diff --git a/addons/account/models/account_payment_term.py b/addons/account/models/account_payment_term.py index 27f7336840e..8a37524bcc4 100644 --- a/addons/account/models/account_payment_term.py +++ b/addons/account/models/account_payment_term.py @@ -26,7 +26,7 @@ class AccountPaymentTerm(models.Model): company_id = fields.Many2one('res.company', string='Company') fiscal_country_codes = fields.Char(compute='_compute_fiscal_country_codes') sequence = fields.Integer(required=True, default=10) - currency_id = fields.Many2one('res.currency', default=lambda self: self.env.company.currency_id, store=True) + currency_id = fields.Many2one('res.currency', compute="_compute_currency_id") display_on_invoice = fields.Boolean(string='Show installment dates', default=True) example_amount = fields.Monetary(currency_field='currency_id', default=1000, store=False, readonly=True) @@ -51,6 +51,12 @@ class AccountPaymentTerm(models.Model): allowed_companies = record.company_id or self.env.companies record.fiscal_country_codes = ",".join(allowed_companies.mapped('account_fiscal_country_id.code')) + @api.depends_context('company') + @api.depends('company_id') + def _compute_currency_id(self): + for payment_term in self: + payment_term.currency_id = payment_term.company_id.currency_id or self.env.company.currency_id + def _get_amount_due_after_discount(self, total_amount, untaxed_amount): self.ensure_one() if self.early_discount: