|
@ -352,19 +352,21 @@ class AccountAnalyticAccount(models.Model): |
|
|
""" |
|
|
""" |
|
|
today = datetime.today() |
|
|
today = datetime.today() |
|
|
company_model = self.env['res.company'] |
|
|
company_model = self.env['res.company'] |
|
|
|
|
|
contracts = self.with_context(cron=True) |
|
|
for company in company_model.search([]): |
|
|
for company in company_model.search([]): |
|
|
days_before = company.contract_pregenerate_days or 0 |
|
|
days_before = company.contract_pregenerate_days or 0 |
|
|
cutoffdate = ( |
|
|
cutoffdate = ( |
|
|
today + relativedelta(days=days_before) |
|
|
today + relativedelta(days=days_before) |
|
|
).strftime(DEFAULT_SERVER_DATE_FORMAT) |
|
|
).strftime(DEFAULT_SERVER_DATE_FORMAT) |
|
|
contracts = self.with_context(cron=True).search([ |
|
|
|
|
|
|
|
|
contracts = contracts.concat(self.with_context(cron=True).search([ |
|
|
('company_id', '=', company.id), |
|
|
('company_id', '=', company.id), |
|
|
('recurring_invoices', '=', True), |
|
|
('recurring_invoices', '=', True), |
|
|
('recurring_next_date', '<=', cutoffdate), |
|
|
('recurring_next_date', '<=', cutoffdate), |
|
|
'|', |
|
|
'|', |
|
|
('date_end', '=', False), |
|
|
('date_end', '=', False), |
|
|
('date_end', '>=', cutoffdate), |
|
|
('date_end', '>=', cutoffdate), |
|
|
]) |
|
|
|
|
|
|
|
|
])) |
|
|
|
|
|
|
|
|
return contracts.recurring_create_invoice(limit) |
|
|
return contracts.recurring_create_invoice(limit) |
|
|
|
|
|
|
|
|
@api.multi |
|
|
@api.multi |
|
|