Skip to content

Commit

Permalink
[FIX] stock: allow to use already defined SN
Browse files Browse the repository at this point in the history
- Define a [DEMO] prod with tracking by SN and add some SNs
- Activate "use existing lot/serial number" on the receipt picking type
- Create a purchase order for [DEMO]
- Process the receipt in the barcode app:
  * Scan the product
  * Scan the SN barcode
  * Validate

User will get an error.
It seems that Odoo is trying to create this SN instead of
matching the existing one

opw-2474347

closes odoo#70097

Related: odoo/enterprise#18277
Signed-off-by: Rémy Voet <[email protected]>
  • Loading branch information
agr-odoo committed May 20, 2021
1 parent debab40 commit 09a1252
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions addons/stock/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,17 +448,14 @@ def _action_done(self):
# If a picking type is linked, we may have to create a production lot on
# the fly before assigning it to the move line if the user checked both
# `use_create_lots` and `use_existing_lots`.
if ml.lot_name:
if ml.product_id.tracking == 'lot' and not ml.lot_id:
lot = self.env['stock.production.lot'].search([
('company_id', '=', ml.company_id.id),
('product_id', '=', ml.product_id.id),
('name', '=', ml.lot_name),
], limit=1)
if lot:
ml.lot_id = lot.id
else:
ml_ids_to_create_lot.add(ml.id)
if ml.lot_name and not ml.lot_id:
lot = self.env['stock.production.lot'].search([
('company_id', '=', ml.company_id.id),
('product_id', '=', ml.product_id.id),
('name', '=', ml.lot_name),
], limit=1)
if lot:
ml.lot_id = lot.id
else:
ml_ids_to_create_lot.add(ml.id)
elif not picking_type_id.use_create_lots and not picking_type_id.use_existing_lots:
Expand Down

0 comments on commit 09a1252

Please sign in to comment.