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
X-original-commit: a45bad4
  • Loading branch information
pablohmontenegro authored and zaoral committed Nov 26, 2022
1 parent 1802465 commit aef2d89
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 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,9 +27,20 @@ def get_move(self):
default=get_move
)

<<<<<<< HEAD
day_rate = fields.Boolean(
string="Use currency rate of the day", help="The currency rate on the invoice date will be used. If the invoice does not have a date, the currency rate will be used at the time of validation.")

||||||| parent of b2f2fc30... temp
=======
@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'))

>>>>>>> b2f2fc30... temp
@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 aef2d89

Please sign in to comment.