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
closes #341

Ticket: 51808
Related: ingadhoc/odoo-argentina#615
Signed-off-by: Katherine Zaoral <kz@adhoc.com.ar>
  • Loading branch information
pablohmontenegro authored and zaoral committed Nov 26, 2022
1 parent ea218a2 commit f20c09b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions account_ux/wizards/account_change_currency.py
Expand Up @@ -3,6 +3,7 @@
# directory
##############################################################################
from odoo import fields, models, api, _
from odoo.exceptions import ValidationError


class AccountChangeCurrency(models.TransientModel):
Expand Down Expand Up @@ -55,6 +56,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 f20c09b

Please sign in to comment.