|
@ -234,17 +234,28 @@ class AccountAnalyticAccount(orm.Model): |
|
|
interval = contract.recurring_interval |
|
|
interval = contract.recurring_interval |
|
|
old_date = next_date |
|
|
old_date = next_date |
|
|
if contract.recurring_rule_type == 'daily': |
|
|
if contract.recurring_rule_type == 'daily': |
|
|
|
|
|
old_date = next_date - relativedelta(days=+interval) |
|
|
new_date = next_date + relativedelta(days=+interval) |
|
|
new_date = next_date + relativedelta(days=+interval) |
|
|
elif contract.recurring_rule_type == 'weekly': |
|
|
elif contract.recurring_rule_type == 'weekly': |
|
|
|
|
|
old_date = next_date - relativedelta(weeks=+interval) |
|
|
new_date = next_date + relativedelta(weeks=+interval) |
|
|
new_date = next_date + relativedelta(weeks=+interval) |
|
|
else: |
|
|
else: |
|
|
|
|
|
old_date = next_date + relativedelta(months=+interval) |
|
|
new_date = next_date + relativedelta(months=+interval) |
|
|
new_date = next_date + relativedelta(months=+interval) |
|
|
|
|
|
|
|
|
context['old_date'] = old_date |
|
|
context['old_date'] = old_date |
|
|
context['next_date'] = new_date |
|
|
|
|
|
|
|
|
context['next_date'] = datetime.datetime.strptime( |
|
|
|
|
|
contract.recurring_next_date or current_date, "%Y-%m-%d") |
|
|
|
|
|
# Force company for correct evaluate domain access rules |
|
|
|
|
|
context['force_company'] = contract.company_id.id |
|
|
|
|
|
# Re-read contract with correct company |
|
|
|
|
|
contract = self.browse(cr, uid, contract.id, context=context) |
|
|
self._prepare_invoice( |
|
|
self._prepare_invoice( |
|
|
cr, uid, contract, context=context) |
|
|
|
|
|
|
|
|
cr, uid, contract, context=context |
|
|
|
|
|
) |
|
|
self.write( |
|
|
self.write( |
|
|
cr, uid, [contract.id], |
|
|
cr, uid, [contract.id], |
|
|
{'recurring_next_date': new_date.strftime('%Y-%m-%d')}, |
|
|
{'recurring_next_date': new_date.strftime('%Y-%m-%d')}, |
|
|
context=context) |
|
|
|
|
|
|
|
|
context=context |
|
|
|
|
|
) |
|
|
return True |
|
|
return True |