diff --git a/oxigen_stock_barcodes_gs1/README.rst b/oxigen_stock_barcodes_gs1/README.rst index 6bc63201..a645983b 100644 --- a/oxigen_stock_barcodes_gs1/README.rst +++ b/oxigen_stock_barcodes_gs1/README.rst @@ -7,7 +7,7 @@ Oxigen stock barcodes GS1 !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:18355e0b0e74e8f9587b341190e2f15a1f71d81a4811fa16e293278459f5529b + !! source digest: sha256:2580c1861591aef093578d851da478d6c965f38c50cfe353ce43edee1d99385c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -54,7 +54,7 @@ Contributors * Lois Rilo -* `NuoBiT `_: +* `NuoBiT Solutions S.L. `_: * Frank Cespedes * Eric Antones diff --git a/oxigen_stock_barcodes_gs1/static/description/index.html b/oxigen_stock_barcodes_gs1/static/description/index.html index bd20fedc..e1520a92 100644 --- a/oxigen_stock_barcodes_gs1/static/description/index.html +++ b/oxigen_stock_barcodes_gs1/static/description/index.html @@ -367,7 +367,7 @@

Oxigen stock barcodes GS1

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:18355e0b0e74e8f9587b341190e2f15a1f71d81a4811fa16e293278459f5529b +!! source digest: sha256:2580c1861591aef093578d851da478d6c965f38c50cfe353ce43edee1d99385c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 oxigensalud/odoo-addons

    -
  • NuoBiT:
      +
    • NuoBiT Solutions S.L.: diff --git a/oxigen_stock_barcodes_gs1/wizard/stock_barcodes_read.py b/oxigen_stock_barcodes_gs1/wizard/stock_barcodes_read.py index 27fb768f..38b44cab 100644 --- a/oxigen_stock_barcodes_gs1/wizard/stock_barcodes_read.py +++ b/oxigen_stock_barcodes_gs1/wizard/stock_barcodes_read.py @@ -16,41 +16,52 @@ class WizStockBarcodesRead(models.AbstractModel): _inherit = "wiz.stock.barcodes.read" def process_lot(self, barcode_decoded): - res = super().process_lot(barcode_decoded) - if self.product_id.tracking == "serial": - lot_barcode = barcode_decoded.get("21", False) - operation = getattr(self, "picking_id", False) or getattr( - self, "inventory_id", False - ) - if not operation: - raise ValidationError( - _( - "This record has inconsistent data. Delete the record and recreate it." - ) + super().process_lot(barcode_decoded) + if self.lot_id and (self.manual_entry or self.is_manual_qty): + self.product_qty += 1 + + def check_serial_lot_conditions(self, barcode_decoded): + operation = getattr(self, "picking_id", False) or getattr( + self, "inventory_id", False + ) + if not operation: + raise ValidationError( + _( + "This record has inconsistent data. Delete the record and recreate it." ) - lot = self.env["stock.production.lot"].search( - [ - ("name", "=", lot_barcode), - ("product_id", "=", self.product_id.id), - ("company_id", "=", operation.company_id.id), - ] ) - ref_barcode = barcode_decoded.get("10", False) - if lot and ref_barcode and lot.ref != ref_barcode: - self._set_messagge_info( - "not_found", - _( - "The lot %s has been found but the reference %s does not match." - % (lot_barcode, ref_barcode) - ), - ) + lot_barcode = barcode_decoded.get("21", False) + lot = self.env["stock.production.lot"].search( + [ + ("name", "=", lot_barcode), + ("product_id", "=", self.product_id.id), + ("company_id", "=", operation.company_id.id), + ] + ) + ref_barcode = barcode_decoded.get("10", False) + if lot and ref_barcode and lot.ref != ref_barcode: + self._set_messagge_info( + "not_found", + _( + "The lot %s has been found but the reference %s does not match." + % (lot_barcode, ref_barcode) + ), + ) + self.env.context = dict(self.env.context, ref_not_found=ref_barcode) + return lot, False + return lot, True + + def process_lot_extended(self, barcode_decoded): + if self.product_id.tracking == "serial": + lot, result_ok = self.check_serial_lot_conditions(barcode_decoded) + if not result_ok: return False if not lot and self.option_group_id.create_lot: lot = self._create_lot(barcode_decoded) self.lot_id = lot - if self.lot_id and (self.manual_entry or self.is_manual_qty): - self.product_qty += 1 - return res + else: + self.process_lot(barcode_decoded) + return True # WARNING: override standard method def process_barcode(self, barcode): # noqa: C901 @@ -114,7 +125,7 @@ def process_barcode(self, barcode): # noqa: C901 else: lot_barcode = barcode_decoded.get("10", False) if lot_barcode and self.product_id.tracking != "none": - if not self.process_lot(barcode_decoded): + if not self.process_lot_extended(barcode_decoded): return False processed = True if product_qty and package_barcode: