Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP]account_ux:prevent currency change when the invoice is not draft #341

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions account_ux/wizards/account_change_currency.py
Original file line number Diff line number Diff line change
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