Skip to content

[FIX] sale_loyalty: prevent tax splitting on discount line#265606

Closed
fw-bot wants to merge 1 commit into
odoo:saas-18.3from
odoo-dev:saas-18.3-18.0-opw-6145674-wrong-tax-behaviour-krip-527859-fw
Closed

[FIX] sale_loyalty: prevent tax splitting on discount line#265606
fw-bot wants to merge 1 commit into
odoo:saas-18.3from
odoo-dev:saas-18.3-18.0-opw-6145674-wrong-tax-behaviour-krip-527859-fw

Conversation

@fw-bot
Copy link
Copy Markdown
Contributor

@fw-bot fw-bot commented May 20, 2026

Steps to produce:

  • Install website_sale, l10n_ca & accountant modules with demo data.
  • Switch to a Canadian (CA) company.
  • Go to Settings and enable Discounts, Loyalty & Gift Cards.
  • Go to Website > eCommerce > Loyalty > Discount & Loyalty.
  • Create a new program > Set Program Type to Discount Code > Under Conditional Rules, set Minimum Purchase to 0 > Under Rewards, choose Discount on Order.
  • Go to website > configuration > websites > Create a new website for the CA company > Set it as default (first in sequence).
  • Create new product > Set Sales Taxes to 14.975% GST + QST > Publish the product.
  • Open the website in an incognito window > Add the product to the cart > Apply the discount code.
  • In the main tab > Go to Website > eCommerce > Orders > Open the corresponding order > In the Other Info tab, change the fiscal position to Quebec (QC) > Click to update taxes.

Issue:

  • The tax on the discount line is split into: 14.975% GST + QST & 9.975% QST.

Root cause:

  • When a discount is applied in the cart, the discount line initially carries split taxes: 5% GST and 9.975% QST.
  • After changing the fiscal position to Quebec (QC), the system replaces 5% GST with 14.975% GST + QST because 5% GST is present in replace of 14.975% GST. so at [1] it replaces 5% GST with 14.975% GST and do nothing for 9.975% QST.
  • In 17.0, the discount line directly uses 14.975% GST + QST (no tax splitting), so this issue does not occur.
  • In 18.0, at [2], taxes are explicitly split and added to the base line, and the same split taxes are reused during grouping. This leads to multiple taxes being displayed on the sale order line.

Fix:

  • Avoid splitting taxes on the discount line in the sale order.
  • Keep the original tax structure intact to prevent duplication after fiscal position changes.

[1]

def map_tax(self, taxes):
return self.env['account.tax'].browse(unique(
tax_id
for tax in taxes
for tax_id in (self.tax_map or {}).get(tax.id, [tax.id])
))

[2]
taxes = base_line['tax_ids'].flatten_taxes_hierarchy()

opw-6145674

I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #265233
Forward-Port-Of: #262147

Steps to produce:
- Install `website_sale`, `l10n_ca` & `accountant` modules with demo data.
- Switch to a Canadian (CA) company.
- Go to Settings and enable Discounts, Loyalty & Gift Cards.
- Go to Website > eCommerce > Loyalty > Discount & Loyalty.
- Create a new program > Set Program Type to Discount Code > Under Conditional
  Rules, set Minimum Purchase to 0 > Under Rewards, choose Discount on Order.
- Go to `website > configuration > websites` > Create a new website for the CA
  company > Set it as default (first in sequence).
- Create new product > Set Sales Taxes to 14.975% GST + QST > Publish
  the product.
- Open the website in an incognito window > Add the product to the cart > Apply
  the discount code.
- In the main tab > Go to Website > eCommerce > Orders > Open the corresponding
  order > In the Other Info tab, change the fiscal position to Quebec (QC) >
  Click to update taxes.

Issue:
- The tax on the discount line is split into: 14.975% GST + QST & 9.975% QST.

Root cause:
- When a discount is applied in the cart, the discount line initially carries
  split taxes: 5% GST and 9.975% QST.
- After changing the fiscal position to Quebec (QC), the system replaces
  5% GST with 14.975% GST + QST because 5% GST is present in replace
  of 14.975% GST. so at [1] it replaces 5% GST with 14.975% GST and do nothing
  for 9.975% QST.
- In 17.0, the discount line directly uses 14.975% GST + QST (no tax
  splitting), so this issue does not occur.
- In 18.0, at [2], taxes are explicitly split and added to the base line, and
  the same split taxes are reused during grouping. This leads to multiple
  taxes being displayed on the sale order line.

Fix:
- Avoid splitting taxes on the discount line in the sale order.
- Keep the original tax structure intact to prevent duplication after fiscal
  position changes.

[1]: https://github.com/odoo/odoo/blob/c6d9fa5873eb759846e9be5b66eedb8b00c5ac11/addons/account/models/partner.py#L151-L156
[2]: https://github.com/odoo/odoo/blob/c6d9fa5873eb759846e9be5b66eedb8b00c5ac11/addons/sale_loyalty/models/sale_order.py#L296

opw-6145674

X-original-commit: bdeade7
@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented May 20, 2026

Pull request status dashboard

@fw-bot
Copy link
Copy Markdown
Contributor Author

fw-bot commented May 20, 2026

This PR targets saas-18.3 and is part of the forward-port chain. Further PRs will be created up to master.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@robodoo robodoo added the forwardport This PR was created by @fw-bot label May 20, 2026
@fw-bot
Copy link
Copy Markdown
Contributor Author

fw-bot commented May 20, 2026

@krip-odoo ci/runbot failed on this forward-port PR

robodoo pushed a commit that referenced this pull request May 22, 2026
Steps to produce:
- Install `website_sale`, `l10n_ca` & `accountant` modules with demo data.
- Switch to a Canadian (CA) company.
- Go to Settings and enable Discounts, Loyalty & Gift Cards.
- Go to Website > eCommerce > Loyalty > Discount & Loyalty.
- Create a new program > Set Program Type to Discount Code > Under Conditional
  Rules, set Minimum Purchase to 0 > Under Rewards, choose Discount on Order.
- Go to `website > configuration > websites` > Create a new website for the CA
  company > Set it as default (first in sequence).
- Create new product > Set Sales Taxes to 14.975% GST + QST > Publish
  the product.
- Open the website in an incognito window > Add the product to the cart > Apply
  the discount code.
- In the main tab > Go to Website > eCommerce > Orders > Open the corresponding
  order > In the Other Info tab, change the fiscal position to Quebec (QC) >
  Click to update taxes.

Issue:
- The tax on the discount line is split into: 14.975% GST + QST & 9.975% QST.

Root cause:
- When a discount is applied in the cart, the discount line initially carries
  split taxes: 5% GST and 9.975% QST.
- After changing the fiscal position to Quebec (QC), the system replaces
  5% GST with 14.975% GST + QST because 5% GST is present in replace
  of 14.975% GST. so at [1] it replaces 5% GST with 14.975% GST and do nothing
  for 9.975% QST.
- In 17.0, the discount line directly uses 14.975% GST + QST (no tax
  splitting), so this issue does not occur.
- In 18.0, at [2], taxes are explicitly split and added to the base line, and
  the same split taxes are reused during grouping. This leads to multiple
  taxes being displayed on the sale order line.

Fix:
- Avoid splitting taxes on the discount line in the sale order.
- Keep the original tax structure intact to prevent duplication after fiscal
  position changes.

[1]: https://github.com/odoo/odoo/blob/c6d9fa5873eb759846e9be5b66eedb8b00c5ac11/addons/account/models/partner.py#L151-L156
[2]: https://github.com/odoo/odoo/blob/c6d9fa5873eb759846e9be5b66eedb8b00c5ac11/addons/sale_loyalty/models/sale_order.py#L296

opw-6145674

closes #265606

X-original-commit: bdeade7
Signed-off-by: Krishna Arvindkumar Patel (krip) <krip@odoo.com>
@robodoo robodoo closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

forwardport This PR was created by @fw-bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants