diff --git a/account_ux/__manifest__.py b/account_ux/__manifest__.py index b15a45c43..c7550440f 100644 --- a/account_ux/__manifest__.py +++ b/account_ux/__manifest__.py @@ -19,7 +19,7 @@ ############################################################################## { 'name': 'Account UX', - 'version': "13.0.1.24.0", + 'version': "13.0.1.25.0", 'category': 'Accounting', 'sequence': 14, 'summary': '', diff --git a/account_ux/wizards/account_change_currency.py b/account_ux/wizards/account_change_currency.py index 110a24384..d3cb0589a 100644 --- a/account_ux/wizards/account_change_currency.py +++ b/account_ux/wizards/account_change_currency.py @@ -3,7 +3,7 @@ # directory ############################################################################## from odoo import fields, models, api, _ - +from odoo.exceptions import ValidationError class AccountChangeCurrency(models.TransientModel): _name = 'account.change.currency' @@ -55,6 +55,13 @@ def onchange_currency(self): date=self.move_id.date or fields.Date.context_today(self)) + @api.constrains('currency_to_id', 'currency_rate') + def _prevent_change_currency(self): + """prevent currency or currency rate change when the invoice is not draft + """ + if self.move_id.state != 'draft': + raise ValidationError(_('This invoice is not draft, reset it to draft to change currency or currency rate')) + def change_currency(self): self.ensure_one() if self.change_type == 'currency':