Skip to content

[19.0][MIG] sale_order_lot_selection: Migration to 19.0#3985

Open
lef-adhoc wants to merge 88 commits intoOCA:19.0from
adhoc-dev:19.0-mig-sale_order_lot_selection
Open

[19.0][MIG] sale_order_lot_selection: Migration to 19.0#3985
lef-adhoc wants to merge 88 commits intoOCA:19.0from
adhoc-dev:19.0-mig-sale_order_lot_selection

Conversation

@lef-adhoc
Copy link
Copy Markdown
Contributor

hurrinico and others added 30 commits November 3, 2025 17:38
[FIX] Fix product_id on test

[FIX] Fix product on test
[FIX] Use product_14 instead of product_11

[FIX] Add test's flow step
[FIX] change data in quant search

[FIX] Fixed tab

[FIX] Add check on lots list

FIX product_id_change_with_wh
Because quants_get_prefered_domain does not return quants with our lots, if other quants are available
Steps to reproduce:

1.- Create a new Sale Order with 2 or more lines of products
2.- Assign lot to every line (ensure lot has stock available)
3.- Confirm the Sale Order
4.- Go to the Delivery Order

Result:

Only the first line in the Delivery Order is in state "Available" and reserved, the rest of the lines are in state "Waiting Availability" and not reserved
rousseldenis and others added 11 commits November 3, 2025 17:38
…ects

If we use the lot_id field to add it as a dependency of the _compute_price_unit method,
we may encounter side effects, and indirectly we will need the field to be defined as
precompute=True to avoid them.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: sale-workflow-18.0/sale-workflow-18.0-sale_order_lot_selection
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_order_lot_selection/
Currently translated at 100.0% (3 of 3 strings)

Translation: sale-workflow-18.0/sale-workflow-18.0-sale_order_lot_selection
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_order_lot_selection/it/
@lef-adhoc lef-adhoc force-pushed the 19.0-mig-sale_order_lot_selection branch from 2924a0a to 635139f Compare November 3, 2025 20:55
Copy link
Copy Markdown

@manuelcalerosolis manuelcalerosolis left a comment

Choose a reason for hiding this comment

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

Functional review ok!

@victoralmau
Copy link
Copy Markdown
Member

Please, cherry-pick #4011 to commit history before migration commit.

Copy link
Copy Markdown

@alexey-pelykh alexey-pelykh left a comment

Choose a reason for hiding this comment

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

Solid migration overall. The core lot selection logic, procurement integration, and view xpaths are correct for 19.0. A few observations:

Functional scope change -- The 16.0 version had allow_to_change_lot_on_confirmed_so (company setting + config view + write() override + lot_id_readonly computed field). All of this is dropped in the migration. If this is intentional simplification, it would be worth mentioning in the PR description or a migration note, since users upgrading from 16.0 will lose that capability.

Minor code observations:

  1. _compute_product_tracking -- The fallback sol.product_id.tracking or sol.product_tracking works correctly for the visibility use-case but could be simplified to just sol.product_id.tracking since the compute fires on product_id change and the only consumer is the invisible expression. The or sol.product_tracking branch only preserves a stale value when product_id is cleared, which has no practical benefit since the field is hidden when not product_id anyway.

  2. In the test test_02_sale_order_lot_selection, self.product_46.write({"tracking": "lot", "type": "consu"}) -- the "type": "consu" is a no-op in 19.0 since these products are already consu (created with is_storable=True). Not a bug, but dead code carried forward from older versions.

  3. The product_tracking field is used in the view invisible expression but not declared in the view XML. Odoo 17+ auto-fetches fields in expressions, so this works, but adding <field name="product_tracking" column_invisible="True"/> would make the dependency explicit.

CI: "Detect unreleased dependencies" failure is expected due to the pending stock_restrict_lot migration (OCA/stock-logistics-workflow#2151).

Tests pass on both Odoo and OCB.

@api.depends("product_id")
def _compute_product_tracking(self):
for sol in self:
sol.product_tracking = sol.product_id.tracking or sol.product_tracking
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: the or sol.product_tracking fallback is only reached when product_id is empty (since 'none' is truthy). In that case the view already hides the lot field via invisible="not product_id ...", so the preserved stale value has no visible effect. Could simplify to just:

sol.product_tracking = sol.product_id.tracking

Not blocking, just a readability point.

if move.product_id == self.prd_cable:
lot10 = self.lot_model.create(
{
"name": "0000010",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor: "type": "consu" is redundant in 19.0 -- products created with is_storable=True already have type='consu'. This write effectively only sets tracking. Consider removing the type key to avoid confusion during future migrations.

context="{'default_product_id': product_id}"
groups="stock.group_production_lot"
optional="show"
/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider adding <field name="product_tracking" column_invisible="True"/> explicitly in the list view. While Odoo 17+ auto-fetches fields used in invisible expressions, declaring it makes the dependency clear and avoids surprises if that auto-fetch behavior ever changes.

Copy link
Copy Markdown

@odooNextev odooNextev left a comment

Choose a reason for hiding this comment

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

tested locally, it works. lgtm

Copy link
Copy Markdown
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

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

My comment #3985 (comment) is still pending.

victoralmau and others added 2 commits March 11, 2026 14:27
…ock moves

Example use case:
- Product with Lot A and Lot B.
- SO with Lot A linked.
- The SO is confirmed and the OUT is generated with Lot A linked in the stock move
- The SO is modified to define Lot B.
- The OUT stock move is changed to Lot B.

TT57112
@lef-adhoc lef-adhoc force-pushed the 19.0-mig-sale_order_lot_selection branch 2 times, most recently from 9ea84b1 to f702c4a Compare March 11, 2026 14:33
@lef-adhoc lef-adhoc force-pushed the 19.0-mig-sale_order_lot_selection branch from f702c4a to 2bd743c Compare March 11, 2026 14:38
@lef-adhoc
Copy link
Copy Markdown
Contributor Author

@victoralmau Done!

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.

Functional review LGTM!

@pedrobaeza
Copy link
Copy Markdown
Member

/ocabot migration sale_order_lot_selection

@OCA-git-bot OCA-git-bot added this to the 19.0 milestone Apr 6, 2026
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.