[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:
@@ -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)
|
||||
|
||||
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user