Skip to content

Commit

Permalink
[IMP] product_contract: add recurring_interval
Browse files Browse the repository at this point in the history
  • Loading branch information
sbejaoui committed Dec 9, 2024
1 parent 04afaf5 commit 118a3f9
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 9 deletions.
5 changes: 5 additions & 0 deletions product_contract/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"),
Expand Down
2 changes: 1 addition & 1 deletion product_contract/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions product_contract/models/sale_order_line_contract_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"),
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions product_contract/static/src/js/sale_product_field.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 11 additions & 3 deletions product_contract/views/sale_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,16 @@
invisible="not is_contract"
/>
<group invisible="not is_contract">
<field name="recurrence_number" />
<field name="recurrence_interval" />
<field name="recurring_rule_type" />
<label for="recurrence_number" />
<div class="o_row">
<field name="recurrence_number" />
<field name="recurrence_interval" />
</div>
<label for="recurring_interval" />
<div class="o_row">
<field name="recurring_interval" />
<field name="recurring_rule_type" />
</div>
</group>
<group invisible="not is_contract">
<field name="recurring_invoicing_type" />
Expand Down Expand Up @@ -116,6 +123,7 @@
/>
<field name="recurrence_number" optional="hide" />
<field name="recurrence_interval" optional="hide" />
<field name="recurring_interval" optional="hide" />
<field name="recurring_rule_type" optional="hide" />
<field name="recurring_invoicing_type" optional="hide" />
<field name="contract_start_date_method" column_invisible="1" />
Expand Down
25 changes: 20 additions & 5 deletions product_contract/wizards/product_contract_configurator_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,22 @@
</group>
<separator colspan="4" string="Recurrence Invoicing" />
<group>
<field name="recurrence_number" />
<label for="recurrence_number" />
<div class="o_row">
<field name="recurrence_number" />
<field name="recurrence_interval" />
</div>
<field name="recurring_invoicing_type" />
</group>
<group>
<label for="recurring_interval" />
<div class="o_row">
<field name="recurring_interval" />
<field name="recurring_rule_type" />
</div>
<field name="contract_start_date_method" />
</group>
<group>
<field
name="date_start"
required="contract_start_date_method == 'manual'"
Expand All @@ -23,8 +37,6 @@
<field name="is_auto_renew" invisible="not date_end" />
</group>
<group>
<field name="recurrence_interval" />
<field name="recurring_rule_type" />
<field
name="date_end"
invisible="contract_start_date_method != 'manual'"
Expand All @@ -50,9 +62,12 @@
required="is_auto_renew"
/>
</div>
<field name="recurring_invoicing_type" />
</group>
<separator colspan="4" string="Contract" />
<separator
colspan="4"
string="Contract"
name="contract_separator"
/>
<group colspan="2">
<field
name="contract_id"
Expand Down

0 comments on commit 118a3f9

Please sign in to comment.