Browse Source

[FIX] - Get auto_renew_rule_type based on recurring_rule_type

pull/208/head
sbejaoui 6 years ago
committed by Thomas Binsfeld
parent
commit
6192a13fe1
  1. 10
      product_contract/models/contract_line.py
  2. 2
      product_contract/models/product_template.py

10
product_contract/models/contract_line.py

@ -24,6 +24,14 @@ class AccountAnalyticInvoiceLine(models.Model):
res['sale_line_ids'] = [(6, 0, [self.sale_order_line_id.id])]
return res
@api.multi
def _get_auto_renew_rule_type(self):
"""monthly last day don't make sense for auto_renew_rule_type"""
self.ensure_one()
if self.recurring_rule_type == "monthlylastday":
return "monthly"
return self.recurring_rule_type
@api.onchange('product_id')
def _onchange_product_id_recurring_info(self):
for rec in self:
@ -36,7 +44,7 @@ class AccountAnalyticInvoiceLine(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.product_id.recurring_rule_type
rec.auto_renew_rule_type = rec._get_auto_renew_rule_type()
rec.termination_notice_interval = (
rec.product_id.termination_notice_interval
)

2
product_contract/models/product_template.py

@ -13,7 +13,7 @@ class ProductTemplate(models.Model):
contract_template_id = fields.Many2one(
comodel_name='account.analytic.contract', string='Contract Template'
)
default_qty = fields.Integer(string="Default Quantity")
default_qty = fields.Integer(string="Default Quantity", default=1)
recurring_rule_type = fields.Selection(
[
('daily', 'Day(s)'),

Loading…
Cancel
Save