-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
[13.0][FIX] stock_picking_import_serial_number: Lot overwriting #1062
Conversation
The import wizard presents an option to "Overwrite Serial", which should take all serials from the XLSX, and unconditionally write them into existing SMLs. However, the condition was not well formed, and so each XLSX line would write to the same SML - effectively only importing the *last* XLSX line into only the *first* SML.
Hi @sergio-teruel, |
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.
For being more efficient
@@ -78,16 +78,20 @@ def _import_serial_number(self, xl_sheet, stock_move_lines, picking): | |||
products = self.env["product.product"].search( | |||
[(self.sn_search_product_by_field, "in", list(product_file_set))] | |||
) | |||
sml_done = self.env["stock.move.line"] |
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.
sml_done = self.env["stock.move.line"] | |
sml_done = set() |
for item in serial_list: | ||
product = products.filtered( | ||
lambda p: p[self.sn_search_product_by_field] == item[0] | ||
) | ||
if picking.picking_type_id.show_reserved: | ||
smls = stock_move_lines.filtered(lambda ln: ln.product_id == product) | ||
for sml in smls: | ||
if not sml.lot_name or self.overwrite_serial: | ||
lot_ok = not sml.lot_name | ||
overwrite_ok = self.overwrite_serial and sml not in sml_done |
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.
overwrite_ok = self.overwrite_serial and sml not in sml_done | |
overwrite_ok = self.overwrite_serial and sml.id not in sml_done |
sml.lot_name = item[1] | ||
sml.qty_done = 1.0 | ||
sml_done += sml |
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.
sml_done += sml | |
sml_done.add(sml.id) |
@ryanc-me Thanks...I will correct it in the next commit that will also allow selecting serial numbers in internal and ougoing operations. I will ping you to review |
@ryanc-me @sergio-teruel What's the status of this ? |
@rousseldenis the author's PR #1065 supersedes this one |
Superseded by #1065 |
The import wizard presents an option to "Overwrite Serial", which should
take all serials from the XLSX, and unconditionally write them into existing
SMLs.
However, the condition was not well formed, and so each XLSX line would
write to the same SML - effectively only importing the last XLSX line
into only the first SML.