Skip to content

Conversation

@yankinmax
Copy link

No description provided.

duongtq and others added 10 commits December 8, 2025 16:17
Currently translated at 100.0% (21 of 21 strings)

Translation: product-pack-16.0/product-pack-16.0-purchase_product_pack
Translate-URL: https://translation.odoo-community.org/projects/product-pack-16-0/product-pack-16-0-purchase_product_pack/it/
Currently translated at 100.0% (21 of 21 strings)

Translation: product-pack-16.0/product-pack-16.0-purchase_product_pack
Translate-URL: https://translation.odoo-community.org/projects/product-pack-16-0/product-pack-16-0-purchase_product_pack/pt/
Currently translated at 100.0% (21 of 21 strings)

Translation: product-pack-16.0/product-pack-16.0-purchase_product_pack
Translate-URL: https://translation.odoo-community.org/projects/product-pack-16-0/product-pack-16-0-purchase_product_pack/it/
…mplification

Demo data can make tests to fail in integration environments or locally
modified ones, so let's remove them and use data created on the test
itself.

We also improve the containerization of the elements of the tests.

In the same movement, we have simplified the code of the test for doing
the same with less lines and in a clearer way.
@yankinmax yankinmax mentioned this pull request Dec 8, 2025
6 tasks
"product_qty": quantity,
}
pol = line.new(line_vals)
pol.onchange_product_id_warning()
Copy link
Author

Choose a reason for hiding this comment

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

purchase_line_warn_msg is now a computed see _compute_purchase_line_warn_msg

@yankinmax yankinmax force-pushed the 19.0-mig-purchase_product_pack branch 3 times, most recently from 7908518 to 0ddbeb1 Compare December 8, 2025 16:37
Comment on lines 64 to 68
existing_subline = first(
self.pack_child_line_ids.filtered(
lambda child, subline=subline: child.product_id
== subline.product_id
)
Copy link
Author

Choose a reason for hiding this comment

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

fields.first is deprecated since 19.0

Choose a reason for hiding this comment

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

A simple (and better) replacement for fields.first is simply:

records.filtered(...)[:1]

just a one-liner
no need to do next/iter etc..

self.env["purchase.order.line"]
.search(
[("id", "child_of", to_delete_ids), ("id", "not in", to_delete_ids)]
Domain("id", "child_of", to_delete_ids), ("id", "not in", to_delete_ids)

Choose a reason for hiding this comment

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

This is not correct. You're building a tuple here instead of a properly initialized domain

Given this is not caught by the current unit tests, can you also add one for this? (or extend an existing one)

Comment on lines 64 to 68
existing_subline = first(
self.pack_child_line_ids.filtered(
lambda child, subline=subline: child.product_id
== subline.product_id
)

Choose a reason for hiding this comment

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

A simple (and better) replacement for fields.first is simply:

records.filtered(...)[:1]

just a one-liner
no need to do next/iter etc..

self.env["purchase.order.line"]
.search(
[("id", "child_of", to_delete_ids), ("id", "not in", to_delete_ids)]
Domain("id", "child_of", to_delete_ids), ("id", "not in", to_delete_ids)
Copy link

Choose a reason for hiding this comment

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

Nice catch Ivan 🐐. If I'm not wrong, this is one possible implementation:

Suggested change
Domain("id", "child_of", to_delete_ids), ("id", "not in", to_delete_ids)
Domain("id", "child_of", to_delete_ids) & Domain("id", "not in", to_delete_ids)

Alternatively:

Suggested change
Domain("id", "child_of", to_delete_ids), ("id", "not in", to_delete_ids)
Domain.AND(Domain("id", "child_of", to_delete_ids), Domain("id", "not in", to_delete_ids))

@yankinmax yankinmax force-pushed the 19.0-mig-purchase_product_pack branch from 0ddbeb1 to 07d2f6b Compare January 19, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants