From 75df756751b742958853ed1899a69a1294887379 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Mon, 1 Mar 2021 17:18:01 +0000 Subject: [PATCH] [IMP] account: Use currency rate when populating journal entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes odoo/odoo#67036 X-original-commit: f6761a7e8b012f5357711303af532fa0ac5bd77a Signed-off-by: William André (wan) Signed-off-by: Laurent Smet --- addons/account/populate/account_move.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/populate/account_move.py b/addons/account/populate/account_move.py index 91bd1459dad..df43df5200f 100644 --- a/addons/account/populate/account_move.py +++ b/addons/account/populate/account_move.py @@ -96,8 +96,10 @@ class AccountMove(models.Model): :return list: list of ORM create commands for the field line_ids """ def get_line(account, label, balance=None, balance_sign=False, exclude_from_invoice_tab=False): - is_foreign_currency = currency_id != account.company_id.currency_id.id + company_currency = account.company_id.currency_id + currency = self.env['res.currency'].browse(currency_id) balance = balance or balance_sign * round(random.uniform(0, 1000)) + amount_currency = company_currency._convert(balance, currency, account.company_id, date) return (0, 0, { 'name': 'label_%s' % label, 'debit': balance > 0 and balance or 0, @@ -105,10 +107,11 @@ class AccountMove(models.Model): 'account_id': account.id, 'partner_id': partner_id, 'currency_id': currency_id, - 'amount_currency': 2 * balance if is_foreign_currency else balance, + 'amount_currency': amount_currency, 'exclude_from_invoice_tab': exclude_from_invoice_tab, }) move_type = values['move_type'] + date = values['date'] company_id = values['company_id'] currency_id = values['currency_id'] partner_id = values['partner_id']