summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiral Bhavsar <hbh@odoo.com>2018-03-09 13:38:45 +0100
committerqdp-odoo <qdp@odoo.com>2018-03-09 13:50:15 +0100
commited4cbf57dc8d5850bf1e700dea0c35ea2f64c191 (patch)
tree5bf551a84c6f68b91a2a6a600f79829f5b2ac100
parent27098b505abe19a41256a37950b1a2c303a452b3 (diff)
[FIX] account: fix account.payment creation from dashboard
From 'Accounting Dashboard', creating a new payment was raising an error 'Record does not exist or has been deleted.'. That's because since cdca5d4751a979f6b694f02d88160843f81a77f5 the default_get() was expecting to be called directly from the account.invoice model, using 'active_ids' to compute default values. Since it was incorrect, we now also check for the active_model to avoid raising this error. Was PR #23548 Was task: 1824893
-rw-r--r--addons/account/models/account_payment.py3
-rw-r--r--addons/account/tests/test_payment.py2
2 files changed, 3 insertions, 2 deletions
diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py
index b03e5f8f684..2090d03bc30 100644
--- a/addons/account/models/account_payment.py
+++ b/addons/account/models/account_payment.py
@@ -70,9 +70,10 @@ class account_abstract_payment(models.AbstractModel):
def default_get(self, fields):
rec = super(account_abstract_payment, self).default_get(fields)
active_ids = self._context.get('active_ids')
+ active_model = self._context.get('active_model')
# Check for selected invoices ids
- if not active_ids:
+ if not active_ids or active_model != 'account.invoice':
return rec
invoices = self.env['account.invoice'].browse(active_ids)
diff --git a/addons/account/tests/test_payment.py b/addons/account/tests/test_payment.py
index 3e0e1c8961d..3c22a127180 100644
--- a/addons/account/tests/test_payment.py
+++ b/addons/account/tests/test_payment.py
@@ -8,7 +8,7 @@ class TestPayment(AccountingTestCase):
def setUp(self):
super(TestPayment, self).setUp()
- self.register_payments_model = self.env['account.register.payments']
+ self.register_payments_model = self.env['account.register.payments'].with_context(active_model='account.invoice')
self.payment_model = self.env['account.payment']
self.invoice_model = self.env['account.invoice']
self.invoice_line_model = self.env['account.invoice.line']