[IMP]GOLEM Activity Registration Payment : manage canceled invoice

This commit is contained in:
Fabien BOURGEOIS 2018-08-05 05:50:51 +02:00
parent 8b40f33a9d
commit 56f6bd9615
2 changed files with 9 additions and 3 deletions

View File

@ -19,7 +19,7 @@
'name': 'GOLEM Activity Member Registration Payments', 'name': 'GOLEM Activity Member Registration Payments',
'summary': 'GOLEM Activities Member Registration Payments', 'summary': 'GOLEM Activities Member Registration Payments',
'description': 'GOLEM Activities Member Registration Payments', 'description': 'GOLEM Activities Member Registration Payments',
'version': '10.0.0.3.3', 'version': '10.0.0.3.4',
'category': 'GOLEM', 'category': 'GOLEM',
'author': 'Fabien Bourgeois', 'author': 'Fabien Bourgeois',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@ -33,7 +33,11 @@ class GolemMember(models.Model):
""" Check if there are confirmed registrations with no invoice linked """ """ Check if there are confirmed registrations with no invoice linked """
for member in self: for member in self:
regis = member.activity_registration_ids regis = member.activity_registration_ids
regis = regis.filtered(lambda r: r.state == 'confirmed' and not r.invoice_line_id) regis = regis.filtered(
lambda r: (r.state == 'confirmed' and
(not r.invoice_line_id or
r.invoice_line_id.invoice_id.state == 'cancel'))
)
member.has_invoicable_registrations = bool(len(regis)) member.has_invoicable_registrations = bool(len(regis))
def invoice_line_data_get(self, registration): def invoice_line_data_get(self, registration):
@ -48,7 +52,9 @@ class GolemMember(models.Model):
self.ensure_one() self.ensure_one()
member = self[0] member = self[0]
registrations = member.activity_registration_ids.filtered( registrations = member.activity_registration_ids.filtered(
lambda r: r.state == 'confirmed' and not r.invoice_line_id lambda r: r.state == 'confirmed' and
(not r.invoice_line_id or
r.invoice_line_id.invoice_id.state == 'cancel')
) )
if registrations: if registrations:
invoicing = self.env['golem.activity.registration.invoicing'].create({ invoicing = self.env['golem.activity.registration.invoicing'].create({