diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index f480b119a7b..87ffdce8fb6 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -13131,6 +13131,18 @@ msgid "" " There is nothing left to process." msgstr "" +#. module: account +#: code:addons/account/wizard/account_automatic_entry_wizard.py:0 +#, python-format +msgid "The date of some related entries is protected by a lock date" +msgstr "" + +#. module: account +#: code:addons/account/wizard/account_automatic_entry_wizard.py:0 +#, python-format +msgid "The date selected is protected by a lock date" +msgstr "" + #. module: account #: code:addons/account/models/account_payment_term.py:0 #, python-format diff --git a/addons/account/wizard/account_automatic_entry_wizard.py b/addons/account/wizard/account_automatic_entry_wizard.py index 6632c64f1b5..29965770f01 100644 --- a/addons/account/wizard/account_automatic_entry_wizard.py +++ b/addons/account/wizard/account_automatic_entry_wizard.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from odoo import api, fields, models, _ -from odoo.exceptions import UserError +from odoo.exceptions import UserError, ValidationError from odoo.tools.misc import format_date, formatLang from collections import defaultdict @@ -106,6 +106,17 @@ class AutomaticEntryWizard(models.TransientModel): for record in self: record.display_currency_helper = bool(record.destination_account_id.currency_id) + @api.constrains('date', 'move_line_ids') + def _check_date(self): + for wizard in self: + if wizard.move_line_ids.move_id._get_violated_lock_dates(wizard.date, False): + raise ValidationError(_("The date selected is protected by a lock date")) + + if wizard.action == 'change_period': + for move in wizard.move_line_ids.move_id: + if move._get_violated_lock_dates(move.date, False): + raise ValidationError(_("The date of some related entries is protected by a lock date")) + @api.model def default_get(self, fields): res = super().default_get(fields)