Skip to content

[19.0][MIG] sale_order_line_position: Migration to 19.0#348

Open
NICO-SOLUTIONS wants to merge 30 commits intoOCA:19.0from
NICO-SOLUTIONS:19.0-mig-sale_order_line_position
Open

[19.0][MIG] sale_order_line_position: Migration to 19.0#348
NICO-SOLUTIONS wants to merge 30 commits intoOCA:19.0from
NICO-SOLUTIONS:19.0-mig-sale_order_line_position

Conversation

@NICO-SOLUTIONS
Copy link
Copy Markdown
Member

standard migration

TDu and others added 30 commits December 18, 2025 13:59
This module adds an auto computed position on sale order line.
This position number is added on the report.

The position can be used to keep track of each line during
the delivery, invoicing of the order with the customer.
This is why there is related modules on `account-invoice-reporting`
and `stock-logisics-reporting`.

The position set on a line is not changed when the order is not in
draft anymore.
The previous implementation with the onchange was broken and hardly
feasible (onchange are called on each line and the sequence set on them
changes on each call) and not possible to cover with unit
tests (reproduce the drag and drop).

The other solution could have been to replace the onchange with a
recompute of the position on every `write` of a sale.order but that
also leads to a complex solution.

As the positions are needed to discuss with the customer, the recompute of the
position on print, send and confirm is a good enough, simple solution.
Currently translated at 81.8% (9 of 11 strings)

Translation: sale-reporting-14.0/sale-reporting-14.0-sale_order_line_position
Translate-URL: https://translation.odoo-community.org/projects/sale-reporting-14-0/sale-reporting-14-0-sale_order_line_position/de/
Currently translated at 100.0% (8 of 8 strings)

Translation: sale-reporting-15.0/sale-reporting-15.0-sale_order_line_position
Translate-URL: https://translation.odoo-community.org/projects/sale-reporting-15-0/sale-reporting-15-0-sale_order_line_position/ca/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: sale-reporting-15.0/sale-reporting-15.0-sale_order_line_position
Translate-URL: https://translation.odoo-community.org/projects/sale-reporting-15-0/sale-reporting-15-0-sale_order_line_position/
Currently translated at 100.0% (13 of 13 strings)

Translation: sale-reporting-17.0/sale-reporting-17.0-sale_order_line_position
Translate-URL: https://translation.odoo-community.org/projects/sale-reporting-17-0/sale-reporting-17-0-sale_order_line_position/it/
[UPD] Update sale_order_line_position.pot

[BOT] post-merge updates
The position field is not required, so technically it could exists a
sale order line row with a NULL position value.

In that case the computation of the next position number will fail with

    unsupported operand type(s) for +: 'NoneType' and 'int'

This change makes sure to not have a crash in such case.

[BOT] post-merge updates
make tests independent and stable
- Remove demo data dependencies
- Generate sale.order per test to isolate state changes
@NICO-SOLUTIONS NICO-SOLUTIONS marked this pull request as ready for review December 18, 2025 14:34
@NICO-SOLUTIONS NICO-SOLUTIONS mentioned this pull request Dec 18, 2025
11 tasks
@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@BhaveshHeliconia
Copy link
Copy Markdown
Contributor

I noticed we are instantiating res.partner and product.product in setUpClass, but putting sale.order inside setUp(). Is there a specific reason we have them separated?

@NICO-SOLUTIONS
Copy link
Copy Markdown
Member Author

@BhaveshHeliconia

I split it intentionally:

res.partner and product.product are created in setUpClass because they’re static test data and not modified.

sale.order is created in setUp since each test changes it (e.g. unlinking lines, changing state, etc.), so i wanted a fresh instance per test to keep them isolated and independent, while avoiding unnecessary re-creation of shared data.

@BhaveshHeliconia
Copy link
Copy Markdown
Contributor

Makes sense, thanks for the clarification 👍

Copy link
Copy Markdown
Contributor

@BhaveshHeliconia BhaveshHeliconia 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 LGTM!

@NICO-SOLUTIONS
Copy link
Copy Markdown
Member Author

@rafaelbn
Can we merge this one?

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.