Skip to content
Browse files

account: dont put residual currency if it is the company currency

OPW 1925104
If a invoice is made in a foreign currency but is paid in the company currency, the amount_currency will be set on the account move line, messing with the reconciliation
  • Loading branch information...
william-andre committed Mar 18, 2019
1 parent ebbb5b8 commit 3c963e74780ac3bf2be3c24637d73b679dbac04b
Showing with 4 additions and 8 deletions.
  1. +0 −4 addons/account/models/
  2. +4 −4 addons/account/models/
@@ -915,10 +915,6 @@ def register_payment(self, payment_line, writeoff_acc_id=False, writeoff_journal
def assign_outstanding_credit(self, credit_aml_id):
credit_aml = self.env['account.move.line'].browse(credit_aml_id)
if not credit_aml.currency_id and self.currency_id != self.company_id.currency_id:
credit_aml.with_context(allow_amount_currency=True, check_move_validity=False).write({
'amount_currency': self.company_id.currency_id.with_context(, self.currency_id),
if credit_aml.payment_id:
credit_aml.payment_id.write({'invoice_ids': [(4,, None)]})
return self.register_payment(credit_aml)
@@ -74,7 +74,7 @@ def _compute_hide_payment_method(self):
def _onchange_journal(self):
if self.journal_id:
self.currency_id = self.journal_id.currency_id or self.company_id.currency_id
self.currency_id = self.journal_id.currency_id or self.currency_id or self.company_id.currency_id
# Set default payment method (we consider the first to be the default one)
payment_methods = self.payment_type == 'inbound' and self.journal_id.inbound_payment_method_ids or self.journal_id.outbound_payment_method_ids
self.payment_method_id = payment_methods and payment_methods[0] or False
@@ -546,8 +546,8 @@ def _create_payment_entry(self, amount):
Return the journal entry.
aml_obj = self.env['account.move.line'].with_context(check_move_validity=False)
invoice_currency = False
if self.invoice_ids and all([x.currency_id == self.invoice_ids[0].currency_id for x in self.invoice_ids]):
invoice_currency = self.currency_id
if not invoice_currency and self.invoice_ids and all([x.currency_id == self.invoice_ids[0].currency_id for x in self.invoice_ids]):
#if all the invoices selected share the same currency, record the paiement in that currency too
invoice_currency = self.invoice_ids[0].currency_id
debit, credit, amount_currency, currency_id = aml_obj.with_context(date=self.payment_date).compute_amount_fields(amount, self.currency_id, self.company_id.currency_id, invoice_currency)
@@ -557,7 +557,7 @@ def _create_payment_entry(self, amount):
#Write line corresponding to invoice payment
counterpart_aml_dict = self._get_shared_move_line_vals(debit, credit, amount_currency,, False)
counterpart_aml_dict.update({'currency_id': currency_id})
counterpart_aml_dict.update({'currency_id': currency_id != and currency_id})
counterpart_aml = aml_obj.create(counterpart_aml_dict)

#Reconcile with the invoices

0 comments on commit 3c963e7

Please sign in to comment.
You can’t perform that action at this time.