Commit 3b9b0e94 authored by Luca Cristaldi's avatar Luca Cristaldi

rewrite function

parent 1c762076
Pipeline #233 failed with stages
in 1 minute and 11 seconds
......@@ -10,9 +10,33 @@ class Subscription(metaclass=PoolMeta):
include = fields.Boolean("Include", states={'readonly': Eval('state') != 'draft'})
def compute_next_invoice_date(self):
date = super(Subscription, self).compute_next_invoice_date()
if(self.include and not self.next_invoice_date):
return self.invoice_start_date or self.start_date
else:
return date
\ No newline at end of file
# def compute_next_invoice_date(self):
# date = super(Subscription, self).compute_next_invoice_date()
# if(self.include and not self.next_invoice_date):
# return self.invoice_start_date or self.start_date
# else:
# return date
@classmethod
@ModelView.button
@Workflow.transition('running')
def run(cls, subscriptions):
pool = Pool()
Line = pool.get('sale.subscription.line')
lines = []
for subscription in subscriptions:
if not subscription.next_invoice_date:
if subscription.include:
subscription.next_invoice_date = (subscription.invoice_start_date or subscription.start_date)
else:
subscription.next_invoice_date = (subscription.compute_next_invoice_date())
for line in subscription.lines:
if (line.next_consumption_date is None
and not line.consumed):
if subscription.include:
subscription.next_invoice_date = (subscription.invoice_start_date or subscription.start_date)
else:
line.next_consumption_date = (line.compute_next_consumption_date())
lines.extend(subscription.lines)
Line.save(lines)
cls.save(subscriptions)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment