summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2020-05-25 06:49:08 +0000
committerNicolas Martinelli <nim@odoo.com>2020-05-26 10:44:47 +0000
commita874dfa08abd5b3c54e29c0257dfa23118b910da (patch)
tree8f79f37f9895b7ac08f09de751598f680ac3843c
parenta624567cd817eac8624ee03c6a1f1b3711fcded0 (diff)
[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>
-rw-r--r--addons/account/models/account_move.py7
1 files 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: