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
Ticket: 51808
  • Loading branch information
pablohmontenegro committed May 17, 2022
1 parent e3f0f8c commit dfddc7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion l10n_ar_ux/__manifest__.py
@@ -1,6 +1,6 @@
{
'name': 'Argentinian Accounting UX',
'version': "13.0.1.39.0",
'version': "13.0.1.40.0",
'category': 'Localization/Argentina',
'sequence': 14,
'author': 'ADHOC SA',
Expand Down
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 dfddc7f

Please sign in to comment.