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,21 @@ 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(
|
||||
self.product_id.auto_renew_rule_type,
|
||||
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(
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user