-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
[17.0][MIG] mrp_bom_tracking: Migration to 17.0 #1226
Conversation
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: manufacture-15.0/manufacture-15.0-mrp_bom_tracking Translate-URL: https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-mrp_bom_tracking/
Currently translated at 100.0% (19 of 19 strings) Translation: manufacture-15.0/manufacture-15.0-mrp_bom_tracking Translate-URL: https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-mrp_bom_tracking/it/
Currently translated at 100.0% (19 of 19 strings) Translation: manufacture-15.0/manufacture-15.0-mrp_bom_tracking Translate-URL: https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-mrp_bom_tracking/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: manufacture-16.0/manufacture-16.0-mrp_bom_tracking Translate-URL: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_tracking/
Currently translated at 100.0% (19 of 19 strings) Translation: manufacture-16.0/manufacture-16.0-mrp_bom_tracking Translate-URL: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_tracking/it/
Currently translated at 100.0% (19 of 19 strings) Translation: manufacture-16.0/manufacture-16.0-mrp_bom_tracking Translate-URL: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_tracking/es/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: manufacture-16.0/manufacture-16.0-mrp_bom_tracking Translate-URL: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_tracking/
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.
general improvements and feedback 🙂
mrp_bom_tracking/models/mrp_bom.py
Outdated
if "product_id" in values: | ||
for bom in self.mapped("bom_id"): | ||
# Bind bom variable for the current iteration to the lambda | ||
lines = self.filtered(lambda x, bom=bom: x.bom_id == bom) | ||
product_id = values.get("product_id") | ||
if product_id: | ||
product_id = self.env["product.product"].browse(product_id) | ||
product_id = product_id or lines.product_id | ||
if lines: | ||
message_body = template_env._render_template( | ||
"mrp_bom_tracking.track_bom_template_2", | ||
values={"lines": lines, "product_id": product_id}, | ||
) | ||
bom.message_post( | ||
body=message_body, subtype_id=self.env.ref("mail.mt_note").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.
if "product_id" in values: | |
for bom in self.mapped("bom_id"): | |
# Bind bom variable for the current iteration to the lambda | |
lines = self.filtered(lambda x, bom=bom: x.bom_id == bom) | |
product_id = values.get("product_id") | |
if product_id: | |
product_id = self.env["product.product"].browse(product_id) | |
product_id = product_id or lines.product_id | |
if lines: | |
message_body = template_env._render_template( | |
"mrp_bom_tracking.track_bom_template_2", | |
values={"lines": lines, "product_id": product_id}, | |
) | |
bom.message_post( | |
body=message_body, subtype_id=self.env.ref("mail.mt_note").id | |
) | |
if "product_id" in values: | |
for bom_line in self: | |
bom = bom_line.bom_id | |
product_id = values.get("product_id") | |
product = self.env["product.product"].browse(product_id) | |
if product.exists(): | |
message_body = template_env._render_template( | |
"mrp_bom_tracking.track_bom_template_2", | |
values={"lines": bom_line, "product_id": product}, | |
) | |
bom.message_post( | |
body=message_body, subtype_id=self.env.ref("mail.mt_note").id | |
) |
product_id
check was already done at the beginning of the indentation, no need to do it again. Also, refactor to iterate over self, which contains the BoM lines, as before the change, it was already doing one message posting per line change. I believe this refactoring simplifies the understanding of the logic. What do you think?
I believe this is more of a general improvement, nothing related to the migration itself.
7820a93
to
71dce9e
Compare
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.
LGTM! Thank you for the improvements 👍🏽
/ocabot migration mrp_bom_tracking |
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.
71dce9e
to
eeb307e
Compare
Done @LoisRForgeFlow! |
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.
Thanks!
/ocabot merge nobump
On my way to merge this fine PR! |
This PR has the |
Congratulations, your PR was merged at 817ade7. Thanks a lot for contributing to OCA. ❤️ |
Standard migration
@ForgeFlow