Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

ryanc-me
Copy link
Contributor

@ryanc-me ryanc-me commented Aug 9, 2022

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.

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.
@OCA-git-bot
Copy link
Contributor

Hi @sergio-teruel,
some modules you are maintaining are being modified, check this out!

@ryanc-me ryanc-me changed the title [FIX] stock_picking_import_serial_number: Lot overwriting [13.0][FIX] stock_picking_import_serial_number: Lot overwriting Aug 9, 2022
@ryanc-me ryanc-me marked this pull request as ready for review August 9, 2022 23:11
@pedrobaeza pedrobaeza added this to the 13.0 milestone Aug 10, 2022
Copy link
Member

@pedrobaeza pedrobaeza left a 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"]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sml_done += sml
sml_done.add(sml.id)

@sergio-teruel
Copy link
Contributor

@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

@rousseldenis
Copy link
Contributor

@ryanc-me @sergio-teruel What's the status of this ?

@ryanc-me
Copy link
Contributor Author

@rousseldenis the author's PR #1065 supersedes this one

@pedrobaeza
Copy link
Member

Superseded by #1065

@pedrobaeza pedrobaeza closed this Dec 20, 2022
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.

5 participants