[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.
This commit is contained in:
Thibault Delavallée
2017-11-14 17:00:42 +01:00
parent d1c705a990
commit 03068f7ec8
2 changed files with 2 additions and 3 deletions
-2
View File
@@ -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()
+2 -1
View File
@@ -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: