-
-
Notifications
You must be signed in to change notification settings - Fork 143
[19.0][MIG] purchase_product_pack: Migration to 19.0 #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 19.0
Are you sure you want to change the base?
Conversation
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.
| "product_qty": quantity, | ||
| } | ||
| pol = line.new(line_vals) | ||
| pol.onchange_product_id_warning() |
There was a problem hiding this comment.
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
7908518 to
0ddbeb1
Compare
| existing_subline = first( | ||
| self.pack_child_line_ids.filtered( | ||
| lambda child, subline=subline: child.product_id | ||
| == subline.product_id | ||
| ) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)
| existing_subline = first( | ||
| self.pack_child_line_ids.filtered( | ||
| lambda child, subline=subline: child.product_id | ||
| == subline.product_id | ||
| ) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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:
| 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:
| 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)) |
0ddbeb1 to
07d2f6b
Compare
No description provided.