Skip to content

Commit

Permalink
[IMP]l10n_ar_ux:prevent currency change when the invoice is not draft
Browse files Browse the repository at this point in the history
closes #615

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


class AccountMoveChangeRate(models.TransientModel):
Expand All @@ -26,6 +27,13 @@ def get_move(self):
default=get_move
)

@api.constrains('currency_rate')
def _prevent_change_currency(self):
"""prevent currency 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 rate'))

@api.onchange('move_id')
def _onchange_move(self):
self.currency_rate = self.move_id.l10n_ar_currency_rate or self.move_id.computed_currency_rate
Expand Down

0 comments on commit 3037060

Please sign in to comment.