Skip to content
Snippets Groups Projects
Commit 8d90809a5430 authored by Etienne Ferriere's avatar Etienne Ferriere
Browse files

Add the possibility to forbid unreconciliation for accounting entries emitted

on specific accounts on closed periods.
parent 5a3faba08229
No related branches found
No related tags found
No related merge requests found
Pipeline #107004 failed
......@@ -2,6 +2,12 @@
Changelog
=========
13.0.1.6.0
----------
Add the possibility to forbid unreconciliation for accounting entries emitted
on specific accounts on closed periods.
13.0.1.5.1
----------
......
......@@ -33,5 +33,7 @@
* Add accounting date used to select the right period.
* Add transaction date.
* Hide default ``date`` field, obsoleted by accounting date above.
* Add the possibility to forbid unreconciliation for accounting entries emitted
on specific accounts on closed periods.
Inspired from what used to be available in previous Odoo versions.
......@@ -22,7 +22,7 @@
"name": "Accounting Periods",
"license": "AGPL-3",
"summary": "Add period accounting concept",
"version": "13.0.1.5.1",
"version": "13.0.1.6.0",
"category": "Accounting/Accounting",
"author": "XCG Consulting",
"website": "https://odoo.consulting/",
......@@ -31,6 +31,7 @@
"security/ir.model.access.csv",
"security/record_rules.xml",
"wizards/account_period_close_view.xml",
"views/account_account.xml",
"views/account_move.xml",
"views/account_period.xml",
"views/account_fiscalyear.xml",
......
from . import ( # noqa: F401
account_account,
account_chart_template,
account_fiscalyear,
......@@ -2,5 +3,6 @@
account_chart_template,
account_fiscalyear,
account_full_reconcile,
account_move,
account_move_line,
account_period,
......
##############################################################################
#
# Accounting periods, for Odoo
# Copyright (C) 2024 XCG Consulting <http://odoo.consulting>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from odoo import fields, models
class Account(models.Model):
"""Add the possibility to forbid unreconciliation for accounting entries
emitted on specific accounts on closed periods.
"""
_inherit = "account.account"
forbid_unreconcile_closed_periods = fields.Boolean(
string="Forbid unreconciliation on closed periods",
help=(
"Check the box, to forbid unreconciliation for accounting entries "
"emitted on this account on closed periods."
),
index=True,
)
##############################################################################
#
# Accounting periods, for Odoo
# Copyright (C) 2024 XCG Consulting <http://odoo.consulting>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from odoo import _, exceptions, fields, models
class AccountFullReconcile(models.Model):
"""Add the possibility to forbid unreconciliation for accounting entries
emitted on specific accounts on closed periods.
"""
_inherit = "account.full.reconcile"
def unlink(self):
"""Override to:
- Forbid unreconciliation for accounting entries emitted on specific
accounts on closed periods.
"""
# Forbid unreconciliation for accounting entries emitted on specific
# accounts on closed periods.
self.reconciled_line_ids.forbid_unreconcile_closed_periods()
return super().unlink()
......@@ -18,9 +18,9 @@
#
##############################################################################
from odoo import fields, models
from odoo import _, exceptions, fields, models
class AccountMoveLine(models.Model):
"""Add a period & dates onto accounting entries (taken from the related
account.move object).
......@@ -22,8 +22,10 @@
class AccountMoveLine(models.Model):
"""Add a period & dates onto accounting entries (taken from the related
account.move object).
Add the possibility to forbid unreconciliation for accounting entries
emitted on specific accounts on closed periods.
"""
_inherit = "account.move.line"
......@@ -50,3 +52,38 @@
readonly=True,
store=True,
)
def remove_move_reconcile(self):
"""Override to:
- Forbid unreconciliation for accounting entries emitted on specific
accounts on closed periods.
"""
# Forbid unreconciliation for accounting entries emitted on specific
# accounts on closed periods.
self.forbid_unreconcile_closed_periods()
return super().remove_move_reconcile()
def forbid_unreconcile_closed_periods(self):
"""Forbid unreconciliation for accounting entries emitted on specific
accounts on closed periods.
"""
if any(
self.mapped(
lambda r: (
r.account_id.forbid_unreconcile_closed_periods
and r.period_id.state == "done"
)
)
):
raise exceptions.UserError(
_(
"Some accounting entries to unreconcile are emitted on "
"closed periods and accounts, which are set to forbid "
"unreconciliation on closed periods."
)
)
return True
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Add the possibility to forbid unreconciliation for accounting entries
emitted on specific accounts on closed periods. -->
<!-- Inherit from the account form view defined in "account". -->
<record id="account_period_account_form" model="ir.ui.view">
<field name="name">account_period_account_form</field>
<field name="model">account.account</field>
<field name="inherit_id" ref="account.view_account_form" />
<field name="arch" type="xml">
<!-- Add fields. -->
<xpath expr="//div[field[@name='reconcile']]" position="after">
<field name="forbid_unreconcile_closed_periods" />
</xpath>
</field>
</record>
</odoo>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment