diff --git a/product_contract/models/contract_line.py b/product_contract/models/contract_line.py index 1e0cd4fe..a298cbbe 100644 --- a/product_contract/models/contract_line.py +++ b/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 ) diff --git a/product_contract/models/product_template.py b/product_contract/models/product_template.py index f73cc3af..f09cec8b 100644 --- a/product_contract/models/product_template.py +++ b/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)'),