mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
@@ -46,8 +46,8 @@ class ContractLine(models.Model):
|
||||
)
|
||||
rec.recurring_interval = 1
|
||||
rec.is_auto_renew = rec.product_id.is_auto_renew
|
||||
rec.auto_renew_interval = rec.product_id.default_qty
|
||||
rec.auto_renew_rule_type = rec._get_auto_renew_rule_type()
|
||||
rec.auto_renew_interval = rec.product_id.auto_renew_interval
|
||||
rec.auto_renew_rule_type = rec.product_id.auto_renew_rule_type
|
||||
rec.termination_notice_interval = (
|
||||
rec.product_id.termination_notice_interval
|
||||
)
|
||||
|
||||
@@ -43,6 +43,22 @@ class ProductTemplate(models.Model):
|
||||
default='monthly',
|
||||
string='Termination Notice type',
|
||||
)
|
||||
auto_renew_interval = fields.Integer(
|
||||
default=1,
|
||||
string='Renew Every',
|
||||
help="Renew every (Days/Week/Month/Year)",
|
||||
)
|
||||
auto_renew_rule_type = fields.Selection(
|
||||
[
|
||||
('daily', 'Day(s)'),
|
||||
('weekly', 'Week(s)'),
|
||||
('monthly', 'Month(s)'),
|
||||
('yearly', 'Year(s)'),
|
||||
],
|
||||
default='yearly',
|
||||
string='Renewal type',
|
||||
help="Specify Interval for automatic renewal.",
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
|
||||
@@ -49,6 +49,23 @@ class SaleOrderLine(models.Model):
|
||||
required=False,
|
||||
copy=False,
|
||||
)
|
||||
is_auto_renew = fields.Boolean(string="Auto Renew", default=False)
|
||||
auto_renew_interval = fields.Integer(
|
||||
default=1,
|
||||
string='Renew Every',
|
||||
help="Renew every (Days/Week/Month/Year)",
|
||||
)
|
||||
auto_renew_rule_type = fields.Selection(
|
||||
[
|
||||
('daily', 'Day(s)'),
|
||||
('weekly', 'Week(s)'),
|
||||
('monthly', 'Month(s)'),
|
||||
('yearly', 'Year(s)'),
|
||||
],
|
||||
default='yearly',
|
||||
string='Renewal type',
|
||||
help="Specify Interval for automatic renewal.",
|
||||
)
|
||||
|
||||
@api.constrains('contract_id')
|
||||
def check_contact_is_not_terminated(self):
|
||||
@@ -97,6 +114,14 @@ class SaleOrderLine(models.Model):
|
||||
)
|
||||
- relativedelta(days=1)
|
||||
)
|
||||
rec.is_auto_renew = rec.product_id.is_auto_renew
|
||||
if rec.is_auto_renew:
|
||||
rec.auto_renew_interval = (
|
||||
rec.product_id.auto_renew_interval
|
||||
)
|
||||
rec.auto_renew_rule_type = (
|
||||
rec.product_id.auto_renew_rule_type
|
||||
)
|
||||
|
||||
@api.onchange('date_start', 'product_uom_qty', 'recurring_rule_type')
|
||||
def onchange_date_start(self):
|
||||
@@ -164,9 +189,9 @@ class SaleOrderLine(models.Model):
|
||||
'recurring_interval': 1,
|
||||
'recurring_invoicing_type': self.recurring_invoicing_type,
|
||||
'recurring_rule_type': self.recurring_rule_type,
|
||||
'is_auto_renew': self.product_id.is_auto_renew,
|
||||
'auto_renew_interval': self.product_uom_qty,
|
||||
'auto_renew_rule_type': self._get_auto_renew_rule_type(),
|
||||
'is_auto_renew': self.is_auto_renew,
|
||||
'auto_renew_interval': self.auto_renew_interval,
|
||||
'auto_renew_rule_type': self.auto_renew_rule_type,
|
||||
'termination_notice_interval': termination_notice_interval,
|
||||
'termination_notice_rule_type': termination_notice_rule_type,
|
||||
'contract_id': contract.id,
|
||||
|
||||
Reference in New Issue
Block a user