mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[ADD] - Add renewal process with termination notice
This commit is contained in:
committed by
Thomas Binsfeld
parent
29a83d7769
commit
d12a9110ee
@@ -16,3 +16,12 @@ class AccountAbstractAnalyticContractLine(models.AbstractModel):
|
||||
)
|
||||
self.recurring_interval = self.product_id.recurring_interval
|
||||
self.date_start = fields.Date.today()
|
||||
self.is_auto_renew = self.product_id.is_auto_renew
|
||||
self.auto_renew_interval = self.product_id.auto_renew_interval
|
||||
self.auto_renew_rule_type = self.product_id.auto_renew_rule_type
|
||||
self.termination_notice_interval = (
|
||||
self.product_id.termination_notice_interval
|
||||
)
|
||||
self.termination_notice_rule_type = (
|
||||
self.product_id.termination_notice_rule_type
|
||||
)
|
||||
|
||||
@@ -37,6 +37,26 @@ class ProductTemplate(models.Model):
|
||||
string='Repeat Every',
|
||||
help="Repeat every (Days/Week/Month/Year)",
|
||||
)
|
||||
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(
|
||||
[('monthly', 'Month(s)'), ('yearly', 'Year(s)')],
|
||||
default='yearly',
|
||||
string='Renewal type',
|
||||
help="Specify Interval for automatic renewal.",
|
||||
)
|
||||
termination_notice_interval = fields.Integer(
|
||||
default=1, string='Termination Notice Before'
|
||||
)
|
||||
termination_notice_rule_type = fields.Selection(
|
||||
[('daily', 'Day(s)'), ('weekly', 'Week(s)'), ('monthly', 'Month(s)')],
|
||||
default='monthly',
|
||||
string='Termination Notice type',
|
||||
)
|
||||
|
||||
@api.onchange('is_contract')
|
||||
def _change_is_contract(self):
|
||||
|
||||
@@ -47,8 +47,8 @@ class SaleOrderLine(models.Model):
|
||||
help="Repeat every (Days/Week/Month/Year)",
|
||||
copy=False,
|
||||
)
|
||||
date_start = fields.Date(string='Date Start')
|
||||
date_end = fields.Date(string='Date End', index=True)
|
||||
date_start = fields.Date(string='Date Start',)
|
||||
date_end = fields.Date(string='Date End',)
|
||||
|
||||
contract_line_id = fields.Many2one(
|
||||
comodel_name="account.analytic.invoice.line",
|
||||
@@ -56,6 +56,11 @@ class SaleOrderLine(models.Model):
|
||||
required=False,
|
||||
copy=False,
|
||||
)
|
||||
is_auto_renew = fields.Boolean(
|
||||
string="Auto Renew",
|
||||
related="product_id.is_auto_renew",
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
@api.onchange('product_id')
|
||||
def onchange_product(self):
|
||||
@@ -65,7 +70,14 @@ class SaleOrderLine(models.Model):
|
||||
self.product_id.recurring_invoicing_type
|
||||
)
|
||||
self.recurring_interval = self.product_id.recurring_interval
|
||||
self.date_start = fields.Date.today()
|
||||
self.date_start = self.date_start or fields.Date.today()
|
||||
if self.product_id.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.multi
|
||||
def _prepare_contract_line_values(self, contract):
|
||||
@@ -91,6 +103,13 @@ class SaleOrderLine(models.Model):
|
||||
'recurring_interval': self.recurring_interval,
|
||||
'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_id.auto_renew_interval,
|
||||
'auto_renew_rule_type': self.product_id.auto_renew_rule_type,
|
||||
'termination_notice_interval':
|
||||
self.product_id.termination_notice_interval,
|
||||
'termination_notice_rule_type':
|
||||
self.product_id.termination_notice_rule_type,
|
||||
'contract_id': contract.id,
|
||||
'sale_order_line_id': self.id,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user