Browse Source

[IMP] - compute date end onchange date start for auto-renew sale order lines

pull/208/head
sbejaoui 6 years ago
committed by Thomas Binsfeld
parent
commit
4c7a314ef6
  1. 16
      product_contract/models/sale_order_line.py
  2. 1
      product_contract/views/product_template.xml

16
product_contract/models/sale_order_line.py

@ -71,7 +71,7 @@ class SaleOrderLine(models.Model):
)
self.recurring_interval = self.product_id.recurring_interval
self.date_start = self.date_start or fields.Date.today()
if self.product_id.is_auto_renew:
if self.is_auto_renew:
self.date_end = self.date_start + self.env[
'account.analytic.invoice.line'
].get_relative_delta(
@ -79,6 +79,20 @@ class SaleOrderLine(models.Model):
self.product_id.auto_renew_interval,
)
@api.onchange('date_start')
def onchange_date_start(self):
for rec in self:
if rec.is_auto_renew:
if not self.date_start:
rec.date_end = False
else:
self.date_end = self.date_start + self.env[
'account.analytic.invoice.line'
].get_relative_delta(
self.product_id.auto_renew_rule_type,
self.product_id.auto_renew_interval,
)
@api.multi
def _prepare_contract_line_values(self, contract):
self.ensure_one()

1
product_contract/views/product_template.xml

@ -21,6 +21,7 @@
</xpath>
<xpath expr="//notebook" position="inside">
<page string="Contract"
name="contract"
attrs="{'invisible': [('is_contract', '=', False)],}">
<group>
<field name="contract_template_id"

Loading…
Cancel
Save