diff --git a/contract/__manifest__.py b/contract/__manifest__.py index 038d8838..54250c1c 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -9,7 +9,7 @@ { 'name': 'Contracts Management - Recurring', - 'version': '10.0.4.2.1', + 'version': '10.0.4.3.0', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "OpenERP SA, " diff --git a/contract/data/contract_cron.xml b/contract/data/contract_cron.xml index 7c3a1fef..bf8e824e 100644 --- a/contract/data/contract_cron.xml +++ b/contract/data/contract_cron.xml @@ -1,5 +1,5 @@ - + Generate Recurring Invoices from Contracts diff --git a/contract/models/account_analytic_account.py b/contract/models/account_analytic_account.py index ee0f6ee9..361be72a 100644 --- a/contract/models/account_analytic_account.py +++ b/contract/models/account_analytic_account.py @@ -260,13 +260,18 @@ class AccountAnalyticAccount(models.Model): return invoice @api.multi - def recurring_create_invoice(self): + def recurring_create_invoice(self, limit=None): """Create invoices from contracts + :param int limit: + Max of invoices to create. + :return: invoices created """ invoices = self.env['account.invoice'] for contract in self: + if limit and len(invoices) >= limit: + break ref_date = contract.recurring_next_date or fields.Date.today() if (contract.date_start > ref_date or contract.date_end and contract.date_end < ref_date): @@ -294,7 +299,7 @@ class AccountAnalyticAccount(models.Model): return invoices @api.model - def cron_recurring_create_invoice(self): + def cron_recurring_create_invoice(self, limit=None): today = fields.Date.today() contracts = self.with_context(cron=True).search([ ('recurring_invoices', '=', True), @@ -303,7 +308,7 @@ class AccountAnalyticAccount(models.Model): ('date_end', '=', False), ('date_end', '>=', today), ]) - return contracts.recurring_create_invoice() + return contracts.recurring_create_invoice(limit) @api.multi def action_contract_send(self):