[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) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-05-26 10:44:47 +00:00
parent a624567cd8
commit a874dfa08a
+5 -2
View File
@@ -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: