[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 cdca5d4751 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
This commit is contained in:
Hiral Bhavsar
2018-03-09 13:50:15 +01:00
committed by qdp-odoo
parent 27098b505a
commit ed4cbf57dc
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -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)
+1 -1
View File
@@ -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']