|
@ -260,13 +260,18 @@ class AccountAnalyticAccount(models.Model): |
|
|
return invoice |
|
|
return invoice |
|
|
|
|
|
|
|
|
@api.multi |
|
|
@api.multi |
|
|
def recurring_create_invoice(self): |
|
|
|
|
|
|
|
|
def recurring_create_invoice(self, limit=None): |
|
|
"""Create invoices from contracts |
|
|
"""Create invoices from contracts |
|
|
|
|
|
|
|
|
|
|
|
:param int limit: |
|
|
|
|
|
Max of invoices to create. |
|
|
|
|
|
|
|
|
:return: invoices created |
|
|
:return: invoices created |
|
|
""" |
|
|
""" |
|
|
invoices = self.env['account.invoice'] |
|
|
invoices = self.env['account.invoice'] |
|
|
for contract in self: |
|
|
for contract in self: |
|
|
|
|
|
if limit and len(invoices) >= limit: |
|
|
|
|
|
break |
|
|
ref_date = contract.recurring_next_date or fields.Date.today() |
|
|
ref_date = contract.recurring_next_date or fields.Date.today() |
|
|
if (contract.date_start > ref_date or |
|
|
if (contract.date_start > ref_date or |
|
|
contract.date_end and contract.date_end < ref_date): |
|
|
contract.date_end and contract.date_end < ref_date): |
|
@ -294,7 +299,7 @@ class AccountAnalyticAccount(models.Model): |
|
|
return invoices |
|
|
return invoices |
|
|
|
|
|
|
|
|
@api.model |
|
|
@api.model |
|
|
def cron_recurring_create_invoice(self): |
|
|
|
|
|
|
|
|
def cron_recurring_create_invoice(self, limit=None): |
|
|
today = fields.Date.today() |
|
|
today = fields.Date.today() |
|
|
contracts = self.with_context(cron=True).search([ |
|
|
contracts = self.with_context(cron=True).search([ |
|
|
('recurring_invoices', '=', True), |
|
|
('recurring_invoices', '=', True), |
|
@ -303,7 +308,7 @@ class AccountAnalyticAccount(models.Model): |
|
|
('date_end', '=', False), |
|
|
('date_end', '=', False), |
|
|
('date_end', '>=', today), |
|
|
('date_end', '>=', today), |
|
|
]) |
|
|
]) |
|
|
return contracts.recurring_create_invoice() |
|
|
|
|
|
|
|
|
return contracts.recurring_create_invoice(limit) |
|
|
|
|
|
|
|
|
@api.multi |
|
|
@api.multi |
|
|
def action_contract_send(self): |
|
|
def action_contract_send(self): |
|
|