-
-
Notifications
You must be signed in to change notification settings - Fork 326
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
[MIG] product_multi_barcode: Migration to 16.0 #471
[MIG] product_multi_barcode: Migration to 16.0 #471
Conversation
a56fe4a
to
c4e15ad
Compare
@StefanRijnhart Still draft ? |
/ocabot migration product_multi_barcode |
@rousseldenis |
c4e15ad
to
6e67e60
Compare
Pre-commit fixed here: #491 |
6e67e60
to
f619864
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.
Code review. Some performance improvements can be done.
[("id", "!=", record.id), ("name", "=", record.name)] | ||
) | ||
if barcodes: | ||
raise UserError( |
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.
You should use ValidationError in constraints
def _inverse_barcode(self): | ||
for product in self: | ||
if product.barcode_ids: | ||
product.barcode_ids[:1].write({"name": product.barcode}) |
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.
I think write() is not correct in an inverse method. You should assign value instead.
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.
I changed this, although I think write is fine in principle. The same method also uses create and unlink. But assigning a single attribute is more odoo-esque of course.
elif not product.barcode: | ||
product.barcode_ids.unlink() | ||
else: | ||
self.env["product.barcode"].create(self._prepare_barcode_vals()) |
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.
Gather barcode vals in a list, then use multi create.
if product.barcode_ids: | ||
product.barcode_ids[:1].write({"name": product.barcode}) | ||
elif not product.barcode: | ||
product.barcode_ids.unlink() |
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.
Gather barcode ids in a set(), then barcode_model.browse(ids).unlink()
|
||
@tagged("post_install", "-at_install") | ||
class TestProductMultiBarcode(TransactionCase): | ||
def setUp(self): |
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.
Could you change this to classmethod ?
@api.constrains("name") | ||
def _check_duplicates(self): | ||
for record in self: | ||
barcodes = self.search( |
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.
should use search_count
?
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.
Actually, the found duplicate is used to present a detailed error message to the user so I've kept search
.
elif not product.barcode: | ||
product.barcode_ids.unlink() | ||
else: | ||
self.env["product.barcode"].create(self._prepare_barcode_vals()) |
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.
should be product._prepare_barcode_vals()
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.
Review comments and cover all cases in tests.
Hello @rousseldenis , I have seen that @aliciagaarzo has made the changes you requested, how do you see them? I think the development is correct, can we help to merge the code? Thank you very much, have a nice day. |
I've made a functional review and LGTM. Friendly ping to @rousseldenis @StefanRijnhart @hieulucky111 |
@StefanRijnhart Could you attend comments ? |
Co-authored-by: Sébastien Beau <sebastien.beau@akretion.com>
Currently translated at 100.0% (17 of 17 strings) Translation: stock-logistics-barcode-14.0/stock-logistics-barcode-14.0-product_multi_barcode Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-barcode-14-0/stock-logistics-barcode-14-0-product_multi_barcode/it/
…form to see barcodes.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: stock-logistics-barcode-14.0/stock-logistics-barcode-14.0-product_multi_barcode Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-barcode-14-0/stock-logistics-barcode-14-0-product_multi_barcode/
f619864
to
594d303
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.
Code review
Thanks for the reviews. Fixes are now applied. I also included #501 |
@StefanRijnhart See my comment #501 (review) |
@rousseldenis do you still have any remaining concerns, or are we ready for merge? |
/ocabot merge nobump |
This PR looks fantastic, let's merge it! |
Congratulations, your PR was merged at 0346ada. Thanks a lot for contributing to OCA. ❤️ |
From unmerged #434
This PR uncovers a problem with
odoo-test-helper
used inbarcodes_generator_abstract
's tests. This should be fixed in OCA/odoo-test-helper#22.