mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[12.0][IMP] - add new option: create_new_line_at_contract_line_renew
Add a company config option to decide whether to create or to extend contract line at renew action
This commit is contained in:
committed by
Francisco Ivan Anton Prieto
parent
f2de4aafe9
commit
becaad164f
@@ -1177,17 +1177,27 @@ class ContractLine(models.Model):
|
||||
)
|
||||
return date_start, date_end
|
||||
|
||||
@api.multi
|
||||
def _renew_create_line(self, date_start, date_end):
|
||||
self.ensure_one()
|
||||
is_auto_renew = self.is_auto_renew
|
||||
self.stop(self.date_end, post_message=False)
|
||||
new_line = self.plan_successor(
|
||||
date_start, date_end, is_auto_renew, post_message=False
|
||||
)
|
||||
new_line._onchange_date_start()
|
||||
return new_line
|
||||
|
||||
@api.multi
|
||||
def renew(self):
|
||||
res = self.env['contract.line']
|
||||
for rec in self:
|
||||
is_auto_renew = rec.is_auto_renew
|
||||
rec.stop(rec.date_end, post_message=False)
|
||||
company = rec.contract_id.company_id
|
||||
date_start, date_end = rec._get_renewal_dates()
|
||||
new_line = rec.plan_successor(
|
||||
date_start, date_end, is_auto_renew, post_message=False
|
||||
)
|
||||
new_line._onchange_date_start()
|
||||
if company.create_new_line_at_contract_line_renew:
|
||||
new_line = rec._renew_create_line(date_start, date_end)
|
||||
else:
|
||||
raise NotImplementedError
|
||||
res |= new_line
|
||||
msg = _(
|
||||
"""Contract line for <strong>{product}</strong>
|
||||
|
||||
Reference in New Issue
Block a user