From 118a3f9099b16bb22f0e986cdf28f850e7fab2d6 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 9 Dec 2024 13:51:21 +0100 Subject: [PATCH] [IMP] product_contract: add recurring_interval --- product_contract/models/product_template.py | 5 ++++ product_contract/models/sale_order_line.py | 2 +- .../models/sale_order_line_contract_mixin.py | 11 ++++++++ .../contract_configurator_controller.esm.js | 2 ++ .../static/src/js/sale_product_field.esm.js | 1 + product_contract/views/sale_order.xml | 14 ++++++++--- .../product_contract_configurator_views.xml | 25 +++++++++++++++---- 7 files changed, 51 insertions(+), 9 deletions(-) diff --git a/product_contract/models/product_template.py b/product_contract/models/product_template.py index a75d29a231..0c86bc01a5 100644 --- a/product_contract/models/product_template.py +++ b/product_contract/models/product_template.py @@ -26,6 +26,11 @@ class ProductTemplate(models.Model): default="monthly", help="Specify Interval for contract duration.", ) + recurring_interval = fields.Integer( + default=1, + string="Invoice Every", + help="Invoice every (Days/Week/Month/Year)", + ) recurring_rule_type = fields.Selection( [ ("daily", "Day(s)"), diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index cd53494b8a..561e4c273d 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -69,7 +69,7 @@ def _prepare_contract_line_values( "date_end": self.date_end, "date_start": self.date_start or fields.Date.today(), "recurring_next_date": recurring_next_date, - "recurring_interval": 1, + "recurring_interval": self.recurring_interval, "recurring_invoicing_type": self.recurring_invoicing_type, "recurring_rule_type": self.recurring_rule_type, "is_auto_renew": self.is_auto_renew, diff --git a/product_contract/models/sale_order_line_contract_mixin.py b/product_contract/models/sale_order_line_contract_mixin.py index 3a53977d0c..0d4bea84bb 100644 --- a/product_contract/models/sale_order_line_contract_mixin.py +++ b/product_contract/models/sale_order_line_contract_mixin.py @@ -43,6 +43,15 @@ class SaleOrderLineContractMixin(models.AbstractModel): store=True, readonly=False, ) + recurring_interval = fields.Integer( + default=1, + string="Invoice Every", + help="Invoice every (Days/Week/Month/Year)", + compute="_compute_product_contract_data", + precompute=True, + store=True, + readonly=False, + ) recurring_rule_type = fields.Selection( [ ("daily", "Day(s)"), @@ -169,6 +178,7 @@ def _compute_product_contract_data(self): for rec in self: vals = { "recurrence_number": 0, + "recurring_interval": 0, "recurring_rule_type": False, "recurring_invoicing_type": False, "recurrence_interval": False, @@ -181,6 +191,7 @@ def _compute_product_contract_data(self): p = rec.product_id vals = { "recurrence_number": p.default_qty, + "recurring_interval": p.recurring_interval, "recurring_rule_type": p.recurring_rule_type, "recurring_invoicing_type": p.recurring_invoicing_type, "recurrence_interval": p.recurrence_interval, diff --git a/product_contract/static/src/js/contract_configurator_controller.esm.js b/product_contract/static/src/js/contract_configurator_controller.esm.js index fb07e3d3b2..e5a7a411b1 100644 --- a/product_contract/static/src/js/contract_configurator_controller.esm.js +++ b/product_contract/static/src/js/contract_configurator_controller.esm.js @@ -15,6 +15,7 @@ export class ProductContractConfiguratorController extends formView.Controller { const { product_uom_qty, recurrence_number, + recurring_interval, recurring_rule_type, recurrence_interval, contract_id, @@ -31,6 +32,7 @@ export class ProductContractConfiguratorController extends formView.Controller { productContractConfiguration: { product_uom_qty, recurrence_number, + recurring_interval, recurring_rule_type, recurrence_interval, contract_id, diff --git a/product_contract/static/src/js/sale_product_field.esm.js b/product_contract/static/src/js/sale_product_field.esm.js index 843c27dcc4..7e331d4577 100644 --- a/product_contract/static/src/js/sale_product_field.esm.js +++ b/product_contract/static/src/js/sale_product_field.esm.js @@ -30,6 +30,7 @@ patch(SaleOrderLineProductField.prototype, { default_partner_id: this.props.record.model.root.data.partner_id[0], default_company_id: this.props.record.model.root.data.company_id[0], default_recurrence_number: this.props.record.data.recurrence_number, + default_recurring_interval: this.props.record.data.recurring_interval, default_recurring_rule_type: this.props.record.data.recurring_rule_type, default_recurrence_interval: this.props.record.data.recurrence_interval, default_product_uom_qty: this.props.record.data.product_uom_qty, diff --git a/product_contract/views/sale_order.xml b/product_contract/views/sale_order.xml index 220bc3d9da..b93b9a6a5d 100644 --- a/product_contract/views/sale_order.xml +++ b/product_contract/views/sale_order.xml @@ -62,9 +62,16 @@ invisible="not is_contract" /> - - - + @@ -116,6 +123,7 @@ /> + diff --git a/product_contract/wizards/product_contract_configurator_views.xml b/product_contract/wizards/product_contract_configurator_views.xml index 42f30fa4c6..9733adf224 100644 --- a/product_contract/wizards/product_contract_configurator_views.xml +++ b/product_contract/wizards/product_contract_configurator_views.xml @@ -13,8 +13,22 @@ - + + + + - - - - +