[FIX] account: wrong currency in payment terms
Create company A with company currency USD, company B with company currency VND. Set company B-VND in payment terms closes odoo/odoo#161044 Expect: currency payment terms is VND Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user