From a874dfa08abd5b3c54e29c0257dfa23118b910da Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 25 May 2020 06:49:08 +0000 Subject: [PATCH] [FIX] account: foreign exchange partner - Create rates at dates 1 and 2 for a foreign currency - Create an invoice at date 1 in foreign currency, set a partner - Register a payment at date 2 The foreign exchange entry has no partner, while it should have as it was the case up to 12.0. opw-2249257 closes odoo/odoo#51873 X-original-commit: 3bc48c01f68c6ee95bec206a4a992adc43a0d8b9 Signed-off-by: Nicolas Martinelli (nim) --- addons/account/models/account_move.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index fd6d382c335..d5c273a5747 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3919,8 +3919,11 @@ class AccountMoveLine(models.Model): # Eventually create a journal entry to book the difference due to foreign currency's exchange rate that fluctuates if to_balance and any([not float_is_zero(residual, precision_rounding=digits_rounding_precision) for aml, residual in to_balance.values()]): if not self.env.context.get('no_exchange_difference'): - exchange_move = self.env['account.move'].with_context(default_move_type='entry').create( - self.env['account.full.reconcile']._prepare_exchange_diff_move(move_date=maxdate, company=amls[0].company_id)) + exchange_move_vals = self.env['account.full.reconcile']._prepare_exchange_diff_move( + move_date=maxdate, company=amls[0].company_id) + if len(amls.mapped('partner_id')) == 1 and amls[0].partner_id: + exchange_move_vals['partner_id'] = amls[0].partner_id.id + exchange_move = self.env['account.move'].with_context(default_move_type='entry').create(exchange_move_vals) part_reconcile = self.env['account.partial.reconcile'] for aml_to_balance, total in to_balance.values(): if total: