Skip to content

[18.0][ADD] sale_multi_discount#4364

Draft
LorenzoC0 wants to merge 1 commit into
OCA:18.0from
LorenzoC0:18.0-add-sale_multi_discount
Draft

[18.0][ADD] sale_multi_discount#4364
LorenzoC0 wants to merge 1 commit into
OCA:18.0from
LorenzoC0:18.0-add-sale_multi_discount

Conversation

@LorenzoC0
Copy link
Copy Markdown

Depends on OCA/account-invoicing#2364

This module adds a distribution-like field in the sale order line discount column, enabling infinite multiplicative discounts.

This module likely conflicts with some other modules that modify the behavior of the discount field, such as sale_global_discount. I could use some help figuring out which of these modules are incompatible, so I can add them as exclusions in the manifest. Thanks!

Adds a distribution-like field in the sale order line discount column.
@OCA-git-bot OCA-git-bot added series:18.0 mod:sale_multi_discount Module sale_multi_discount labels May 26, 2026
@LorenzoC0 LorenzoC0 marked this pull request as draft May 26, 2026 11:10
back through our ``write`` override and squash a freshly-edited
multi-discount rule into a single flattened value.
"""
self._compute_discount_distribution()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not calling super?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if product_id or product_uom or product_uom_qty change, the distribution should be emptied

for vals in vals_list:
if "discount" in vals and "discount_distribution" not in vals:
discount_val = vals.pop("discount")
if discount_val:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if discount_val is 0, shouldn't we still empty discount_distribution?

],
"data": [
"views/sale_order_views.xml",
"report/sale_order_report.xml",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should probably extend sale.sale_portal_templates as well

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we can also not do it for now

<td t-if="display_discount" class="text-end text-nowrap">
<t t-if="line.discount_distribution and len(line.discount_distribution) > 1">
<t t-foreach="line.discount_distribution" t-as="d" t-key="d_index">
<span t-out="'%.2f' % d"/>%<t t-if="not d_last"> + </t>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is it possible to use formatLang?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:sale_multi_discount Module sale_multi_discount series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants