From e6282eb21301a1c9ba6f6a17802ba01110ccaa24 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Tue, 28 Dec 2021 12:26:47 +0000 Subject: [PATCH] [IMP] product_expiry, stock: include product barcodes in package content When a product's barcode is EAN compliant (i.e. EAN-8, EAN-13, GTIN-14}) and feature to create DataMatrix is fully installed then we would like to print its GS1 datamatrix on the package content report. Additionally, if the product is tracked, we would like to include its SN/Lot if assigned one + any "use by"/"expiration date" to make the overall usefulness of the report go up. Part of Task: 2494740 Part-of: odoo/odoo#82389 --- addons/barcodes/models/barcode_nomenclature.py | 1 + addons/product_expiry/__manifest__.py | 1 + .../report/report_package_barcode.xml | 10 ++++++++++ addons/stock/models/product.py | 8 ++++++++ addons/stock/report/report_package_barcode.xml | 13 ++++++++++++- 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 addons/product_expiry/report/report_package_barcode.xml diff --git a/addons/barcodes/models/barcode_nomenclature.py b/addons/barcodes/models/barcode_nomenclature.py index c72e2ac6c5a..5a9605c9140 100644 --- a/addons/barcodes/models/barcode_nomenclature.py +++ b/addons/barcodes/models/barcode_nomenclature.py @@ -63,6 +63,7 @@ class BarcodeNomenclature(models.Model): barcode_sizes = { 'ean8': 8, 'ean13': 13, + 'gtin14': 14, 'upca': 12, } barcode_size = barcode_sizes[encoding] diff --git a/addons/product_expiry/__manifest__.py b/addons/product_expiry/__manifest__.py index 60f3822367e..2ca9b2d4e30 100644 --- a/addons/product_expiry/__manifest__.py +++ b/addons/product_expiry/__manifest__.py @@ -27,6 +27,7 @@ Also implements the removal strategy First Expiry First Out (FEFO) widely used, 'wizard/confirm_expiry_view.xml', 'report/report_deliveryslip.xml', 'report/report_lot_barcode.xml', + 'report/report_package_barcode.xml', 'data/product_expiry_data.xml'], 'license': 'LGPL-3', } diff --git a/addons/product_expiry/report/report_package_barcode.xml b/addons/product_expiry/report/report_package_barcode.xml new file mode 100644 index 00000000000..030fcf7873a --- /dev/null +++ b/addons/product_expiry/report/report_package_barcode.xml @@ -0,0 +1,10 @@ + + + diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 282e41759c5..f36f2a2203d 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -101,12 +101,20 @@ class Product(models.Model): storage_category_capacity_ids = fields.One2many('stock.storage.category.capacity', 'product_id', 'Storage Category Capacity') show_on_hand_qty_status_button = fields.Boolean(compute='_compute_show_qty_status_button') show_forecasted_qty_status_button = fields.Boolean(compute='_compute_show_qty_status_button') + valid_ean = fields.Boolean('Barcode is valid EAN', compute='_compute_valid_ean') def _compute_show_qty_status_button(self): for product in self: product.show_on_hand_qty_status_button = product.product_tmpl_id.show_on_hand_qty_status_button product.show_forecasted_qty_status_button = product.product_tmpl_id.show_forecasted_qty_status_button + @api.depends('barcode') + def _compute_valid_ean(self): + self.valid_ean = False + for product in self: + if product.barcode: + product.valid_ean = self.env['barcode.nomenclature'].check_encoding(product.barcode.rjust(14, '0'), 'gtin14') + @api.depends('stock_move_ids.product_qty', 'stock_move_ids.state') @api.depends_context( 'lot_id', 'owner_id', 'package_id', 'from_date', 'to_date', diff --git a/addons/stock/report/report_package_barcode.xml b/addons/stock/report/report_package_barcode.xml index a3a4a71491a..5f02d0a2906 100644 --- a/addons/stock/report/report_package_barcode.xml +++ b/addons/stock/report/report_package_barcode.xml @@ -24,14 +24,16 @@

- +
+ + @@ -48,6 +50,15 @@ +
Product Quantity Lot/Serial Number
+ + + + + + + +