Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] sale_product_pack: adjust discount formula for detailed packs #201

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

lef-adhoc
Copy link

The discount formula for detailed packs has been updated to address inconsistencies when pricelists explicitly display discounts.

The new formula ensures accurate representation of the combined discount by correctly factoring in both the parent pack and component discounts.

Example:

Parent pack discount: 5%
Component A discount: 10%
Component B discount: 20%
The issue occurred when pricelists explicitly displayed discounts. For example, when the pricelist showed the discount percentage but did not properly calculate the combined effect of the pack discount and the component discounts, the displayed total was inconsistent.

With the new formula:

Component A effective discount:
100.0 - ((100.0 - 5.0) * (100.0 - 10.0) / 100.0) = 14.5%
Component B effective discount:
100.0 - ((100.0 - 5.0) * (100.0 - 20.0) / 100.0) = 24.0%

@OCA-git-bot
Copy link
Contributor

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

@lef-adhoc lef-adhoc force-pushed the 18.0-h-86712-lef branch 4 times, most recently from 14d15c1 to bf866f3 Compare January 28, 2025 20:08
adhoc-cicd-bot pushed a commit to adhoc-cicd/oca-product-pack that referenced this pull request Jan 30, 2025
…scount. (OCA#197)

Formerly was only taking into account the product packs discount, now take
into account both discounts.

Also we simplify the way that get_sale_order_line_vals works and now is
simplier and use Odoo's onchange methods to compute the lines values.

[FIX] product_pack: Pack component now have the tax of the company (OCA#198)

Before this fix the product's packs new sale order line have multiple taxes:
one por each company. Actually only need to add the taxes realated to the
sale order's company.

[FIX] product_pack: compute proper components prices (OCA#199)

In some cases the values were prefetched and it was throwing bad prices.
we add prefetch_fields to the context of the packs and that solve it.

[FIX/IMP] product_pack: Allow modify pack and do not reset after confirm website sale order (OCA#201)

* [FIX] product_pack: Do not reset packs components when confirm sale order.

If a sale order is updated from the website whrn confirm the order we do
not expand the pack, we usit as it is.

* [ADD] product_pack: Allow modify pack from backend/website

Now we can choose if the product can be modified in the only int he backend or
if can be modified also in the frontend by the customers.

* [FIX] lint
@lef-adhoc lef-adhoc force-pushed the 18.0-h-86712-lef branch 4 times, most recently from ead3758 to d625a76 Compare January 30, 2025 15:18
The discount formula for detailed packs has been updated to address inconsistencies when pricelists explicitly display discounts.

The new formula ensures accurate representation of the combined discount by correctly factoring in both the parent pack and component discounts.

Example:

Parent pack discount: 5%
Component A discount: 10%
Component B discount: 20%
The issue occurred when pricelists explicitly displayed discounts. For example, when the pricelist showed the discount percentage but did not properly calculate the combined effect of the pack discount and the component discounts, the displayed total was inconsistent.

With the new formula:

Component A effective discount:
100.0 - ((100.0 - 5.0) * (100.0 - 10.0) / 100.0) = 14.5%
Component B effective discount:
100.0 - ((100.0 - 5.0) * (100.0 - 20.0) / 100.0) = 24.0%
This ensures that when pricelists explicitly show discounts, the displayed percentage matches the calculated prices.
Copy link

@nicolascol nicolascol left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@matiasperalta1 matiasperalta1 left a comment

Choose a reason for hiding this comment

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

LGTM

@matiasperalta1
Copy link

@pedrobaeza Is it ready to merge?

@pedrobaeza pedrobaeza added this to the 18.0 milestone Jan 31, 2025
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

Code review.

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 18.0-ocabot-merge-pr-201-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 233c855 into OCA:18.0 Jan 31, 2025
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at d0dbb11. Thanks a lot for contributing to OCA. ❤️

celm1990 pushed a commit to Spearhead-Odoo/product-pack that referenced this pull request Feb 4, 2025
…scount. (OCA#197)

Formerly was only taking into account the product packs discount, now take
into account both discounts.

Also we simplify the way that get_sale_order_line_vals works and now is
simplier and use Odoo's onchange methods to compute the lines values.

[FIX] product_pack: Pack component now have the tax of the company (OCA#198)

Before this fix the product's packs new sale order line have multiple taxes:
one por each company. Actually only need to add the taxes realated to the
sale order's company.

[FIX] product_pack: compute proper components prices (OCA#199)

In some cases the values were prefetched and it was throwing bad prices.
we add prefetch_fields to the context of the packs and that solve it.

[FIX/IMP] product_pack: Allow modify pack and do not reset after confirm website sale order (OCA#201)

* [FIX] product_pack: Do not reset packs components when confirm sale order.

If a sale order is updated from the website whrn confirm the order we do
not expand the pack, we usit as it is.

* [ADD] product_pack: Allow modify pack from backend/website

Now we can choose if the product can be modified in the only int he backend or
if can be modified also in the frontend by the customers.

* [FIX] lint
@lef-adhoc lef-adhoc deleted the 18.0-h-86712-lef branch February 10, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants