From 03068f7ec85b0f1d941ec2253530ec1523aeadff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 14 Nov 2017 13:13:49 +0100 Subject: [PATCH] [IMP] sale_payment: avoid defining out-of-the-blue context keys when odoo behavior is sufficient As what has been implemented is basically a default, let us use the default mechanism of odoo. --- addons/account/models/account_invoice.py | 2 -- addons/sale_payment/models/payment.py | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index ce099bd0ea4..f760bdca07d 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1387,8 +1387,6 @@ class AccountInvoice(models.Model): 'payment_difference_handling': writeoff_acc and 'reconcile' or 'open', 'writeoff_account_id': writeoff_acc and writeoff_acc.id or False, } - if self.env.context.get('tx_currency_id'): - payment_vals['currency_id'] = self.env.context.get('tx_currency_id') payment = self.env['account.payment'].create(payment_vals) payment.post() diff --git a/addons/sale_payment/models/payment.py b/addons/sale_payment/models/payment.py index fab6f546d6f..e5c8e7e4ddc 100644 --- a/addons/sale_payment/models/payment.py +++ b/addons/sale_payment/models/payment.py @@ -87,7 +87,8 @@ class PaymentTransaction(models.Model): _logger.warning('<%s> transaction completed, could not auto-generate payment for %s (ID %s) (no journal set on acquirer)', self.acquirer_id.provider, self.sale_order_id.name, self.sale_order_id.id) self.acquirer_id.journal_id = default_journal - created_invoice.with_context(tx_currency_id=self.currency_id.id).pay_and_reconcile(self.acquirer_id.journal_id, pay_amount=created_invoice.amount_total) + # TDE Note: in post-v11 we could probably add an explicit parameter + update account.payment tx directly at creation, not afterwards + created_invoice.with_context(default_currency_id=self.currency_id.id).pay_and_reconcile(self.acquirer_id.journal_id, pay_amount=created_invoice.amount_total) if created_invoice.payment_ids: created_invoice.payment_ids[0].payment_transaction_id = self else: