Browse Source

#356 fix the cron recurring invoice creation in a multi-company setup

pull/360/head
Peter Morawski 5 years ago
parent
commit
a54b6d1fea
  1. 6
      contract/models/account_analytic_account.py

6
contract/models/account_analytic_account.py

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

Loading…
Cancel
Save