Skip to content

Commit

Permalink
[IMP]account_ux:prevent currency change when the invoice is not draft
Browse files Browse the repository at this point in the history
Ticket: 51808
  • Loading branch information
pablohmontenegro committed May 17, 2022
1 parent 9a98c2d commit 5c2457b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion account_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Account UX',
'version': "13.0.1.24.0",
'version': "13.0.1.25.0",
'category': 'Accounting',
'sequence': 14,
'summary': '',
Expand Down
9 changes: 8 additions & 1 deletion account_ux/wizards/account_change_currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# directory
##############################################################################
from odoo import fields, models, api, _

from odoo.exceptions import ValidationError

class AccountChangeCurrency(models.TransientModel):
_name = 'account.change.currency'
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit 5c2457b

Please sign in to comment.