Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@qgroulard
Copy link
Contributor

@qgroulard qgroulard commented Aug 25, 2025

This module extends the functionality of product_contract to add an option to compute
the total amounts on "contract" Sale Order lines, including every invoicing planned.

For instance, a product worth 10€ invoiced every month for one year would have a total
of 120€ (unit_price * #invoices) instead of 10€ (unit_price * quantity).

@OCA-git-bot
Copy link
Contributor

Hi @sbejaoui,
some modules you are maintaining are being modified, check this out!

@qgroulard qgroulard force-pushed the 18.0-product_contract_so_line_amounts-qgr branch from b92e159 to 2384f96 Compare August 25, 2025 13:57
@qgroulard qgroulard force-pushed the 18.0-product_contract_so_line_amounts-qgr branch from 2384f96 to 0710477 Compare August 26, 2025 16:20
@qgroulard
Copy link
Contributor Author

I have pushed a new version.
The first approach was a bit naive, it was based on the field recurrence_number, which is not the actual number of times the line will be invoiced.
Thus, I add a new field recurring_invoicing_number for this.

@pedrobaeza pedrobaeza added this to the 18.0 milestone Aug 26, 2025
@pedrobaeza
Copy link
Member

But why do you need an extra multiplier and the quantity is not enough?

@qgroulard
Copy link
Contributor Author

But why do you need an extra multiplier and the quantity is not enough?

Let's say you sell a subscription over 3 years, invoiced every quarter with a unit price of 100€.

Prior to f50e15d, you would have:

  • price_unit = 100.0
  • product_uom_qty = 12 (there are 12 quarters in 3 years)

Thus the subtotal of the line would be 1200€ (price_unit * product_uom_qty).
It makes sense, in total the customer will have to pay 1200€ for this subscription.

After f50e15d, you would have:

  • price_unit = 100.0
  • product_uom_qty = 1
  • recurring_interval = 1
  • recurring_rule_type = "quarterly"

Without this PR, the subtotal of the line would be 100€ (price_unit * product_uom_qty), which is wrong.
With this PR, we have:

  • recurring_invoicing_number = 12 (there are 12 quarters in 3 years) / 1 (recurring_interval)

And the subtotal of the line would be 1200€: 100 (price_unit) * 12 (recurring_invoicing_number) * 1 (product_uom_qty)

@pedrobaeza
Copy link
Member

The original intention of the system is that you put on the sale.order.line the "setup" price, and then, when confirmed, the contract is created for the recurring "maintenance" price. What you are telling is that you put in the quotation the full price of the whole "maintenance" price period. That use case sounds very weird, and I think it's over-complicating this module, so it should be handled on extra modules on top.

@qgroulard qgroulard force-pushed the 18.0-product_contract_so_line_amounts-qgr branch from 0710477 to 511ea0e Compare August 27, 2025 14:06
@qgroulard qgroulard changed the title [18.0] [IMP] product_contract: consider recurrence in SO lines amounts [18.0] [ADD] product_contract_recurrence_in_price Aug 27, 2025
@qgroulard
Copy link
Contributor Author

The original intention of the system is that you put on the sale.order.line the "setup" price, and then, when confirmed, the contract is created for the recurring "maintenance" price. What you are telling is that you put in the quotation the full price of the whole "maintenance" price period. That use case sounds very weird, and I think it's over-complicating this module, so it should be handled on extra modules on top.

The use case is the sale of subscriptions.
Recurrences are not maintenance cost, this is a service that the customer pays every month for X years.

I understand that this module can solve different use cases, therefore I have added this as a new option in a new module.

@qgroulard qgroulard force-pushed the 18.0-product_contract_so_line_amounts-qgr branch from 511ea0e to 336ec49 Compare August 28, 2025 13:40
Comment on lines 32 to 35
if rec.product_id.is_contract:
rec.include_recurrence_in_price = (
rec.product_id.include_recurrence_in_price
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You aren't setting your field in every cases

Suggested change
if rec.product_id.is_contract:
rec.include_recurrence_in_price = (
rec.product_id.include_recurrence_in_price
)
rec.include_recurrence_in_price = rec.product_id.is_contract and (
rec.product_id.include_recurrence_in_price
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

Add an option to include the recurrences in the total of a Sale Order Line
@qgroulard qgroulard force-pushed the 18.0-product_contract_so_line_amounts-qgr branch from 336ec49 to 71b7f6a Compare September 23, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants