diff options
| author | Goffin Simon <sig@odoo.com> | 2017-09-18 17:06:13 +0200 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2017-09-19 00:04:24 +0200 |
| commit | 875dd9221f80ea1b60cd9ee8a005d71246734a2b (patch) | |
| tree | 90dd29079bc4eb7f8ae4b0b1c30f3a7d0cfd8bed | |
| parent | 58c5b1cfd83a947a3b9d621ed20db9a118d88662 (diff) | |
[FIX] account, website_portal_sale: _generate_and_pay_invoice in other currency
When paying in other currency that the one defined in the company, it
generates a payment which has to be in the currency of the transaction.
Otherwise it will generate an invoice which won't be completely paid.
opw:769278
| -rw-r--r-- | addons/account/models/account_invoice.py | 8 | ||||
| -rw-r--r-- | addons/website_portal_sale/models/payment.py | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 56b95ab8feb..c56ea11333b 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1113,7 +1113,7 @@ class AccountInvoice(models.Model): if self.origin: communication = '%s (%s)' % (communication, self.origin) - payment = self.env['account.payment'].create({ + payment_vals = { 'invoice_ids': [(6, 0, self.ids)], 'amount': pay_amount or self.residual, 'payment_date': date or fields.Date.context_today(self), @@ -1125,7 +1125,11 @@ class AccountInvoice(models.Model): 'payment_method_id': payment_method.id, '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() return True diff --git a/addons/website_portal_sale/models/payment.py b/addons/website_portal_sale/models/payment.py index 1005250807f..7aa838149bd 100644 --- a/addons/website_portal_sale/models/payment.py +++ b/addons/website_portal_sale/models/payment.py @@ -29,7 +29,7 @@ class PaymentTransaction(models.Model): created_invoice.action_invoice_open() if tx.acquirer_id.journal_id: - created_invoice.pay_and_reconcile(tx.acquirer_id.journal_id, pay_amount=created_invoice.amount_total) + created_invoice.with_context(tx_currency_id=tx.currency_id.id).pay_and_reconcile(tx.acquirer_id.journal_id, pay_amount=created_invoice.amount_total) if created_invoice.payment_ids: created_invoice.payment_ids[0].payment_transaction_id = tx else: |
