Skip to content

[19.0][BUG] sale_fixed_discount: portal template typo line.fixed_discount + 17.0 fix from #3945 not ported #4172

@bpcreate

Description

@bpcreate

Module

sale_fixed_discount

Affected version

19.0

Describe the bug

Two issues in sale_fixed_discount/views/sale_portal_templates.xml on the 19.0 branch:

1. Typo: line.fixed_discount should be line.discount_fixed

Line 30 of the portal template references a non-existent field name:

<attribute name="t-if">line.discount &gt;= 0 or line.fixed_discount &gt;= 0</attribute>

The field defined in models/sale_order_line.py is discount_fixed, not fixed_discount. Every other reference in the same file uses the correct name, there are 8 correct uses of discount_fixed and this single typo:

Line Value Correct?
13 line.discount_fixed
30 line.fixed_discount ❌ typo
33 line.discount_fixed
36 line.discount_fixed
39 line.discount_fixed
46 line.discount_fixed
47 line.discount_fixed

Fix:

<attribute name="t-if">line.discount &gt;= 0 or line.discount_fixed &gt;= 0</attribute>

Note: The typo is currently latent (does not cause a visible crash) because line.discount >= 0 evaluates to True for any standard discount value, short-circuiting the or. However it is still incorrect and would become a real bug if the condition logic were tightened (e.g. > 0).


2. Fix from 17.0 PR #3945 was not ported to 19.0

PR #3945 (open, targeting 17.0) fixes the portal not displaying the discounted unit price when a fixed discount is applied, the same symptom reported in issues #3768 and #3769. That fix was not included in the 19.0 migration (PR #4031), so the 19.0 branch still has the broken display behaviour.

The fix in #3945 replaces:

<xpath expr="//div[@t-if='line.discount']/t" position="attributes">
    <attribute name="t-out">line.price_unit - line.discount_fixed</attribute>
</xpath>

with a proper t-elif sibling element so the discounted price renders when a fixed discount is set:

<xpath expr="//div[@t-if='line.discount']" position="after">
    <div t-elif="line.discount_fixed">
        <t
            t-out="line.price_unit - line.discount_fixed"
            t-options='{"widget": "float", "decimal_precision": "Product Price"}'
        />
    </div>
</xpath>

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions