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 authored and zaoral committed Nov 26, 2022
1 parent ea218a2 commit 8701e04
Showing 1 changed file with 8 additions and 1 deletion.
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 8701e04

Please sign in to comment.