From d8e9f46801b561baca113e3eab835f5c429de4b9 Mon Sep 17 00:00:00 2001 From: HItesh Jadav Date: Fri, 5 Dec 2025 17:43:01 +0530 Subject: [PATCH 1/7] [18.0][MIG] product_label_image: Migration to v18.0 --- product_label_image/README.rst | 5 ++ product_label_image/__init__.py | 1 + product_label_image/__manifest__.py | 18 +++++ product_label_image/reports/__init__.py | 1 + .../reports/product_label_report.py | 50 ++++++++++++ .../reports/product_template_report.xml | 76 +++++++++++++++++++ .../static/src/scss/product_label_image.scss | 38 ++++++++++ product_label_image/wizard/__init__.py | 1 + .../wizard/product_label_layout.py | 39 ++++++++++ 9 files changed, 229 insertions(+) create mode 100644 product_label_image/README.rst create mode 100644 product_label_image/__init__.py create mode 100644 product_label_image/__manifest__.py create mode 100644 product_label_image/reports/__init__.py create mode 100644 product_label_image/reports/product_label_report.py create mode 100644 product_label_image/reports/product_template_report.xml create mode 100644 product_label_image/static/src/scss/product_label_image.scss create mode 100644 product_label_image/wizard/__init__.py create mode 100644 product_label_image/wizard/product_label_layout.py diff --git a/product_label_image/README.rst b/product_label_image/README.rst new file mode 100644 index 00000000..e036a97f --- /dev/null +++ b/product_label_image/README.rst @@ -0,0 +1,5 @@ +=================== +Product Label Image +=================== + +Product barcode print with product image diff --git a/product_label_image/__init__.py b/product_label_image/__init__.py new file mode 100644 index 00000000..0c291b47 --- /dev/null +++ b/product_label_image/__init__.py @@ -0,0 +1 @@ +from . import reports, wizard diff --git a/product_label_image/__manifest__.py b/product_label_image/__manifest__.py new file mode 100644 index 00000000..54eb4b16 --- /dev/null +++ b/product_label_image/__manifest__.py @@ -0,0 +1,18 @@ +{ + "name": "Product Label Image", + "category": "other", + "version": "18.0.1.0.1", + "summary": """Prints product barcode along with product image""", + "author": "Nitrokey GmbH, Odoo Community Association (OCA)", + "website": "https://github.com/Nitrokey/odoo-modules", + "license": "AGPL-3", + "depends": ["product"], + "data": [ + "reports/product_template_report.xml", + ], + "assets": { + "web.report_assets_common": [ + "product_label_image/static/src/scss/product_label_image.scss" + ], + }, +} diff --git a/product_label_image/reports/__init__.py b/product_label_image/reports/__init__.py new file mode 100644 index 00000000..50fc64e0 --- /dev/null +++ b/product_label_image/reports/__init__.py @@ -0,0 +1 @@ +from . import product_label_report diff --git a/product_label_image/reports/product_label_report.py b/product_label_image/reports/product_label_report.py new file mode 100644 index 00000000..109df49d --- /dev/null +++ b/product_label_image/reports/product_label_report.py @@ -0,0 +1,50 @@ +from collections import defaultdict + +from odoo import _, models +from odoo.exceptions import UserError + + +def _prepare_data(env, data): + # change product ids by actual product object to get access to fields in xml + # template we needed to pass ids because reports only accepts native python + # types (int, float, strings, ...) + if data.get("active_model") == "product.template": + Product = env["product.template"].with_context(display_default_code=False) + elif data.get("active_model") == "product.product": + Product = env["product.product"].with_context(display_default_code=False) + else: + raise UserError( + _("Product model not defined, Please contact your administrator.") + ) + + total, quantity_by_product = 0, defaultdict(list) + for p, q in data.get("quantity_by_product", {}).items(): + product = Product.browse(int(p)) + quantity_by_product[product].append((product.barcode, q)) + total += q + if data.get("custom_barcodes"): + # we expect custom barcodes format as: {product: [(barcode, qty_of_barcode)]} + for product, barcodes_qtys in data.get("custom_barcodes").items(): + quantity_by_product[Product.browse(int(product))] += barcodes_qtys + total += sum(qty for _, qty in barcodes_qtys) + + layout_wizard = env["product.label.layout"].browse(data.get("layout_wizard")) + if not layout_wizard: + return {} + + return { + "quantity": quantity_by_product, + "rows": layout_wizard.rows, + "columns": layout_wizard.columns, + "page_numbers": (total - 1) // (layout_wizard.rows * layout_wizard.columns) + 1, + "price_included": data.get("price_included"), + "extra_html": layout_wizard.extra_html, + } + + +class ReportProductTemplateLabelImage4x6(models.AbstractModel): + _name = "report.product_label_image.producttemplatelabel_image_4x6" + _description = "Product Label Report" + + def _get_report_values(self, docids, data): + return _prepare_data(self.env, data) diff --git a/product_label_image/reports/product_template_report.xml b/product_label_image/reports/product_template_report.xml new file mode 100644 index 00000000..dbdd1591 --- /dev/null +++ b/product_label_image/reports/product_template_report.xml @@ -0,0 +1,76 @@ + + + + + + + + + + Product Label (PDF) + product.template + qweb-pdf + product_label_image.producttemplatelabel_image_4x6 + product_label_image.producttemplatelabel_image_4x6 + + 'Products Labels - %s' % (object.name) + report + + diff --git a/product_label_image/static/src/scss/product_label_image.scss b/product_label_image/static/src/scss/product_label_image.scss new file mode 100644 index 00000000..dff48f1f --- /dev/null +++ b/product_label_image/static/src/scss/product_label_image.scss @@ -0,0 +1,38 @@ +div { + &.o_firstdiv { + width: 100%; + margin-bottom: 200px; + } + &.o_seconddiv { + width: 310px; + height: 210px; + border: 2px solid #555555 !important; + padding: 2px 4px; + } + &.o_thirddiv { + height: 86px; + margin-bottom: 18px; + overflow: hidden; + background-color: ghostwhite; + & > strong { + font-size: 16px; + } + } + &.o_barcode { + padding: 5px; + } + &.o_product_img_div1 { + width: 310px; + height: 210px; + border: 2px solid #555555; + border-left: 1px; + } + &.img_div2 { + height: 10rem; + } + & > img.o_product_picture { + height: 190px; + width: auto; + margin-top: 8%; + } +} diff --git a/product_label_image/wizard/__init__.py b/product_label_image/wizard/__init__.py new file mode 100644 index 00000000..6818894b --- /dev/null +++ b/product_label_image/wizard/__init__.py @@ -0,0 +1 @@ +from . import product_label_layout diff --git a/product_label_image/wizard/product_label_layout.py b/product_label_image/wizard/product_label_layout.py new file mode 100644 index 00000000..7758dd6d --- /dev/null +++ b/product_label_image/wizard/product_label_layout.py @@ -0,0 +1,39 @@ +from odoo import _, fields, models +from odoo.exceptions import UserError + + +class ProductLabelLayout(models.TransientModel): + _inherit = "product.label.layout" + + print_format = fields.Selection( + selection_add=[("4x6", "4x6")], + default="4x6", + ondelete={"4x6": "set default"}, + ) + + def _prepare_report_data(self): + if self.custom_quantity <= 0: + raise UserError(_("You need to set a positive quantity.")) + + # Get layout grid + if self.print_format != "4x6": + return super()._prepare_report_data() + + xml_id = "product_label_image.report_product_label_image_4x6" + + active_model = "" + if self.product_tmpl_ids: + products = self.product_tmpl_ids.ids + active_model = "product.template" + elif self.product_ids: + products = self.product_ids.ids + active_model = "product.product" + + # Build data to pass to the report + data = { + "active_model": active_model, + "quantity_by_product": {p: self.custom_quantity for p in products}, + "layout_wizard": self.id, + "price_included": "xprice" in self.print_format, + } + return xml_id, data From ea6a2f91e0c1bd26ed15341868e009dea1850d09 Mon Sep 17 00:00:00 2001 From: HItesh Jadav Date: Wed, 10 Dec 2025 18:28:09 +0530 Subject: [PATCH 2/7] [IMP] Implememeted the report image format --- product_label_image/reports/product_template_report.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/product_label_image/reports/product_template_report.xml b/product_label_image/reports/product_template_report.xml index dbdd1591..8c8cd741 100644 --- a/product_label_image/reports/product_template_report.xml +++ b/product_label_image/reports/product_template_report.xml @@ -24,9 +24,10 @@
+
From 558fdadc3fc2a763fed50e63422ad761136efaa5 Mon Sep 17 00:00:00 2001 From: jans23 Date: Wed, 10 Dec 2025 14:49:35 +0100 Subject: [PATCH 3/7] Update author information in manifest file --- product_label_image/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product_label_image/__manifest__.py b/product_label_image/__manifest__.py index 54eb4b16..37797b89 100644 --- a/product_label_image/__manifest__.py +++ b/product_label_image/__manifest__.py @@ -3,7 +3,7 @@ "category": "other", "version": "18.0.1.0.1", "summary": """Prints product barcode along with product image""", - "author": "Nitrokey GmbH, Odoo Community Association (OCA)", + "author": "Nitrokey GmbH", "website": "https://github.com/Nitrokey/odoo-modules", "license": "AGPL-3", "depends": ["product"], From 24e1e20966ead504e04ddd3953fb5efbde9c8556 Mon Sep 17 00:00:00 2001 From: HItesh Jadav Date: Wed, 10 Dec 2025 19:28:54 +0530 Subject: [PATCH 4/7] [IMP] Remove the light-grey-blue background color behind the product name --- product_label_image/reports/product_template_report.xml | 1 - product_label_image/static/src/scss/product_label_image.scss | 1 - 2 files changed, 2 deletions(-) diff --git a/product_label_image/reports/product_template_report.xml b/product_label_image/reports/product_template_report.xml index 8c8cd741..24c36f3c 100644 --- a/product_label_image/reports/product_template_report.xml +++ b/product_label_image/reports/product_template_report.xml @@ -27,7 +27,6 @@ t-att-src="image_data_uri(product.image_512)" t-attf-style="max-width: 100%; max-height: 100%; object-fit: contain;" /> - diff --git a/product_label_image/static/src/scss/product_label_image.scss b/product_label_image/static/src/scss/product_label_image.scss index dff48f1f..fba86bd5 100644 --- a/product_label_image/static/src/scss/product_label_image.scss +++ b/product_label_image/static/src/scss/product_label_image.scss @@ -13,7 +13,6 @@ div { height: 86px; margin-bottom: 18px; overflow: hidden; - background-color: ghostwhite; & > strong { font-size: 16px; } From ea10dcf3b5dc1955bddffaf27150cb0590a6de9c Mon Sep 17 00:00:00 2001 From: HItesh Jadav Date: Thu, 11 Dec 2025 12:00:27 +0530 Subject: [PATCH 5/7] [REM] Remove README file --- product_label_image/README.rst | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 product_label_image/README.rst diff --git a/product_label_image/README.rst b/product_label_image/README.rst deleted file mode 100644 index e036a97f..00000000 --- a/product_label_image/README.rst +++ /dev/null @@ -1,5 +0,0 @@ -=================== -Product Label Image -=================== - -Product barcode print with product image From 3e005146e65e78bed76dbad774b82d8d1f8e8dbc Mon Sep 17 00:00:00 2001 From: HItesh Jadav Date: Thu, 11 Dec 2025 14:23:46 +0530 Subject: [PATCH 6/7] [ADD] Added README file --- product_label_image/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 product_label_image/README.md diff --git a/product_label_image/README.md b/product_label_image/README.md new file mode 100644 index 00000000..e036a97f --- /dev/null +++ b/product_label_image/README.md @@ -0,0 +1,5 @@ +=================== +Product Label Image +=================== + +Product barcode print with product image From 686dd2021cb472c7c1d78baf3cc8031359b2c150 Mon Sep 17 00:00:00 2001 From: HItesh Jadav Date: Thu, 11 Dec 2025 14:56:05 +0530 Subject: [PATCH 7/7] [ADD] Implemented README file --- product_label_image/{README.md => README.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename product_label_image/{README.md => README.rst} (100%) diff --git a/product_label_image/README.md b/product_label_image/README.rst similarity index 100% rename from product_label_image/README.md rename to product_label_image/README.rst