mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] - compute date end onchange date start for auto-renew sale order lines
This commit is contained in:
@@ -71,7 +71,7 @@ class SaleOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
self.recurring_interval = self.product_id.recurring_interval
|
self.recurring_interval = self.product_id.recurring_interval
|
||||||
self.date_start = self.date_start or fields.Date.today()
|
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[
|
self.date_end = self.date_start + self.env[
|
||||||
'account.analytic.invoice.line'
|
'account.analytic.invoice.line'
|
||||||
].get_relative_delta(
|
].get_relative_delta(
|
||||||
@@ -79,6 +79,20 @@ class SaleOrderLine(models.Model):
|
|||||||
self.product_id.auto_renew_interval,
|
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
|
@api.multi
|
||||||
def _prepare_contract_line_values(self, contract):
|
def _prepare_contract_line_values(self, contract):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//notebook" position="inside">
|
<xpath expr="//notebook" position="inside">
|
||||||
<page string="Contract"
|
<page string="Contract"
|
||||||
|
name="contract"
|
||||||
attrs="{'invisible': [('is_contract', '=', False)],}">
|
attrs="{'invisible': [('is_contract', '=', False)],}">
|
||||||
<group>
|
<group>
|
||||||
<field name="contract_template_id"
|
<field name="contract_template_id"
|
||||||
|
|||||||
Reference in New Issue
Block a user