Skip to content

[18.0][ADD] sale_order_line_final_price: add new module#4468

Open
eduezerouali-tecnativa wants to merge 1 commit into
OCA:18.0from
Tecnativa:18.0-add-sale_order_line_final_price
Open

[18.0][ADD] sale_order_line_final_price: add new module#4468
eduezerouali-tecnativa wants to merge 1 commit into
OCA:18.0from
Tecnativa:18.0-add-sale_order_line_final_price

Conversation

@eduezerouali-tecnativa

Copy link
Copy Markdown
Contributor

@OCA-git-bot OCA-git-bot added series:18.0 mod:sale_order_line_price_lock_by_price_final Module sale_order_line_price_lock_by_price_final labels Jul 14, 2026
@eduezerouali-tecnativa
eduezerouali-tecnativa force-pushed the 18.0-add-sale_order_line_final_price branch from 65eb84f to 2512440 Compare July 14, 2026 09:13
Comment thread sale_order_line_final_price/readme/DESCRIPTION.md
@pedrobaeza pedrobaeza added this to the 18.0 milestone Jul 14, 2026
@pedrobaeza

Copy link
Copy Markdown
Member

Please simplify the name to sale_order_line_final_price, and add CONTEXT.md to explain why this is useful, for always maintaining the list price, and only touch discounts in an indirect mode.

Check also the CI.

@eduezerouali-tecnativa
eduezerouali-tecnativa force-pushed the 18.0-add-sale_order_line_final_price branch from 2512440 to 1b804e0 Compare July 14, 2026 10:15
@OCA-git-bot OCA-git-bot added mod:sale_order_line_final_price Module sale_order_line_final_price and removed mod:sale_order_line_price_lock_by_price_final Module sale_order_line_price_lock_by_price_final labels Jul 14, 2026
@eduezerouali-tecnativa
eduezerouali-tecnativa force-pushed the 18.0-add-sale_order_line_final_price branch from 1b804e0 to f2035fd Compare July 14, 2026 10:24
@eduezerouali-tecnativa

Copy link
Copy Markdown
Contributor Author

Name changed, CONTEXT.md added and took care of CI.

@rousseldenis

Copy link
Copy Markdown
Contributor

Ok, I understand the use case now. It seems to me there is already a module for that or at least a PR. I will check

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Functional review: LGTM. Just one technical comment:

Please update the PR title to reflect the new module name.

Comment on lines +34 to +38
<field
name="price_final"
readonly="qty_invoiced &gt; 0"
optional="show"
/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this feature should only be visible when the discount feature is enabled. Otherwise, users will see two similar fields, even though discounts are not displayed.

What do you think about adding the sale.group_discount_per_so_line group?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True. Done!

@juancarlosonate-tecnativa juancarlosonate-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, decimal precision behavior reviewed and working as documented, just rename the .pot file to the new module name and update the PR title accordingly.

@eduezerouali-tecnativa
eduezerouali-tecnativa force-pushed the 18.0-add-sale_order_line_final_price branch 2 times, most recently from 08c4d35 to 695abf1 Compare July 15, 2026 08:50
@eduezerouali-tecnativa eduezerouali-tecnativa changed the title [18.0][ADD] sale_order_line_price_lock_by_price_final: add new module [18.0][ADD] sale_order_line_final_price: add new module Jul 15, 2026
@eduezerouali-tecnativa

Copy link
Copy Markdown
Contributor Author

Changes done

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread sale_order_line_final_price/models/sale_order_line.py Outdated
Comment thread sale_order_line_final_price/models/sale_order_line.py Outdated
Comment thread sale_order_line_final_price/models/sale_order_line.py Outdated
@eduezerouali-tecnativa

Copy link
Copy Markdown
Contributor Author

We also added the case when price_unit is 0. As no discount will lift a 0 price, now if price_unit is 0 editable from price_final in this particular case. Also added to the test.

@eduezerouali-tecnativa
eduezerouali-tecnativa force-pushed the 18.0-add-sale_order_line_final_price branch from 6777c26 to 28310d1 Compare July 16, 2026 14:03

@pedrobaeza pedrobaeza left a comment

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.

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 18.0-ocabot-merge-pr-4468-by-pedrobaeza-bump-nobump, awaiting test results.

@pedrobaeza pedrobaeza left a comment

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.

Oh, wait, this is still doing 2 SQL operations (create and write), no matter if you do it directly or through modify. Please include everything needed in the vals dictionary for doing in one shot.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@pedrobaeza your merge command was aborted due to failed check(s), which you can inspect on this commit of 18.0-ocabot-merge-pr-4468-by-pedrobaeza-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@eduezerouali-tecnativa
eduezerouali-tecnativa force-pushed the 18.0-add-sale_order_line_final_price branch from 28310d1 to f5cd2b5 Compare July 17, 2026 13:32
@eduezerouali-tecnativa

Copy link
Copy Markdown
Contributor Author

With new approach we should avoid doing 2 SQL operations.

self.env.add_to_compute(self._fields["price_final"], self)

@api.onchange("price_final")
def _onchange_price_final(self):

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.

You should avoid onchange at all cost, because they only works on screen, but not by code. Isn't there any other option? Maybe the other formula didn't work because you didn't put force_save="1" on the view?

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