Rename getter of has_payments to avoid name collision

issue10810
review339021002
This commit is contained in:
Cédric Krier committed 2021-10-03 13:48:43 +02:00
1 parent fdd1a160dd
commit 8006ab71ca
2 files changed
+6 -4

No files matched your search

+4 -4
View File
@@ -482,7 +482,7 @@ class Mandate(Workflow, ModelSQL, ModelView):
], 'State', readonly=True)
payments = fields.One2Many('account.payment', 'sepa_mandate', 'Payments')
has_payments = fields.Function(fields.Boolean('Has Payments'),
'has_payments')
'get_has_payments')
@classmethod
def __setup__(cls):
@@ -650,10 +650,10 @@ class Mandate(Workflow, ModelSQL, ModelView):
return 'RCUR'
@classmethod
def has_payments(cls, mandates, name):
def get_has_payments(cls, mandates, name):
pool = Pool()
Payment = pool.get('account.payment')
payment = Payment.__table__
payment = Payment.__table__()
cursor = Transaction().connection.cursor()
has_payments = dict.fromkeys([m.id for m in mandates], False)
@@ -664,7 +664,7 @@ class Mandate(Workflow, ModelSQL, ModelView):
group_by=payment.sepa_mandate))
has_payments.update(cursor)
return {'has_payments': has_payments}
return has_payments
@classmethod
@ModelView.button
+2
View File
@@ -299,6 +299,7 @@ class AccountPaymentSepaTestCase(CompanyTestMixin, ModuleTestCase):
journal = setup_journal('pain.008.001.02', 'receivable',
company, company_account)
self.assertFalse(mandate.has_payments)
self.assertEqual(mandate.sequence_type, 'FRST')
mandate.sequence_type_rcur = True
self.assertEqual(mandate.sequence_type, 'RCUR')
@@ -322,6 +323,7 @@ class AccountPaymentSepaTestCase(CompanyTestMixin, ModuleTestCase):
_, data = process_payment.do_process(None)
self.assertEqual(payment.sepa_mandate_sequence_type, 'FRST')
self.assertTrue(payment.sepa_mandate.has_payments)
payments = Payment.create([{
'company': company,