From ecc45ed84adc582b561b9424e43308c4bcf61b9d Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 25 Feb 2021 13:05:11 +0800 Subject: [PATCH 01/10] st1 [1490][ADD] product_label_template (#74) --- product_label_template/__init__.py | 1 + product_label_template/__manifest__.py | 20 ++ product_label_template/i18n/ja.po | 180 ++++++++++++++++++ product_label_template/models/__init__.py | 3 + .../models/product_label_template.py | 77 ++++++++ .../models/product_label_type.py | 10 + .../models/product_product.py | 12 ++ .../reports/product_label_reports.xml | 23 +++ .../security/ir.model.access.csv | 3 + .../views/product_label_template_views.xml | 38 ++++ .../views/product_label_type_views.xml | 25 +++ .../views/product_product_views.xml | 29 +++ product_label_template/views/templates.xml | 51 +++++ 13 files changed, 472 insertions(+) create mode 100644 product_label_template/__init__.py create mode 100644 product_label_template/__manifest__.py create mode 100644 product_label_template/i18n/ja.po create mode 100644 product_label_template/models/__init__.py create mode 100644 product_label_template/models/product_label_template.py create mode 100644 product_label_template/models/product_label_type.py create mode 100644 product_label_template/models/product_product.py create mode 100644 product_label_template/reports/product_label_reports.xml create mode 100644 product_label_template/security/ir.model.access.csv create mode 100644 product_label_template/views/product_label_template_views.xml create mode 100644 product_label_template/views/product_label_type_views.xml create mode 100644 product_label_template/views/product_product_views.xml create mode 100644 product_label_template/views/templates.xml diff --git a/product_label_template/__init__.py b/product_label_template/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/product_label_template/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_label_template/__manifest__.py b/product_label_template/__manifest__.py new file mode 100644 index 0000000..c37958a --- /dev/null +++ b/product_label_template/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2021 Quartile Limited +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +{ + "name": "Product Label Template", + "version": "12.0.1.0.0", + "author": "Quartile Limited", + "website": "https://www.quartile.co", + "category": "Products", + "license": "LGPL-3", + "depends": ["sale_stock", "stock_lot_expiry_rpl"], + "data": [ + "security/ir.model.access.csv", + "reports/product_label_reports.xml", + "views/product_label_template_views.xml", + "views/product_label_type_views.xml", + "views/product_product_views.xml", + "views/templates.xml", + ], + "installable": True, +} diff --git a/product_label_template/i18n/ja.po b/product_label_template/i18n/ja.po new file mode 100644 index 0000000..f257245 --- /dev/null +++ b/product_label_template/i18n/ja.po @@ -0,0 +1,180 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_label_template +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-02-25 04:46+0000\n" +"PO-Revision-Date: 2021-02-25 04:46+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__create_uid +#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__create_uid +msgid "Created by" +msgstr "作成者" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__create_date +#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__create_date +msgid "Created on" +msgstr "作成日" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__display_name +#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__display_name +msgid "Display Name" +msgstr "表示名" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__font_family +msgid "Font Family" +msgstr "フォント" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__font_size +msgid "Font Size" +msgstr "フォントサイズ" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_height_padding +msgid "Height Padding (QR Code)" +msgstr "高さパディング(QRコード)" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__height_padding +msgid "Height Padding (Text)" +msgstr "高さパディング(テキスト)" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__id +#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__id +msgid "ID" +msgstr "" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_height +msgid "Label Height" +msgstr "ラベル高さ" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__name +msgid "Label Type" +msgstr "ラベルタイプ" + +#. module: product_label_template +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_type_tree_view +msgid "Label Types" +msgstr "ラベルタイプ" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_width +msgid "Label Width" +msgstr "ラベル幅" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template____last_update +#: model:ir.model.fields,field_description:product_label_template.field_product_label_type____last_update +msgid "Last Modified on" +msgstr "最終更新日" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__write_uid +#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__write_uid +msgid "Last Updated by" +msgstr "最終更新者" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__write_date +#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__write_date +msgid "Last Updated on" +msgstr "最終更新日" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__line_height +msgid "Line Spacing" +msgstr "行間隔" + +#. module: product_label_template +#: model:ir.model,name:product_label_template.model_product_product +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__product_id +msgid "Product" +msgstr "プロダクト" + +#. module: product_label_template +#: model:ir.actions.report,name:product_label_template.action_mrp_production_report_product_label +#: model:ir.actions.report,name:product_label_template.action_stock_picking_report_product_label +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_image +msgid "Product Label" +msgstr "プロダクトラベル" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_product__product_label_template_ids +msgid "Product Label Template" +msgstr "プロダクトラベルテンプレート" + +#. module: product_label_template +#: model:ir.actions.act_window,name:product_label_template.product_label_template_action +#: model:ir.ui.menu,name:product_label_template.menu_product_label_template_action +msgid "Product Label Templates" +msgstr "プロダクトラベルテンプレート" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__product_label_type_id +msgid "Product Label Type" +msgstr "プロダクトラベルタイプ" + +#. module: product_label_template +#: model:ir.actions.act_window,name:product_label_template.product_label_type_action +#: model:ir.ui.menu,name:product_label_template.menu_product_label_type_action +msgid "Product Label Types" +msgstr "プロダクトラベルタイプ" + +#. module: product_label_template +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_tree_view +#: model_terms:ir.ui.view,arch_db:product_label_template.product_normal_form_view +msgid "Product Labels" +msgstr "プロダクトラベル" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_size +msgid "QR Code Size" +msgstr "QRコードサイズ" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_width_padding +msgid "Width Padding (QR Code)" +msgstr "幅パディング(QRコード)" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__width_padding +msgid "Width Padding (Text)" +msgstr "幅パディング(テキスト)" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__with_qr_code +msgid "With QR Code" +msgstr "QRコード付き" + +#. module: product_label_template +#: model:ir.model,name:product_label_template.model_product_label_template +msgid "product.label.template" +msgstr "" + +#. module: product_label_template +#: model:ir.model,name:product_label_template.model_product_label_type +msgid "product.label.type" +msgstr "" + +#. module: product_label_template +#: model:ir.model,name:product_label_template.model_report_product_label_template_product_label_reports +msgid "report.product_label_template.product_label_reports" +msgstr "" + diff --git a/product_label_template/models/__init__.py b/product_label_template/models/__init__.py new file mode 100644 index 0000000..6e92df7 --- /dev/null +++ b/product_label_template/models/__init__.py @@ -0,0 +1,3 @@ +from . import product_label_template +from . import product_label_type +from . import product_product diff --git a/product_label_template/models/product_label_template.py b/product_label_template/models/product_label_template.py new file mode 100644 index 0000000..05b9e09 --- /dev/null +++ b/product_label_template/models/product_label_template.py @@ -0,0 +1,77 @@ +# Copyright 2021 Quartile Limited +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +import codecs +import io + +from PIL import Image + +from odoo import api, fields, models +from odoo.tools.image import image_data_uri + + +class ProductLabelTemplate(models.Model): + _name = "product.label.template" + + product_label_type_id = fields.Many2one("product.label.type", required=True) + product_id = fields.Many2one("product.product", required=True) + label_image = fields.Binary(string="Product Label", attachment=True,) + label_width = fields.Float( + "Label Width", compute="_compute_label_size", store=True, readonly=False + ) + label_height = fields.Float( + "Label Height", compute="_compute_label_size", store=True, readonly=False + ) + font_family = fields.Char("Font Family") + font_size = fields.Float("Font Size") + line_height = fields.Float("Line Spacing") + width_padding = fields.Float("Width Padding (Text)") + height_padding = fields.Float("Height Padding (Text)") + with_qr_code = fields.Boolean("With QR Code") + qr_code_size = fields.Integer("QR Code Size") + qr_code_width_padding = fields.Float("Width Padding (QR Code)") + qr_code_height_padding = fields.Float("Height Padding (QR Code)") + + def get_label_css(self): + css_list = [ + "position: relative", + "background-image: url('%s')" % image_data_uri(self.label_image), + "height: %spx" % self.label_height, + "width: %spx" % self.label_width, + "background-size: cover", + ] + return ";".join(css_list) + + def get_label_text_css(self): + css_list = ["position: absolute"] + if self.font_family: + css_list.append("font-family: %s" % self.font_family) + if self.font_size: + css_list.append("font-size: %spx" % self.font_size) + if self.line_height: + css_list.append("line-height: %s" % self.line_height) + if self.width_padding: + css_list.append("left: %spx" % self.width_padding) + if self.height_padding: + css_list.append("top: %spx" % self.height_padding) + return ";".join(css_list) + + def get_qr_code_css(self): + css_list = ["position: absolute"] + if self.qr_code_width_padding: + css_list.append("left: %spx" % self.width_padding) + if self.qr_code_height_padding: + css_list.append("top: %spx" % self.height_padding) + return ";".join(css_list) + + @api.multi + @api.depends("label_image") + def _compute_label_size(self): + for template in self: + if template.label_image: + # Borrowing logic from odoo image tool + # https://github.com/odoo/odoo/blob/4e2d0b97f3ec0491294301a5a6b05086e158dea8/odoo/tools/image.py#L68-L69 # noqa + image_stream = io.BytesIO(codecs.decode(template.label_image, "base64")) + image = Image.open(image_stream) + template.label_width = image.size[0] + template.label_height = image.size[1] diff --git a/product_label_template/models/product_label_type.py b/product_label_template/models/product_label_type.py new file mode 100644 index 0000000..82d3d26 --- /dev/null +++ b/product_label_template/models/product_label_type.py @@ -0,0 +1,10 @@ +# Copyright 2021 Quartile Limited +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class ProductLabelType(models.Model): + _name = "product.label.type" + + name = fields.Char("Label Type") diff --git a/product_label_template/models/product_product.py b/product_label_template/models/product_product.py new file mode 100644 index 0000000..f2eb118 --- /dev/null +++ b/product_label_template/models/product_product.py @@ -0,0 +1,12 @@ +# Copyright 2021 Quartile Limited +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class ProductProduct(models.Model): + _inherit = "product.product" + + product_label_template_ids = fields.One2many( + "product.label.template", "product_id", "Product Label Template" + ) diff --git a/product_label_template/reports/product_label_reports.xml b/product_label_template/reports/product_label_reports.xml new file mode 100644 index 0000000..7d8068b --- /dev/null +++ b/product_label_template/reports/product_label_reports.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/product_label_template/security/ir.model.access.csv b/product_label_template/security/ir.model.access.csv new file mode 100644 index 0000000..296bd66 --- /dev/null +++ b/product_label_template/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_product_label_template,access.product.label.template,model_product_label_template,base.group_user,1,1,1,1 +access_product_label_type,access.product.label.type,model_product_label_type,base.group_user,1,1,1,1 diff --git a/product_label_template/views/product_label_template_views.xml b/product_label_template/views/product_label_template_views.xml new file mode 100644 index 0000000..dc2308e --- /dev/null +++ b/product_label_template/views/product_label_template_views.xml @@ -0,0 +1,38 @@ + + + + product.label.template.tree + product.label.template + + + + + + + + + + + + + + + + + + + + + Product Label Templates + ir.actions.act_window + product.label.template + tree + form + + + diff --git a/product_label_template/views/product_label_type_views.xml b/product_label_template/views/product_label_type_views.xml new file mode 100644 index 0000000..a5e0790 --- /dev/null +++ b/product_label_template/views/product_label_type_views.xml @@ -0,0 +1,25 @@ + + + + product.label.type.tree + product.label.type + + + + + + + + Product Label Types + ir.actions.act_window + product.label.type + tree + form + + + diff --git a/product_label_template/views/product_product_views.xml b/product_label_template/views/product_product_views.xml new file mode 100644 index 0000000..3c1ace5 --- /dev/null +++ b/product_label_template/views/product_product_views.xml @@ -0,0 +1,29 @@ + + + + product.product.form + product.product + + + + + + + + + + + + + + + + + + + + + diff --git a/product_label_template/views/templates.xml b/product_label_template/views/templates.xml new file mode 100644 index 0000000..b1ba51d --- /dev/null +++ b/product_label_template/views/templates.xml @@ -0,0 +1,51 @@ + + + + + From 1c8ff5cc0999a4357330a4d642a7da340393d950 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 1 Mar 2021 13:35:29 +0800 Subject: [PATCH 02/10] Read bytes string in _compute_label_size (#77) --- product_label_template/models/product_label_template.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/product_label_template/models/product_label_template.py b/product_label_template/models/product_label_template.py index 05b9e09..dd1520d 100644 --- a/product_label_template/models/product_label_template.py +++ b/product_label_template/models/product_label_template.py @@ -1,7 +1,7 @@ # Copyright 2021 Quartile Limited # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -import codecs +import base64 import io from PIL import Image @@ -71,7 +71,7 @@ def _compute_label_size(self): if template.label_image: # Borrowing logic from odoo image tool # https://github.com/odoo/odoo/blob/4e2d0b97f3ec0491294301a5a6b05086e158dea8/odoo/tools/image.py#L68-L69 # noqa - image_stream = io.BytesIO(codecs.decode(template.label_image, "base64")) + image_stream = io.BytesIO(base64.b64decode(template.label_image)) image = Image.open(image_stream) template.label_width = image.size[0] template.label_height = image.size[1] From fd44e776541bbd37bb736e5c03a3cec295a8bad1 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 22 Mar 2021 12:51:47 +0800 Subject: [PATCH 03/10] st1 [1490][IMP] Add label margin and paper format (#84) --- product_label_template/README.rst | 70 +++ product_label_template/__manifest__.py | 3 +- product_label_template/i18n/ja.po | 46 +- product_label_template/models/__init__.py | 2 +- .../models/product_label_reports.py | 25 ++ .../models/product_label_template.py | 26 +- .../models/product_label_type.py | 10 - product_label_template/readme/DESCRIPTION.rst | 19 + .../security/ir.model.access.csv | 1 - .../static/description/index.html | 425 ++++++++++++++++++ .../views/product_label_template_views.xml | 7 +- .../views/product_label_type_views.xml | 25 -- .../views/product_product_views.xml | 1 - product_label_template/views/templates.xml | 56 ++- 14 files changed, 614 insertions(+), 102 deletions(-) create mode 100644 product_label_template/README.rst create mode 100644 product_label_template/models/product_label_reports.py delete mode 100644 product_label_template/models/product_label_type.py create mode 100644 product_label_template/readme/DESCRIPTION.rst create mode 100644 product_label_template/static/description/index.html delete mode 100644 product_label_template/views/product_label_type_views.xml diff --git a/product_label_template/README.rst b/product_label_template/README.rst new file mode 100644 index 0000000..d142d76 --- /dev/null +++ b/product_label_template/README.rst @@ -0,0 +1,70 @@ +====================== +Product Label Template +====================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-qrtl%2Frpl--private-lightgray.png?logo=github + :target: https://github.com/qrtl/rpl-private/tree/12.0/product_label_template + :alt: qrtl/rpl-private + +|badge1| |badge2| |badge3| + +This module adds product label printing to delivery and manufacturing order. + +Product Label Template Settings Description + +1. Paper Format: Paper format that uses to print out the PDF (report.paperformat) +2. Product Label: Product label image +3. Label Width: Width of the printed label image (in px) +4. Label Height: Height of the printed label image (in px) +5. Font Family: Font of the lot information +6. Font Size: Font size of the lot information (in px) +7. Line Spacing: Spacing between the lot information (in px) +8. Width Padding (Text): Horizontal position of the lot information (corresponding to the label) +9. Height Padding (Text): Vertical position of the lot information (corresponding to the label) +10. With QR Code: Print QR code on the label +11. QR Code Size: Size of the QR code. +12. Width Padding (QR Code): Horizontal position of QR code (corresponding to the label) +13. Height Padding (QR Code): Vertical position of QR code (corresponding to the label) +14. Label Width Margin: Horizontal margin between labels +15. Label Height Margin: Vertical margin between labels + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Quartile Limited + +Maintainers +~~~~~~~~~~~ + +This module is part of the `qrtl/rpl-private `_ project on GitHub. + +You are welcome to contribute. diff --git a/product_label_template/__manifest__.py b/product_label_template/__manifest__.py index c37958a..a9bba2b 100644 --- a/product_label_template/__manifest__.py +++ b/product_label_template/__manifest__.py @@ -7,12 +7,11 @@ "website": "https://www.quartile.co", "category": "Products", "license": "LGPL-3", - "depends": ["sale_stock", "stock_lot_expiry_rpl"], + "depends": ["stock_lot_expiry_rpl", "mrp"], "data": [ "security/ir.model.access.csv", "reports/product_label_reports.xml", "views/product_label_template_views.xml", - "views/product_label_type_views.xml", "views/product_product_views.xml", "views/templates.xml", ], diff --git a/product_label_template/i18n/ja.po b/product_label_template/i18n/ja.po index f257245..9aeab57 100644 --- a/product_label_template/i18n/ja.po +++ b/product_label_template/i18n/ja.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-02-25 04:46+0000\n" -"PO-Revision-Date: 2021-02-25 04:46+0000\n" +"POT-Creation-Date: 2021-03-15 09:54+0000\n" +"PO-Revision-Date: 2021-03-15 09:54+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -17,19 +17,17 @@ msgstr "" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__create_uid -#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__create_uid msgid "Created by" msgstr "作成者" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__create_date -#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__create_date msgid "Created on" msgstr "作成日" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__display_name -#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__display_name +#: model:ir.model.fields,field_description:product_label_template.field_report_product_label_template_product_label_reports__display_name msgid "Display Name" msgstr "表示名" @@ -55,7 +53,7 @@ msgstr "高さパディング(テキスト)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__id -#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__id +#: model:ir.model.fields,field_description:product_label_template.field_report_product_label_template_product_label_reports__id msgid "ID" msgstr "" @@ -65,35 +63,33 @@ msgid "Label Height" msgstr "ラベル高さ" #. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__name -msgid "Label Type" -msgstr "ラベルタイプ" - -#. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_type_tree_view -msgid "Label Types" -msgstr "ラベルタイプ" +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_height_margin +msgid "Label Height Margin" +msgstr "高さマージン" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_width msgid "Label Width" msgstr "ラベル幅" +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_width_margin +msgid "Label Width Margin" +msgstr "幅マージン" + #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template____last_update -#: model:ir.model.fields,field_description:product_label_template.field_product_label_type____last_update +#: model:ir.model.fields,field_description:product_label_template.field_report_product_label_template_product_label_reports____last_update msgid "Last Modified on" msgstr "最終更新日" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__write_uid -#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__write_uid msgid "Last Updated by" msgstr "最終更新者" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__write_date -#: model:ir.model.fields,field_description:product_label_template.field_product_label_type__write_date msgid "Last Updated on" msgstr "最終更新日" @@ -102,6 +98,11 @@ msgstr "最終更新日" msgid "Line Spacing" msgstr "行間隔" +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__paperformat_id +msgid "Paper Format" +msgstr "用紙" + #. module: product_label_template #: model:ir.model,name:product_label_template.model_product_product #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__product_id @@ -126,17 +127,6 @@ msgstr "プロダクトラベルテンプレート" msgid "Product Label Templates" msgstr "プロダクトラベルテンプレート" -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__product_label_type_id -msgid "Product Label Type" -msgstr "プロダクトラベルタイプ" - -#. module: product_label_template -#: model:ir.actions.act_window,name:product_label_template.product_label_type_action -#: model:ir.ui.menu,name:product_label_template.menu_product_label_type_action -msgid "Product Label Types" -msgstr "プロダクトラベルタイプ" - #. module: product_label_template #: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_tree_view #: model_terms:ir.ui.view,arch_db:product_label_template.product_normal_form_view diff --git a/product_label_template/models/__init__.py b/product_label_template/models/__init__.py index 6e92df7..620730a 100644 --- a/product_label_template/models/__init__.py +++ b/product_label_template/models/__init__.py @@ -1,3 +1,3 @@ +from . import product_label_reports from . import product_label_template -from . import product_label_type from . import product_product diff --git a/product_label_template/models/product_label_reports.py b/product_label_template/models/product_label_reports.py new file mode 100644 index 0000000..e3468af --- /dev/null +++ b/product_label_template/models/product_label_reports.py @@ -0,0 +1,25 @@ +# Copyright 2021 Quartile Limited +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import api, models + + +class ProductLabelReports(models.AbstractModel): + _name = "report.product_label_template.product_label_reports" + + @api.model + def _get_report_values(self, docids, data=None): + report_name = "product_label_template.product_label_reports" + report = self.env["ir.actions.report"]._get_report_from_name(report_name) + lots = self.env["mrp.production"].browse(docids).mapped("new_lot_id") + paper_format = ( + lots.mapped("product_id") + .mapped("product_label_template_ids") + .mapped("paperformat_id") + ) + report.paperformat_id = paper_format[0] if paper_format else False + return { + "doc_ids": docids, + "doc_model": report.model, + "lots": lots, + } diff --git a/product_label_template/models/product_label_template.py b/product_label_template/models/product_label_template.py index dd1520d..c18e1c4 100644 --- a/product_label_template/models/product_label_template.py +++ b/product_label_template/models/product_label_template.py @@ -13,8 +13,8 @@ class ProductLabelTemplate(models.Model): _name = "product.label.template" - product_label_type_id = fields.Many2one("product.label.type", required=True) product_id = fields.Many2one("product.product", required=True) + paperformat_id = fields.Many2one("report.paperformat", "Paper Format") label_image = fields.Binary(string="Product Label", attachment=True,) label_width = fields.Float( "Label Width", compute="_compute_label_size", store=True, readonly=False @@ -22,6 +22,7 @@ class ProductLabelTemplate(models.Model): label_height = fields.Float( "Label Height", compute="_compute_label_size", store=True, readonly=False ) + label_ratio = fields.Float("Label Ratio", compute="_compute_label_size", store=True) font_family = fields.Char("Font Family") font_size = fields.Float("Font Size") line_height = fields.Float("Line Spacing") @@ -31,6 +32,18 @@ class ProductLabelTemplate(models.Model): qr_code_size = fields.Integer("QR Code Size") qr_code_width_padding = fields.Float("Width Padding (QR Code)") qr_code_height_padding = fields.Float("Height Padding (QR Code)") + label_width_margin = fields.Float("Label Width Margin") + label_height_margin = fields.Float("Label Height Margin") + + def get_label_layout_css(self): + css_list = [ + "display: inline-table", + ] + if self.label_width_margin: + css_list.append("margin-left: %spx" % self.label_width_margin) + if self.label_height_margin: + css_list.append("margin-top: %spx" % self.label_height_margin) + return ";".join(css_list) def get_label_css(self): css_list = [ @@ -64,6 +77,16 @@ def get_qr_code_css(self): css_list.append("top: %spx" % self.height_padding) return ";".join(css_list) + @api.onchange("label_width") + def _onchange_label_width(self): + if self.label_width and self.label_ratio: + self.label_height = self.label_width / self.label_ratio + + @api.onchange("label_height") + def _onchange_label_height(self): + if self.label_height and self.label_ratio: + self.label_width = self.label_height * self.label_ratio + @api.multi @api.depends("label_image") def _compute_label_size(self): @@ -75,3 +98,4 @@ def _compute_label_size(self): image = Image.open(image_stream) template.label_width = image.size[0] template.label_height = image.size[1] + template.label_ratio = image.size[0] / image.size[1] diff --git a/product_label_template/models/product_label_type.py b/product_label_template/models/product_label_type.py deleted file mode 100644 index 82d3d26..0000000 --- a/product_label_template/models/product_label_type.py +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2021 Quartile Limited -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - -from odoo import fields, models - - -class ProductLabelType(models.Model): - _name = "product.label.type" - - name = fields.Char("Label Type") diff --git a/product_label_template/readme/DESCRIPTION.rst b/product_label_template/readme/DESCRIPTION.rst new file mode 100644 index 0000000..134e4ba --- /dev/null +++ b/product_label_template/readme/DESCRIPTION.rst @@ -0,0 +1,19 @@ +This module adds product label printing to delivery and manufacturing order. + +Product Label Template Settings Description + +1. Paper Format: Paper format that uses to print out the PDF (report.paperformat) +2. Product Label: Product label image +3. Label Width: Width of the printed label image (in px) +4. Label Height: Height of the printed label image (in px) +5. Font Family: Font of the lot information +6. Font Size: Font size of the lot information (in px) +7. Line Spacing: Spacing between the lot information (in px) +8. Width Padding (Text): Horizontal position of the lot information (corresponding to the label) +9. Height Padding (Text): Vertical position of the lot information (corresponding to the label) +10. With QR Code: Print QR code on the label +11. QR Code Size: Size of the QR code. +12. Width Padding (QR Code): Horizontal position of QR code (corresponding to the label) +13. Height Padding (QR Code): Vertical position of QR code (corresponding to the label) +14. Label Width Margin: Horizontal margin between labels +15. Label Height Margin: Vertical margin between labels diff --git a/product_label_template/security/ir.model.access.csv b/product_label_template/security/ir.model.access.csv index 296bd66..6e02c67 100644 --- a/product_label_template/security/ir.model.access.csv +++ b/product_label_template/security/ir.model.access.csv @@ -1,3 +1,2 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_product_label_template,access.product.label.template,model_product_label_template,base.group_user,1,1,1,1 -access_product_label_type,access.product.label.type,model_product_label_type,base.group_user,1,1,1,1 diff --git a/product_label_template/static/description/index.html b/product_label_template/static/description/index.html new file mode 100644 index 0000000..5512dfb --- /dev/null +++ b/product_label_template/static/description/index.html @@ -0,0 +1,425 @@ + + + + + + +Product Label Template + + + +
+

Product Label Template

+ + +

Beta License: LGPL-3 qrtl/rpl-private

+

This module adds product label printing to delivery and manufacturing order.

+

Product Label Template Settings Description

+
    +
  1. Paper Format: Paper format that uses to print out the PDF (report.paperformat)
  2. +
  3. Product Label: Product label image
  4. +
  5. Label Width: Width of the printed label image (in px)
  6. +
  7. Label Height: Height of the printed label image (in px)
  8. +
  9. Font Family: Font of the lot information
  10. +
  11. Font Size: Font size of the lot information (in px)
  12. +
  13. Line Spacing: Spacing between the lot information (in px)
  14. +
  15. Width Padding (Text): Horizontal position of the lot information (corresponding to the label)
  16. +
  17. Height Padding (Text): Vertical position of the lot information (corresponding to the label)
  18. +
  19. With QR Code: Print QR code on the label
  20. +
  21. QR Code Size: Size of the QR code.
  22. +
  23. Width Padding (QR Code): Horizontal position of QR code (corresponding to the label)
  24. +
  25. Height Padding (QR Code): Vertical position of QR code (corresponding to the label)
  26. +
  27. Label Width Margin: Horizontal margin between labels
  28. +
  29. Label Height Margin: Vertical margin between labels
  30. +
+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Quartile Limited
  • +
+
+
+

Maintainers

+

This module is part of the qrtl/rpl-private project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/product_label_template/views/product_label_template_views.xml b/product_label_template/views/product_label_template_views.xml index dc2308e..dd68593 100644 --- a/product_label_template/views/product_label_template_views.xml +++ b/product_label_template/views/product_label_template_views.xml @@ -6,10 +6,13 @@ - + + + + @@ -32,7 +35,7 @@ diff --git a/product_label_template/views/product_label_type_views.xml b/product_label_template/views/product_label_type_views.xml deleted file mode 100644 index a5e0790..0000000 --- a/product_label_template/views/product_label_type_views.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - product.label.type.tree - product.label.type - - - - - - - - Product Label Types - ir.actions.act_window - product.label.type - tree - form - - - diff --git a/product_label_template/views/product_product_views.xml b/product_label_template/views/product_product_views.xml index 3c1ace5..7c8c3fe 100644 --- a/product_label_template/views/product_product_views.xml +++ b/product_label_template/views/product_product_views.xml @@ -13,7 +13,6 @@ > - diff --git a/product_label_template/views/templates.xml b/product_label_template/views/templates.xml index b1ba51d..18b52e6 100644 --- a/product_label_template/views/templates.xml +++ b/product_label_template/views/templates.xml @@ -2,50 +2,44 @@ From 7c84c014402f7ca2d72d19e598920273cb83cf22 Mon Sep 17 00:00:00 2001 From: "Yoshi Tashiro (Quartile)" Date: Fri, 3 Sep 2021 16:11:21 +0900 Subject: [PATCH 04/10] st1 [523][ADD] mrp_production_product_label_print (#180) * add mrp_production_product_label_print * update readme * pre-commit * update * update readme --- product_label_template/README.rst | 29 +++++++++++- product_label_template/__manifest__.py | 3 +- product_label_template/readme/CONFIGURE.rst | 20 +++++++++ product_label_template/readme/DESCRIPTION.rst | 5 ++- .../reports/product_label_reports.xml | 23 ---------- .../static/description/index.html | 45 +++++++++++++++---- product_label_template/views/templates.xml | 17 +------ 7 files changed, 90 insertions(+), 52 deletions(-) create mode 100644 product_label_template/readme/CONFIGURE.rst delete mode 100644 product_label_template/reports/product_label_reports.xml diff --git a/product_label_template/README.rst b/product_label_template/README.rst index d142d76..d15f7b8 100644 --- a/product_label_template/README.rst +++ b/product_label_template/README.rst @@ -19,7 +19,10 @@ Product Label Template |badge1| |badge2| |badge3| -This module adds product label printing to delivery and manufacturing order. +This module provides the function to maintain the label template for each product. +The module does not provide the printing function by itself. The module is expected +to be used as a dependency of the modules for label printing (e.g. +mrp_production_product_label_print module). Product Label Template Settings Description @@ -44,6 +47,30 @@ Product Label Template Settings Description .. contents:: :local: +Configuration +============= + +Go to *Manufacturing > Configuratioon > Product Label Templates*, and create/maintain +product templates there. + +Product Label Template settings: + +1. Paper Format: Paper format that uses to print out the PDF (report.paperformat) +2. Product Label: Product label image +3. Label Width: Width of the printed label image (in px) +4. Label Height: Height of the printed label image (in px) +5. Font Family: Font of the lot information +6. Font Size: Font size of the lot information (in px) +7. Line Spacing: Spacing between the lot information (in px) +8. Width Padding (Text): Horizontal position of the lot information (corresponding to the label) +9. Height Padding (Text): Vertical position of the lot information (corresponding to the label) +10. With QR Code: Print QR code on the label +11. QR Code Size: Size of the QR code. +12. Width Padding (QR Code): Horizontal position of QR code (corresponding to the label) +13. Height Padding (QR Code): Vertical position of QR code (corresponding to the label) +14. Label Width Margin: Horizontal margin between labels +15. Label Height Margin: Vertical margin between labels + Bug Tracker =========== diff --git a/product_label_template/__manifest__.py b/product_label_template/__manifest__.py index a9bba2b..a3ba8fe 100644 --- a/product_label_template/__manifest__.py +++ b/product_label_template/__manifest__.py @@ -7,10 +7,9 @@ "website": "https://www.quartile.co", "category": "Products", "license": "LGPL-3", - "depends": ["stock_lot_expiry_rpl", "mrp"], + "depends": ["mrp", "stock_lot_expiry_rpl"], "data": [ "security/ir.model.access.csv", - "reports/product_label_reports.xml", "views/product_label_template_views.xml", "views/product_product_views.xml", "views/templates.xml", diff --git a/product_label_template/readme/CONFIGURE.rst b/product_label_template/readme/CONFIGURE.rst new file mode 100644 index 0000000..c8e50d0 --- /dev/null +++ b/product_label_template/readme/CONFIGURE.rst @@ -0,0 +1,20 @@ +Go to *Manufacturing > Configuratioon > Product Label Templates*, and create/maintain +product templates there. + +Product Label Template settings: + +1. Paper Format: Paper format that uses to print out the PDF (report.paperformat) +2. Product Label: Product label image +3. Label Width: Width of the printed label image (in px) +4. Label Height: Height of the printed label image (in px) +5. Font Family: Font of the lot information +6. Font Size: Font size of the lot information (in px) +7. Line Spacing: Spacing between the lot information (in px) +8. Width Padding (Text): Horizontal position of the lot information (corresponding to the label) +9. Height Padding (Text): Vertical position of the lot information (corresponding to the label) +10. With QR Code: Print QR code on the label +11. QR Code Size: Size of the QR code. +12. Width Padding (QR Code): Horizontal position of QR code (corresponding to the label) +13. Height Padding (QR Code): Vertical position of QR code (corresponding to the label) +14. Label Width Margin: Horizontal margin between labels +15. Label Height Margin: Vertical margin between labels diff --git a/product_label_template/readme/DESCRIPTION.rst b/product_label_template/readme/DESCRIPTION.rst index 134e4ba..fc79592 100644 --- a/product_label_template/readme/DESCRIPTION.rst +++ b/product_label_template/readme/DESCRIPTION.rst @@ -1,4 +1,7 @@ -This module adds product label printing to delivery and manufacturing order. +This module provides the function to maintain the label template for each product. +The module does not provide the printing function by itself. The module is expected +to be used as a dependency of the modules for label printing (e.g. +mrp_production_product_label_print module). Product Label Template Settings Description diff --git a/product_label_template/reports/product_label_reports.xml b/product_label_template/reports/product_label_reports.xml deleted file mode 100644 index 7d8068b..0000000 --- a/product_label_template/reports/product_label_reports.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - diff --git a/product_label_template/static/description/index.html b/product_label_template/static/description/index.html index 5512dfb..a84f14b 100644 --- a/product_label_template/static/description/index.html +++ b/product_label_template/static/description/index.html @@ -368,7 +368,10 @@

Product Label Template

!! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: LGPL-3 qrtl/rpl-private

-

This module adds product label printing to delivery and manufacturing order.

+

This module provides the function to maintain the label template for each product. +The module does not provide the printing function by itself. The module is expected +to be used as a dependency of the modules for label printing (e.g. +mrp_production_product_label_print module).

Product Label Template Settings Description

  1. Paper Format: Paper format that uses to print out the PDF (report.paperformat)
  2. @@ -390,16 +393,40 @@

    Product Label Template

    Table of contents

    +
    +

    Configuration

    +

    Go to Manufacturing > Configuratioon > Product Label Templates, and create/maintain +product templates there.

    +

    Product Label Template settings:

    +
      +
    1. Paper Format: Paper format that uses to print out the PDF (report.paperformat)
    2. +
    3. Product Label: Product label image
    4. +
    5. Label Width: Width of the printed label image (in px)
    6. +
    7. Label Height: Height of the printed label image (in px)
    8. +
    9. Font Family: Font of the lot information
    10. +
    11. Font Size: Font size of the lot information (in px)
    12. +
    13. Line Spacing: Spacing between the lot information (in px)
    14. +
    15. Width Padding (Text): Horizontal position of the lot information (corresponding to the label)
    16. +
    17. Height Padding (Text): Vertical position of the lot information (corresponding to the label)
    18. +
    19. With QR Code: Print QR code on the label
    20. +
    21. QR Code Size: Size of the QR code.
    22. +
    23. Width Padding (QR Code): Horizontal position of QR code (corresponding to the label)
    24. +
    25. Height Padding (QR Code): Vertical position of QR code (corresponding to the label)
    26. +
    27. Label Width Margin: Horizontal margin between labels
    28. +
    29. Label Height Margin: Vertical margin between labels
    30. +
    +
    -

    Bug Tracker

    +

    Bug Tracker

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed @@ -407,15 +434,15 @@

    Bug Tracker

    Do not contact contributors directly about support or help with technical issues.

    -

    Credits

    +

    Credits

    -

    Authors

    +

    Authors

    • Quartile Limited
    -

    Maintainers

    +

    Maintainers

    This module is part of the qrtl/rpl-private project on GitHub.

    You are welcome to contribute.

    diff --git a/product_label_template/views/templates.xml b/product_label_template/views/templates.xml index 18b52e6..2d24500 100644 --- a/product_label_template/views/templates.xml +++ b/product_label_template/views/templates.xml @@ -1,25 +1,10 @@ - From e949113cbd329c590f0fe852ca9424b4b50c9c7a Mon Sep 17 00:00:00 2001 From: Tack Yabe <85266439+tack-yabeQuartile@users.noreply.github.com> Date: Tue, 19 Oct 2021 19:15:59 +0900 Subject: [PATCH 06/10] st1 [523][IMP] product_label_template; split text and display coefficient (#198) * split printing texts to locate independently of each other * display coefficient (environmental parameter) * pre-commit * normalize get_label_text_css() * tidy up codes and configure.rst Co-authored-by: Yoshi Tashiro --- product_label_template/README.rst | 17 ++---- .../models/product_label_template.py | 54 +++++++++++++------ product_label_template/readme/CONFIGURE.rst | 17 ++---- .../static/description/index.html | 17 ++---- .../views/product_label_template_views.xml | 36 ++++++++++--- product_label_template/views/templates.xml | 11 ++-- 6 files changed, 91 insertions(+), 61 deletions(-) diff --git a/product_label_template/README.rst b/product_label_template/README.rst index 28046cd..f464ed7 100644 --- a/product_label_template/README.rst +++ b/product_label_template/README.rst @@ -49,24 +49,17 @@ product templates there. Product Label Template settings: #. Paper Format: Paper format used to print the PDF with (report.paperformat) +#. Coefficient: Environment-depending parameter to adjust the input values to actual length. #. Product Label: Product label image #. Label Width: Width of the printed label image (in cm) #. Label Height: Height of the printed label image (in cm) #. Label Width Margin: Margin on the right side of the label (in cm) #. Label Height Margin: Margin at the bottom of the label (in cm) #. Font Family: Font applied to the printed texts -#. Font Size: Size of the font (in cm) -#. Line Spacing: Line spacing between the printed texts (in proportion to the font size) -#. Width Padding (Dates): Horizontal position of the texts from the left of the label (in cm) -#. Height Padding (Dates): Vertical position of the texts from the top of the label (in cm) -#. With QR Code: Indicates whether QR code should be printed on the label -#. QR Code Size: Size of the QR code (in cm) -#. Width Padding (QR Code): Horizontal position of the QR code from the left of the label (in cm) -#. Height Padding (QR Code): Vertical position of the QR code from the top of the label (in cm) -#. With GS1 Code: Indicates whether GS1 Data Matrix code should be printed on the label -#. GS1 Code Size: Size of the GS1 Data Matrix code (in cm) -#. Width Padding (GS1 Code): Horizontal position of the GS1 Data Matrix code from the left of the label (in cm) -#. Height Padding (GS1 Code): Vertical position of the GS1 Data Matrix code from the top of the label (in cm) +#. xxxx Size: Size of xxxx (in cm) +#. With xxxx: Indicates whether xxxx should be printed on the label. +#. Width Padding xxxx: Horizontal position of xxxx from the left of the label (in cm) +#. Height Padding xxxx: Vertical position of xxxx from the top of the label (in cm) Bug Tracker =========== diff --git a/product_label_template/models/product_label_template.py b/product_label_template/models/product_label_template.py index 7f3e3d7..83ee236 100644 --- a/product_label_template/models/product_label_template.py +++ b/product_label_template/models/product_label_template.py @@ -40,17 +40,33 @@ class ProductLabelTemplate(models.Model): help="Font applied to the printed texts", ) font_size = fields.Float(help="Size of the font (in cm)") - line_height = fields.Float( - "Line Spacing", - help="Line spacing between the printed texts (in proportion to the font size)", + width_padding_lot = fields.Float( + "Width Padding (Lot)", + oldname="width_padding", + help="Horizontal position of the lot from the left of the label (in cm)", ) - width_padding = fields.Float( - "Width Padding (Dates)", - help="Horizontal position of the texts from the left of the label (in cm)", + height_padding_lot = fields.Float( + "Height Padding (Lot)", + oldname="height_padding", + help="Vertical position of the lot from the top of the label (in cm)", ) - height_padding = fields.Float( - "Height Padding (Dates)", - help="Vertical position of the texts from the top of the label (in cm)", + # some products do not need to show production date on label. + with_prod_date = fields.Boolean("With production date") + width_padding_production_date = fields.Float( + "Width Padding (Prod. Date)", + help="Horizontal position of the prod. date from the left of the label (in cm)", + ) + height_padding_production_date = fields.Float( + "Height Padding (Prod. Date)", + help="Vertical position of the prod. date from the top of the label (in cm)", + ) + width_padding_expiry_date = fields.Float( + "Width Padding (Exp. Date)", + help="Horizontal position of the exp. date from the left of the label (in cm)", + ) + height_padding_expiry_date = fields.Float( + "Height Padding (Exp. Date)", + help="Vertical position of the exp. date from the top of the label (in cm)", ) with_qr_code = fields.Boolean("With QR Code") qr_code_size = fields.Float("QR Code Size", help="Size of the QR code (in cm)") @@ -78,15 +94,22 @@ class ProductLabelTemplate(models.Model): ) coefficient = fields.Float( "Conversion Coefficient", - compute="_compute_coefficient", + # compute="_compute_coefficient", + default=13.37, help="The coefficient to convert the parameter values from 'cm' to 'mm' " "taking the dpi setting into account.", ) + # 13.37 under 300 dpi was reported by one whose env. is MS windows and chrome. + # 38.55 under 300 dpi and 12.7 under 100 dpi was by Macintosh user. + """ + memo: In dev. env., dpi * 0.1285 is good value, but it is not so in other servers. def _compute_coefficient(self): for template in self: - # TODO How was '0.1285' calculated? + # '0.1285' was decided by updating label width moderately to paper size + # (wide=210mm) under left and right margins are 0 mm on dev. env. of qrtl. template.coefficient = template.paperformat_id.dpi * 0.1285 + """ def get_label_layout_css(self): self.ensure_one() @@ -109,15 +132,16 @@ def get_label_css(self): ] return ";".join(css_list) - def get_label_text_css(self): + def get_label_text_css(self, field_name): self.ensure_one() + width_padding_field = getattr(self, "width_padding_%s" % field_name) + height_padding_field = getattr(self, "height_padding_%s" % field_name) css_list = [ "position: absolute", "font-family: %s" % self.font_family, "font-size: %smm" % str(self.font_size * self.coefficient), - "line-height: %s" % self.line_height, - "left: %smm" % str(self.width_padding * self.coefficient), - "top: %smm" % str(self.height_padding * self.coefficient), + "left: %smm" % str(width_padding_field * self.coefficient), + "top: %smm" % str(height_padding_field * self.coefficient), ] return ";".join(css_list) diff --git a/product_label_template/readme/CONFIGURE.rst b/product_label_template/readme/CONFIGURE.rst index 671b174..4cfa168 100644 --- a/product_label_template/readme/CONFIGURE.rst +++ b/product_label_template/readme/CONFIGURE.rst @@ -4,21 +4,14 @@ product templates there. Product Label Template settings: #. Paper Format: Paper format used to print the PDF with (report.paperformat) +#. Coefficient: Environment-depending parameter to adjust the input values to actual length. #. Product Label: Product label image #. Label Width: Width of the printed label image (in cm) #. Label Height: Height of the printed label image (in cm) #. Label Width Margin: Margin on the right side of the label (in cm) #. Label Height Margin: Margin at the bottom of the label (in cm) #. Font Family: Font applied to the printed texts -#. Font Size: Size of the font (in cm) -#. Line Spacing: Line spacing between the printed texts (in proportion to the font size) -#. Width Padding (Dates): Horizontal position of the texts from the left of the label (in cm) -#. Height Padding (Dates): Vertical position of the texts from the top of the label (in cm) -#. With QR Code: Indicates whether QR code should be printed on the label -#. QR Code Size: Size of the QR code (in cm) -#. Width Padding (QR Code): Horizontal position of the QR code from the left of the label (in cm) -#. Height Padding (QR Code): Vertical position of the QR code from the top of the label (in cm) -#. With GS1 Code: Indicates whether GS1 Data Matrix code should be printed on the label -#. GS1 Code Size: Size of the GS1 Data Matrix code (in cm) -#. Width Padding (GS1 Code): Horizontal position of the GS1 Data Matrix code from the left of the label (in cm) -#. Height Padding (GS1 Code): Vertical position of the GS1 Data Matrix code from the top of the label (in cm) +#. xxxx Size: Size of xxxx (in cm) +#. With xxxx: Indicates whether xxxx should be printed on the label. +#. Width Padding xxxx: Horizontal position of xxxx from the left of the label (in cm) +#. Height Padding xxxx: Vertical position of xxxx from the top of the label (in cm) diff --git a/product_label_template/static/description/index.html b/product_label_template/static/description/index.html index 2e3ee5a..f791c12 100644 --- a/product_label_template/static/description/index.html +++ b/product_label_template/static/description/index.html @@ -406,24 +406,17 @@

    Configuration

    Product Label Template settings:

    1. Paper Format: Paper format used to print the PDF with (report.paperformat)
    2. +
    3. Coefficient: Environment-depending parameter to adjust the input values to actual length.
    4. Product Label: Product label image
    5. Label Width: Width of the printed label image (in cm)
    6. Label Height: Height of the printed label image (in cm)
    7. Label Width Margin: Margin on the right side of the label (in cm)
    8. Label Height Margin: Margin at the bottom of the label (in cm)
    9. Font Family: Font applied to the printed texts
    10. -
    11. Font Size: Size of the font (in cm)
    12. -
    13. Line Spacing: Line spacing between the printed texts (in proportion to the font size)
    14. -
    15. Width Padding (Dates): Horizontal position of the texts from the left of the label (in cm)
    16. -
    17. Height Padding (Dates): Vertical position of the texts from the top of the label (in cm)
    18. -
    19. With QR Code: Indicates whether QR code should be printed on the label
    20. -
    21. QR Code Size: Size of the QR code (in cm)
    22. -
    23. Width Padding (QR Code): Horizontal position of the QR code from the left of the label (in cm)
    24. -
    25. Height Padding (QR Code): Vertical position of the QR code from the top of the label (in cm)
    26. -
    27. With GS1 Code: Indicates whether GS1 Data Matrix code should be printed on the label
    28. -
    29. GS1 Code Size: Size of the GS1 Data Matrix code (in cm)
    30. -
    31. Width Padding (GS1 Code): Horizontal position of the GS1 Data Matrix code from the left of the label (in cm)
    32. -
    33. Height Padding (GS1 Code): Vertical position of the GS1 Data Matrix code from the top of the label (in cm)
    34. +
    35. xxxx Size: Size of xxxx (in cm)
    36. +
    37. With xxxx: Indicates whether xxxx should be printed on the label.
    38. +
    39. Width Padding xxxx: Horizontal position of xxxx from the left of the label (in cm)
    40. +
    41. Height Padding xxxx: Vertical position of xxxx from the top of the label (in cm)
    diff --git a/product_label_template/views/product_label_template_views.xml b/product_label_template/views/product_label_template_views.xml index 3bdf98a..5e9bf7a 100644 --- a/product_label_template/views/product_label_template_views.xml +++ b/product_label_template/views/product_label_template_views.xml @@ -10,6 +10,7 @@ + @@ -23,12 +24,22 @@ - + - - - + + + + + + + + - - - + + + + + + +
    -
    +
    -
    +
    +
    -
    +
    +
    Date: Tue, 9 Nov 2021 10:43:35 +0900 Subject: [PATCH 07/10] st1 [523][IMP] mrp_production_product_label_print, product_label_template; print only QRs (#199) * print only QRs but those may overlap each other (hourly commit) * add a function of individual qr code printing * make UI better, add filter setting with an error * upgrade UI * add paperformat for QR-print update translation unify some items etc. * get paperformat from label template record * update translation * adjust default value of coefficient Co-authored-by: Yoshi Tashiro --- product_label_template/README.rst | 14 +- product_label_template/__manifest__.py | 3 +- product_label_template/i18n/ja.po | 196 +++++++++++++----- product_label_template/models/__init__.py | 1 + .../models/ir_actions_report.py | 53 +++++ .../models/product_label_template.py | 47 ++++- product_label_template/readme/CONFIGURE.rst | 5 +- product_label_template/readme/DESCRIPTION.rst | 9 +- .../static/description/index.html | 14 +- .../views/ir_actions_report_views.xml | 17 ++ .../views/product_label_template_views.xml | 58 ++++-- .../views/product_product_views.xml | 6 +- product_label_template/views/templates.xml | 16 +- 13 files changed, 329 insertions(+), 110 deletions(-) create mode 100644 product_label_template/models/ir_actions_report.py create mode 100644 product_label_template/views/ir_actions_report_views.xml diff --git a/product_label_template/README.rst b/product_label_template/README.rst index f464ed7..2f225d5 100644 --- a/product_label_template/README.rst +++ b/product_label_template/README.rst @@ -16,10 +16,11 @@ Product Label Template |badge1| |badge2| -This module provides the function to maintain the label template for each product. -The module does not provide the print action per se. The module is expected to be used -as a dependency of the modules for label printing (e.g. -mrp_production_product_label_print module). +This module provides the function to maintain the label template +and parameters of individual QR printing for each product. +The module does not provide the print action per se. +The module is expected to be used as a dependency of the modules for printing. +(e.g.mrp_production_product_label_print module). **Table of contents** @@ -53,9 +54,8 @@ Product Label Template settings: #. Product Label: Product label image #. Label Width: Width of the printed label image (in cm) #. Label Height: Height of the printed label image (in cm) -#. Label Width Margin: Margin on the right side of the label (in cm) -#. Label Height Margin: Margin at the bottom of the label (in cm) -#. Font Family: Font applied to the printed texts +#. xxxx Width Margin: Margin on the right side of xxxx (in cm) +#. xxxx Height Margin: Margin at the bottom of xxxx (in cm) #. xxxx Size: Size of xxxx (in cm) #. With xxxx: Indicates whether xxxx should be printed on the label. #. Width Padding xxxx: Horizontal position of xxxx from the left of the label (in cm) diff --git a/product_label_template/__manifest__.py b/product_label_template/__manifest__.py index 30a9399..df6ee06 100644 --- a/product_label_template/__manifest__.py +++ b/product_label_template/__manifest__.py @@ -1,7 +1,7 @@ # Copyright 2021 Quartile Limited { "name": "Product Label Template", - "version": "12.0.1.0.0", + "version": "12.0.1.1.0", "author": "Quartile Limited", "website": "https://www.quartile.co", "category": "Products", @@ -10,6 +10,7 @@ "external_dependencies": {"python": ["treepoem"]}, "data": [ "security/ir.model.access.csv", + "views/ir_actions_report_views.xml", "views/product_label_template_views.xml", "views/product_product_views.xml", "views/templates.xml", diff --git a/product_label_template/i18n/ja.po b/product_label_template/i18n/ja.po index 7c62c6d..7778e05 100644 --- a/product_label_template/i18n/ja.po +++ b/product_label_template/i18n/ja.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-10-02 15:32+0000\n" -"PO-Revision-Date: 2021-10-02 15:32+0000\n" +"POT-Creation-Date: 2021-11-07 15:00+0000\n" +"PO-Revision-Date: 2021-11-07 15:00+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,14 +16,9 @@ msgstr "" "Plural-Forms: \n" #. module: product_label_template -#: selection:product.label.template,font_family:0 -msgid "Arial" -msgstr "" - -#. module: product_label_template -#: selection:product.label.template,font_family:0 -msgid "Calibri" -msgstr "" +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__attribute_value_ids +msgid "Attribute Values" +msgstr "属性値" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__coefficient @@ -40,31 +35,16 @@ msgstr "作成者" msgid "Created on" msgstr "作成日" -#. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form -msgid "Dates" -msgstr "日付" - #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__display_name msgid "Display Name" msgstr "表示名" -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__font_family -msgid "Font Family" -msgstr "フォント" - #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__font_size msgid "Font Size" msgstr "フォントサイズ" -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__font_family -msgid "Font applied to the printed texts" -msgstr "表示テキストに適用されるフォント" - #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__gs1_code_size msgid "GS1 Code Size" @@ -91,25 +71,40 @@ msgid "Group By" msgstr "グループ化" #. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__height_padding -msgid "Height Padding (Dates)" -msgstr "高さパディング(日付)" +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__height_padding_expiry_date +msgid "Height Padding (Exp. Date)" +msgstr "期限日の位置(縦)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__gs1_code_height_padding msgid "Height Padding (GS1)" -msgstr "高さパディング(GS1)" +msgstr "GS1画像位置(縦)" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__height_padding_lot +msgid "Height Padding (Lot)" +msgstr "ロット位置(縦)" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__height_padding_production_date +msgid "Height Padding (Prod. Date)" +msgstr "製造日の位置(縦)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_height_padding msgid "Height Padding (QR)" -msgstr "高さパディング(QR)" +msgstr "QR位置(縦)" #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__label_height msgid "Height of the printed label image (in cm)" msgstr "印刷されるラベル画像の高さ(cm)" +#. module: product_label_template +#: model:ir.model.fields,help:product_label_template.field_product_label_template__qr_code_width_margin +msgid "Horizontal margin between the QR codes (in cm)" +msgstr "別刷りQRコードの横方向の表示間隔(cm)" + #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__gs1_code_width_padding msgid "Horizontal position of the GS1 Data Matrix code from the left of the label (in cm)" @@ -121,15 +116,30 @@ msgid "Horizontal position of the QR code from the left of the label (in cm)" msgstr "ラベル左端からのQRコード表示位置(cm)" #. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__width_padding -msgid "Horizontal position of the texts from the left of the label (in cm)" -msgstr "ラベル左端からのテキスト表示位置(cm)" +#: model:ir.model.fields,help:product_label_template.field_product_label_template__width_padding_expiry_date +msgid "Horizontal position of the exp. date from the left of the label (in cm)" +msgstr "ラベル左端からの使用期限日の表示位置(cm)" + +#. module: product_label_template +#: model:ir.model.fields,help:product_label_template.field_product_label_template__width_padding_lot +msgid "Horizontal position of the lot from the left of the label (in cm)" +msgstr "ラベル左端からのロットの表示位置(cm)" + +#. module: product_label_template +#: model:ir.model.fields,help:product_label_template.field_product_label_template__width_padding_production_date +msgid "Horizontal position of the prod. date from the left of the label (in cm)" +msgstr "ラベル左端からの製造日の表示位置(cm)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__id msgid "ID" msgstr "" +#. module: product_label_template +#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form +msgid "Individual QR Code Printing" +msgstr "QRコード単独印刷時の設定" + #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_height msgid "Label Height" @@ -138,7 +148,7 @@ msgstr "ラベル高さ" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_height_margin msgid "Label Height Margin" -msgstr "ラベル高さマージン" +msgstr "ラベル同士の間隔(縦)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_image @@ -164,7 +174,7 @@ msgstr "ラベル幅" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_width_margin msgid "Label Width Margin" -msgstr "ラベル幅マージン" +msgstr "ラベル同士の間隔(横)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template____last_update @@ -182,20 +192,20 @@ msgid "Last Updated on" msgstr "最終更新日" #. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__line_height -msgid "Line Spacing" -msgstr "行間隔" - -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__line_height -msgid "Line spacing between the printed texts (in proportion to the font size)" -msgstr "表示テキストの行間隔(フォントサイズ比)" +#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form +msgid "Lot Information" +msgstr "ロット情報" #. module: product_label_template #: model:ir.model,name:product_label_template.model_stock_production_lot msgid "Lot/Serial" msgstr "ロット/シリアル" +#. module: product_label_template +#: selection:ir.actions.report,plt_paperformat_type:0 +msgid "Main" +msgstr "メイン" + #. module: product_label_template #: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form msgid "Main Attributes" @@ -204,18 +214,28 @@ msgstr "基本属性" #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__label_height_margin msgid "Margin at the bottom of the label (in cm)" -msgstr "ラベル下部のマージン(cm)" +msgstr "ラベル下部の余白(cm)" #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__label_width_margin msgid "Margin on the right side of the label (in cm)" -msgstr "ラベル右側のマージン(cm)" +msgstr "ラベル右側の余白(cm)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__paperformat_id msgid "Paper Format" msgstr "用紙" +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_paperformat_id +msgid "Paper Format (QR)" +msgstr "用紙(QR)" + +#. module: product_label_template +#: model:ir.model.fields,help:product_label_template.field_product_label_template__qr_paperformat_id +msgid "Paper format used to print only QR codes." +msgstr "QRコード単独印刷で使用される用紙" + #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__paperformat_id msgid "Paper format used to print the PDF with" @@ -233,6 +253,11 @@ msgstr "プロダクト" msgid "Product Label Template" msgstr "プロダクトラベルテンプレート" +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_ir_actions_report__plt_paperformat_type +msgid "Product Label Template Paperformat Type" +msgstr "プロダクトラベルテンプレート用紙タイプ" + #. module: product_label_template #: model:ir.actions.act_window,name:product_label_template.product_label_template_action #: model:ir.ui.menu,name:product_label_template.menu_product_label_template @@ -252,6 +277,11 @@ msgstr "プロダクトラベル" msgid "Product Template" msgstr "プロダクトテンプレート" +#. module: product_label_template +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_search_view +msgid "Product variant attribute" +msgstr "製品属性" + #. module: product_label_template #: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form msgid "QR Code" @@ -262,6 +292,26 @@ msgstr "QRコード" msgid "QR Code Size" msgstr "QRコードサイズ" +#. module: product_label_template +#: selection:ir.actions.report,plt_paperformat_type:0 +msgid "QR Only" +msgstr "QRコードのみ" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_height_margin +msgid "Qr Code Height Margin" +msgstr "QR同士の間隔(縦)" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_width_margin +msgid "Qr Code Width Margin" +msgstr "QR同士の間隔(横)" + +#. module: product_label_template +#: model:ir.model,name:product_label_template.model_ir_actions_report +msgid "Report Action" +msgstr "レポートアクション" + #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__gs1_code_size msgid "Size of the GS1 Data Matrix code (in cm)" @@ -282,6 +332,16 @@ msgstr "フォントのサイズ(cm)" msgid "The coefficient to convert the parameter values from 'cm' to 'mm' taking the dpi setting into account." msgstr "パラメタ値の「cm」から「mm」への換算係数(DPIを加味)" +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_ir_actions_report__use_plt_paperformat +msgid "Use Product Label Template Paperformat" +msgstr "プロダクトラベルテンプレートの用紙設定を使用" + +#. module: product_label_template +#: model:ir.model.fields,help:product_label_template.field_product_label_template__qr_code_height_margin +msgid "Vertical margin between the QR codes (in cm)" +msgstr "別刷り時の縦方向のQRコード表示間隔(cm)" + #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__gs1_code_height_padding msgid "Vertical position of the GS1 Data Matrix code from the top of the label (in cm)" @@ -293,24 +353,44 @@ msgid "Vertical position of the QR code from the top of the label (in cm)" msgstr "ラベル上端からのQRコード表示位置(cm)" #. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__height_padding -msgid "Vertical position of the texts from the top of the label (in cm)" -msgstr "ラベル上端からのテキスト表示位置(cm)" +#: model:ir.model.fields,help:product_label_template.field_product_label_template__height_padding_expiry_date +msgid "Vertical position of the exp. date from the top of the label (in cm)" +msgstr "ラベル上端からの使用期限日表示位置(cm)" + +#. module: product_label_template +#: model:ir.model.fields,help:product_label_template.field_product_label_template__height_padding_lot +msgid "Vertical position of the lot from the top of the label (in cm)" +msgstr "ラベル上端からのロット表示位置(cm)" + +#. module: product_label_template +#: model:ir.model.fields,help:product_label_template.field_product_label_template__height_padding_production_date +msgid "Vertical position of the prod. date from the top of the label (in cm)" +msgstr "ラベル上端からの製造日表示位置(cm)" #. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__width_padding -msgid "Width Padding (Dates)" -msgstr "幅パディング(日付)" +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__width_padding_expiry_date +msgid "Width Padding (Exp. Date)" +msgstr "期限日の位置(横)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__gs1_code_width_padding msgid "Width Padding (GS1)" -msgstr "幅パディング(GS1)" +msgstr "GS1画像位置(横)" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__width_padding_lot +msgid "Width Padding (Lot)" +msgstr "ロット位置(横)" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__width_padding_production_date +msgid "Width Padding (Prod. Date)" +msgstr "製造日の位置(横)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_width_padding msgid "Width Padding (QR)" -msgstr "幅パディング(QR)" +msgstr "QR位置(横)" #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__label_width @@ -322,11 +402,21 @@ msgstr "印刷されるラベル画像の幅(cm)" msgid "With GS1 Code" msgstr "GS1コード表示" +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__with_individual_qr_code +msgid "With Individual QR Code" +msgstr "QRコードを単独で印刷" + #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__with_qr_code msgid "With QR Code" msgstr "QRコード表示" +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__with_prod_date +msgid "With production date" +msgstr "製造日表示" + #. module: product_label_template #: model:ir.model,name:product_label_template.model_report_product_label_template_product_label_reports msgid "report.product_label_template.product_label_reports" diff --git a/product_label_template/models/__init__.py b/product_label_template/models/__init__.py index 30fe519..0ccd069 100644 --- a/product_label_template/models/__init__.py +++ b/product_label_template/models/__init__.py @@ -1,3 +1,4 @@ +from . import ir_actions_report from . import product_label_template from . import product_product from . import stock_production_lot diff --git a/product_label_template/models/ir_actions_report.py b/product_label_template/models/ir_actions_report.py new file mode 100644 index 0000000..d069bd9 --- /dev/null +++ b/product_label_template/models/ir_actions_report.py @@ -0,0 +1,53 @@ +# Copyright 2021 Quartile Limited + +from odoo import api, fields, models + + +class IrActionsReport(models.Model): + _inherit = "ir.actions.report" + + use_plt_paperformat = fields.Boolean("Use Product Label Template Paperformat") + plt_paperformat_type = fields.Selection( + selection=[("main", "Main"), ("qr", "QR Only")], + string="Product Label Template Paperformat Type", + ) + + @api.model + def get_paperformat(self): + if self._context.get("plt_paperformat"): + return self._context.get("plt_paperformat") + return super().get_paperformat() + + @api.model + def _get_product_for_active_rec(self, active_rec): + """This method is expected to be extended by modules with the print function.""" + return False + + @api.model + def _get_plt_paperformat(self, res_ids, plt_paperformat_type): + """Return the paperformat from the relevant product label template.""" + active_rec = self.env[self.model].browse(res_ids)[:1] + if not active_rec: + return False + product = self._get_product_for_active_rec(active_rec) + if not product: + return False + plt_rec = self.env["product.label.template"].search( + [("product_id", "=", product.id)] + )[:1] + if not plt_rec: + return False + if plt_paperformat_type == "main": + return plt_rec.paperformat_id + if plt_paperformat_type == "qr": + return plt_rec.qr_paperformat_id + + @api.multi + def render_qweb_pdf(self, res_ids=None, data=None): + if self.use_plt_paperformat and self.plt_paperformat_type: + plt_paperformat = self._get_plt_paperformat( + res_ids, self.plt_paperformat_type + ) + if plt_paperformat: + self = self.with_context(plt_paperformat=plt_paperformat) + return super().render_qweb_pdf(res_ids=res_ids, data=data) diff --git a/product_label_template/models/product_label_template.py b/product_label_template/models/product_label_template.py index 83ee236..83ad2a1 100644 --- a/product_label_template/models/product_label_template.py +++ b/product_label_template/models/product_label_template.py @@ -16,6 +16,7 @@ class ProductLabelTemplate(models.Model): _description = "Product Label Template" product_id = fields.Many2one("product.product", required=True) + attribute_value_ids = fields.Many2many(related="product_id.attribute_value_ids") product_tmpl_id = fields.Many2one(related="product_id.product_tmpl_id", store=True) paperformat_id = fields.Many2one( "report.paperformat", @@ -23,6 +24,11 @@ class ProductLabelTemplate(models.Model): required=True, help="Paper format used to print the PDF with", ) + qr_paperformat_id = fields.Many2one( + "report.paperformat", + "Paper Format (QR)", + help="Paper format used to print only QR codes.", + ) label_image = fields.Binary(attachment=True) label_width = fields.Float(help="Width of the printed label image (in cm)") label_height = fields.Float(help="Height of the printed label image (in cm)") @@ -31,6 +37,11 @@ class ProductLabelTemplate(models.Model): help="Margin on the right side of the label (in cm)" ) label_height_margin = fields.Float(help="Margin at the bottom of the label (in cm)") + + """ + NOTE: parameter of font_family has used to select font, + but latest requirement is limited to Arial font. + Codes below would be a good example to use this function again. # When adding a new font, you add ("string for CSS", "display name") # The string for CSS can be checked with `fc-list | awk -F ":" '{print $2}'` font_family = fields.Selection( @@ -39,6 +50,7 @@ class ProductLabelTemplate(models.Model): required=True, help="Font applied to the printed texts", ) + """ font_size = fields.Float(help="Size of the font (in cm)") width_padding_lot = fields.Float( "Width Padding (Lot)", @@ -68,6 +80,7 @@ class ProductLabelTemplate(models.Model): "Height Padding (Exp. Date)", help="Vertical position of the exp. date from the top of the label (in cm)", ) + with_qr_code = fields.Boolean("With QR Code") qr_code_size = fields.Float("QR Code Size", help="Size of the QR code (in cm)") qr_code_width_padding = fields.Float( @@ -78,6 +91,15 @@ class ProductLabelTemplate(models.Model): "Height Padding (QR)", help="Vertical position of the QR code from the top of the label (in cm)", ) + + with_individual_qr_code = fields.Boolean("With Individual QR Code") + qr_code_width_margin = fields.Float( + help="Horizontal margin between the QR codes (in cm)" + ) + qr_code_height_margin = fields.Float( + help="Vertical margin between the QR codes (in cm)" + ) + with_gs1_code = fields.Boolean("With GS1 Code") gs1_code_size = fields.Float( "GS1 Code Size", help="Size of the GS1 Data Matrix code (in cm)" @@ -95,15 +117,15 @@ class ProductLabelTemplate(models.Model): coefficient = fields.Float( "Conversion Coefficient", # compute="_compute_coefficient", - default=13.37, + default=38.55, help="The coefficient to convert the parameter values from 'cm' to 'mm' " "taking the dpi setting into account.", ) - # 13.37 under 300 dpi was reported by one whose env. is MS windows and chrome. - # 38.55 under 300 dpi and 12.7 under 100 dpi was by Macintosh user. """ - memo: In dev. env., dpi * 0.1285 is good value, but it is not so in other servers. + NOTE: dpi * 0.1285 is good value in dev. env., but it is not so in other servers. + # 13.37 under 300 dpi was reported by one whose env. is MS windows and chrome. + # 38.55 under 300 dpi and 12.7 under 100 dpi was by Macintosh user. def _compute_coefficient(self): for template in self: # '0.1285' was decided by updating label width moderately to paper size @@ -111,13 +133,15 @@ def _compute_coefficient(self): template.coefficient = template.paperformat_id.dpi * 0.1285 """ - def get_label_layout_css(self): + def get_label_layout_css(self, field_name): self.ensure_one() + width_margin_field = getattr(self, "%s_width_margin" % field_name) + height_margin_field = getattr(self, "%s_height_margin" % field_name) # margin-top and margin-left will be given by report.paperformat css_list = [ "display: inline-table", - "margin-bottom: %smm" % str(self.label_height_margin * self.coefficient), - "margin-right: %smm" % str(self.label_width_margin * self.coefficient), + "margin-bottom: %smm" % str(height_margin_field * self.coefficient), + "margin-right: %smm" % str(width_margin_field * self.coefficient), ] return ";".join(css_list) @@ -138,17 +162,20 @@ def get_label_text_css(self, field_name): height_padding_field = getattr(self, "height_padding_%s" % field_name) css_list = [ "position: absolute", - "font-family: %s" % self.font_family, + "font-family: Arial", "font-size: %smm" % str(self.font_size * self.coefficient), "left: %smm" % str(width_padding_field * self.coefficient), "top: %smm" % str(height_padding_field * self.coefficient), ] return ";".join(css_list) - def get_qr_code_css(self): + def get_qr_code_css(self, qr_only=False): self.ensure_one() css_list = [ - "position: absolute", + # When qr_only is true, there is no parent element and in that case + # 'relative' should be applied for the position attribute to avoid the + # overlap of the images. + "position: %s" % ("relative" if qr_only else "absolute"), "left: %smm" % str(self.qr_code_width_padding * self.coefficient), "top: %smm" % str(self.qr_code_height_padding * self.coefficient), "width: %smm" % str(self.qr_code_size * self.coefficient), diff --git a/product_label_template/readme/CONFIGURE.rst b/product_label_template/readme/CONFIGURE.rst index 4cfa168..1f7659b 100644 --- a/product_label_template/readme/CONFIGURE.rst +++ b/product_label_template/readme/CONFIGURE.rst @@ -8,9 +8,8 @@ Product Label Template settings: #. Product Label: Product label image #. Label Width: Width of the printed label image (in cm) #. Label Height: Height of the printed label image (in cm) -#. Label Width Margin: Margin on the right side of the label (in cm) -#. Label Height Margin: Margin at the bottom of the label (in cm) -#. Font Family: Font applied to the printed texts +#. xxxx Width Margin: Margin on the right side of xxxx (in cm) +#. xxxx Height Margin: Margin at the bottom of xxxx (in cm) #. xxxx Size: Size of xxxx (in cm) #. With xxxx: Indicates whether xxxx should be printed on the label. #. Width Padding xxxx: Horizontal position of xxxx from the left of the label (in cm) diff --git a/product_label_template/readme/DESCRIPTION.rst b/product_label_template/readme/DESCRIPTION.rst index 61cb2fb..fd56b6a 100644 --- a/product_label_template/readme/DESCRIPTION.rst +++ b/product_label_template/readme/DESCRIPTION.rst @@ -1,4 +1,5 @@ -This module provides the function to maintain the label template for each product. -The module does not provide the print action per se. The module is expected to be used -as a dependency of the modules for label printing (e.g. -mrp_production_product_label_print module). +This module provides the function to maintain the label template +and parameters of individual QR printing for each product. +The module does not provide the print action per se. +The module is expected to be used as a dependency of the modules for printing. +(e.g.mrp_production_product_label_print module). diff --git a/product_label_template/static/description/index.html b/product_label_template/static/description/index.html index f791c12..f4b847b 100644 --- a/product_label_template/static/description/index.html +++ b/product_label_template/static/description/index.html @@ -368,10 +368,11 @@

    Product Label Template

    !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

    Beta qrtl/rpl-private

    -

    This module provides the function to maintain the label template for each product. -The module does not provide the print action per se. The module is expected to be used -as a dependency of the modules for label printing (e.g. -mrp_production_product_label_print module).

    +

    This module provides the function to maintain the label template +and parameters of individual QR printing for each product. +The module does not provide the print action per se. +The module is expected to be used as a dependency of the modules for printing. +(e.g.mrp_production_product_label_print module).

    Table of contents

      @@ -410,9 +411,8 @@

      Configuration

    • Product Label: Product label image
    • Label Width: Width of the printed label image (in cm)
    • Label Height: Height of the printed label image (in cm)
    • -
    • Label Width Margin: Margin on the right side of the label (in cm)
    • -
    • Label Height Margin: Margin at the bottom of the label (in cm)
    • -
    • Font Family: Font applied to the printed texts
    • +
    • xxxx Width Margin: Margin on the right side of xxxx (in cm)
    • +
    • xxxx Height Margin: Margin at the bottom of xxxx (in cm)
    • xxxx Size: Size of xxxx (in cm)
    • With xxxx: Indicates whether xxxx should be printed on the label.
    • Width Padding xxxx: Horizontal position of xxxx from the left of the label (in cm)
    • diff --git a/product_label_template/views/ir_actions_report_views.xml b/product_label_template/views/ir_actions_report_views.xml new file mode 100644 index 0000000..e230e6c --- /dev/null +++ b/product_label_template/views/ir_actions_report_views.xml @@ -0,0 +1,17 @@ + + + + ir.actions.report + ir.actions.report + + + + + + + + + diff --git a/product_label_template/views/product_label_template_views.xml b/product_label_template/views/product_label_template_views.xml index 5e9bf7a..5a27d68 100644 --- a/product_label_template/views/product_label_template_views.xml +++ b/product_label_template/views/product_label_template_views.xml @@ -9,6 +9,7 @@ + @@ -19,13 +20,19 @@ - + + - @@ -41,6 +48,18 @@ + + + + + + + - - - + + + - - - - - - @@ -132,6 +134,15 @@ context="{'group_by':'product_tmpl_id'}" /> + + + + @@ -141,6 +152,7 @@ product.label.template tree,form form + {'search_default_by_product_template': 1} + - + diff --git a/product_label_template/views/templates.xml b/product_label_template/views/templates.xml index edc0ad6..79ce1f1 100644 --- a/product_label_template/views/templates.xml +++ b/product_label_template/views/templates.xml @@ -1,7 +1,10 @@ + From 68d2dcb9fb915a7b64c5865f23ca8ef36de89ef2 Mon Sep 17 00:00:00 2001 From: Tack Yabe <85266439+tack-yabeQuartile@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:12:27 +0900 Subject: [PATCH 08/10] st1 [523][FIX] product_label_template;attach required options (#204) * attach required options * adjust get_label_css --- product_label_template/models/product_label_template.py | 2 +- .../views/product_label_template_views.xml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/product_label_template/models/product_label_template.py b/product_label_template/models/product_label_template.py index 83ad2a1..25e5d40 100644 --- a/product_label_template/models/product_label_template.py +++ b/product_label_template/models/product_label_template.py @@ -149,7 +149,7 @@ def get_label_css(self): self.ensure_one() css_list = [ "position: relative", - "background-image: url('%s')" % image_data_uri(self.label_image), + "background-image: url('%s')" % image_data_uri(self.label_image or b""), "height: %smm" % str(self.label_height * self.coefficient), "width: %smm" % str(self.label_width * self.coefficient), "background-size: cover", diff --git a/product_label_template/views/product_label_template_views.xml b/product_label_template/views/product_label_template_views.xml index 5a27d68..ba53e5f 100644 --- a/product_label_template/views/product_label_template_views.xml +++ b/product_label_template/views/product_label_template_views.xml @@ -52,7 +52,10 @@ string="Individual QR Code Printing" attrs="{'invisible': [('with_individual_qr_code','=',False)]}" > - + Date: Wed, 15 Jul 2026 06:32:38 +0000 Subject: [PATCH 09/10] [MIG] product_label_template: migrate to 18.0 Migrate the module from 12.0 to 18.0 with a minimal scope for RBKK: - rename stock.production.lot -> stock.lot and update the report / paperformat overrides to the 18.0 API (_render_qweb_pdf, get_paperformat) - drop the RPL-specific dependencies and features that do not exist on 18.0: the expiry/production date and GS1 datamatrix handling coming from stock_lot_expiry_rpl / stock_lot_serial and the treepoem library - add a "Product Label" print action bound to stock.lot so the label can be printed from Lot/Serial Numbers > Print (the 12.0 module relied on a separate print module that is not part of RBKK) - convert views to the 18.0 list / attribute syntax and relicense to LGPL-3 Co-Authored-By: Claude Opus 4.8 (1M context) --- product_label_template/README.rst | 102 +++---- product_label_template/__manifest__.py | 17 +- product_label_template/i18n/ja.po | 248 ++++-------------- product_label_template/models/__init__.py | 3 +- .../models/ir_actions_report.py | 38 +-- .../models/product_label_template.py | 131 ++------- .../models/product_product.py | 4 +- .../models/stock_production_lot.py | 49 ---- product_label_template/pyproject.toml | 3 + product_label_template/readme/CONFIGURE.md | 18 ++ product_label_template/readme/CONFIGURE.rst | 16 -- product_label_template/readme/CONTRIBUTORS.md | 4 + product_label_template/readme/DESCRIPTION.md | 7 + product_label_template/readme/DESCRIPTION.rst | 5 - product_label_template/readme/INSTALL.rst | 10 - product_label_template/readme/USAGE.md | 3 + .../reports/product_label_report.xml | 49 ++++ .../static/description/index.html | 103 ++++---- .../views/ir_actions_report_views.xml | 6 +- .../views/product_label_template_views.xml | 100 ++----- .../views/product_product_views.xml | 56 ++-- .../views/stock_production_lot_views.xml | 23 -- product_label_template/views/templates.xml | 54 ---- 23 files changed, 358 insertions(+), 691 deletions(-) delete mode 100644 product_label_template/models/stock_production_lot.py create mode 100644 product_label_template/pyproject.toml create mode 100644 product_label_template/readme/CONFIGURE.md delete mode 100644 product_label_template/readme/CONFIGURE.rst create mode 100644 product_label_template/readme/CONTRIBUTORS.md create mode 100644 product_label_template/readme/DESCRIPTION.md delete mode 100644 product_label_template/readme/DESCRIPTION.rst delete mode 100644 product_label_template/readme/INSTALL.rst create mode 100644 product_label_template/readme/USAGE.md create mode 100644 product_label_template/reports/product_label_report.xml delete mode 100644 product_label_template/views/stock_production_lot_views.xml delete mode 100644 product_label_template/views/templates.xml diff --git a/product_label_template/README.rst b/product_label_template/README.rst index 2f225d5..10ac58c 100644 --- a/product_label_template/README.rst +++ b/product_label_template/README.rst @@ -2,72 +2,77 @@ Product Label Template ====================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:37967c3a58ed4093e61d3671bc5b4803181c903a2c5dca201b9bce8467b703c9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/github-qrtl%2Frpl--private-lightgray.png?logo=github - :target: https://github.com/qrtl/rpl-private/tree/12.0/product_label_template - :alt: qrtl/rpl-private +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-Quartile%2Frbkk--custom-lightgray.png?logo=github + :target: https://github.com/Quartile/rbkk-custom/tree/18.0/plt_mig_full + :alt: Quartile/rbkk-custom + +|badge1| |badge2| |badge3| -|badge1| |badge2| +This module lets you define, per product, a label template that +positions the lot/serial number and a QR code at exact coordinates over +a label background image. -This module provides the function to maintain the label template -and parameters of individual QR printing for each product. -The module does not provide the print action per se. -The module is expected to be used as a dependency of the modules for printing. -(e.g.mrp_production_product_label_print module). +It adds a **Product Label** print action to lots/serial numbers, so the +label can be printed from the standard *Lot/Serial Numbers > Print* +menu, using the paper format configured on the product's label template. **Table of contents** .. contents:: :local: -Installation -============ - -This module uses the 'treepoem' Python library for printing two-dimentional Data Matrix -code, which depends on 'ghostscript':: - - sudo pip install treepoem - apt-get install ghostscript - -To add fonts to the server:: - - sudo apt install ttf-mscorefonts-installer - sudo fc-cache -f - Configuration ============= -Go to *Manufacturing > Configuratioon > Product Label Templates*, and create/maintain -product templates there. +Go to *Inventory > Configuration > Products > Product Label Templates* +and create/maintain a template per product. The template can also be +maintained from the *Label Templates* tab of the product variant form. Product Label Template settings: -#. Paper Format: Paper format used to print the PDF with (report.paperformat) -#. Coefficient: Environment-depending parameter to adjust the input values to actual length. -#. Product Label: Product label image -#. Label Width: Width of the printed label image (in cm) -#. Label Height: Height of the printed label image (in cm) -#. xxxx Width Margin: Margin on the right side of xxxx (in cm) -#. xxxx Height Margin: Margin at the bottom of xxxx (in cm) -#. xxxx Size: Size of xxxx (in cm) -#. With xxxx: Indicates whether xxxx should be printed on the label. -#. Width Padding xxxx: Horizontal position of xxxx from the left of the label (in cm) -#. Height Padding xxxx: Vertical position of xxxx from the top of the label (in cm) +- **Paper Format**: paper format used to print the PDF with. +- **Conversion Coefficient**: environment-dependent parameter to + convert the input values (cm) to the actual printed length, taking + the dpi setting into account. +- **Product Label**: label background image. +- **Label Width / Label Height**: size of the printed label image (in + cm). +- **Label Width/Height Margin**: margins on the right/bottom of the + label (in cm). +- **Font Size**: size of the printed text (in cm). +- **Width/Height Padding (Lot)**: position of the lot/serial number + from the left/top of the label (in cm). +- **With QR Code**: whether a QR code (of the lot/serial number) is + printed, with its own size and left/top position. + +Usage +===== + +Go to *Inventory > Products > Lots/Serial Numbers*, select one or more +lots/serial numbers, then use *Print > Product Label*. The label is +rendered from the label template configured on each lot's product. Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -75,13 +80,22 @@ Credits ======= Authors -~~~~~~~ +------- + +* Quartile + +Contributors +------------ + +- `Quartile `__: -* Quartile Limited + - Tim + - Yoshi Tashiro + - Tack Yabe Maintainers -~~~~~~~~~~~ +----------- -This module is part of the `qrtl/rpl-private `_ project on GitHub. +This module is part of the `Quartile/rbkk-custom `_ project on GitHub. You are welcome to contribute. diff --git a/product_label_template/__manifest__.py b/product_label_template/__manifest__.py index df6ee06..c88c88d 100644 --- a/product_label_template/__manifest__.py +++ b/product_label_template/__manifest__.py @@ -1,20 +1,19 @@ -# Copyright 2021 Quartile Limited +# Copyright 2021 Quartile (https://www.quartile.co) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). { "name": "Product Label Template", - "version": "12.0.1.1.0", - "author": "Quartile Limited", + "version": "18.0.1.0.0", + "author": "Quartile", "website": "https://www.quartile.co", - "category": "Products", - "license": "Other proprietary", - "depends": ["stock_lot_expiry_rpl", "stock_lot_serial"], - "external_dependencies": {"python": ["treepoem"]}, + "category": "Inventory", + "license": "LGPL-3", + "depends": ["stock"], "data": [ "security/ir.model.access.csv", "views/ir_actions_report_views.xml", "views/product_label_template_views.xml", "views/product_product_views.xml", - "views/templates.xml", - "views/stock_production_lot_views.xml", + "reports/product_label_report.xml", ], "installable": True, } diff --git a/product_label_template/i18n/ja.po b/product_label_template/i18n/ja.po index 7778e05..cf43fcb 100644 --- a/product_label_template/i18n/ja.po +++ b/product_label_template/i18n/ja.po @@ -1,22 +1,28 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * product_label_template +# * product_label_template # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0+e\n" +"Project-Id-Version: Odoo Server 18.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-11-07 15:00+0000\n" -"PO-Revision-Date: 2021-11-07 15:00+0000\n" -"Last-Translator: <>\n" +"POT-Creation-Date: 2026-07-15 06:20+0000\n" +"PO-Revision-Date: 2026-07-15 06:20+0000\n" +"Last-Translator: \n" "Language-Team: \n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: \n" +"Plural-Forms: nplurals=1; plural=0;\n" #. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__attribute_value_ids +#: model:ir.actions.report,print_report_name:product_label_template.action_report_product_label +msgid "'Product Label - %s' % object.name" +msgstr "" + +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__product_template_attribute_value_ids msgid "Attribute Values" msgstr "属性値" @@ -46,50 +52,15 @@ msgid "Font Size" msgstr "フォントサイズ" #. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__gs1_code_size -msgid "GS1 Code Size" -msgstr "GS1コードサイズ" - -#. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form -msgid "GS1 Datamatrix" -msgstr "GS1データマトリックス" - -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_stock_production_lot__gs1_image -msgid "GS1 Image" -msgstr "GS1画像" - -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_stock_production_lot__gs1_string -msgid "GS1 String" -msgstr "GS1ストリング" - -#. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_search_view +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_view_search msgid "Group By" msgstr "グループ化" -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__height_padding_expiry_date -msgid "Height Padding (Exp. Date)" -msgstr "期限日の位置(縦)" - -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__gs1_code_height_padding -msgid "Height Padding (GS1)" -msgstr "GS1画像位置(縦)" - #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__height_padding_lot msgid "Height Padding (Lot)" msgstr "ロット位置(縦)" -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__height_padding_production_date -msgid "Height Padding (Prod. Date)" -msgstr "製造日の位置(縦)" - #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_height_padding msgid "Height Padding (QR)" @@ -100,45 +71,20 @@ msgstr "QR位置(縦)" msgid "Height of the printed label image (in cm)" msgstr "印刷されるラベル画像の高さ(cm)" -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__qr_code_width_margin -msgid "Horizontal margin between the QR codes (in cm)" -msgstr "別刷りQRコードの横方向の表示間隔(cm)" - -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__gs1_code_width_padding -msgid "Horizontal position of the GS1 Data Matrix code from the left of the label (in cm)" -msgstr "ラベル左端からのGS1データマトリックスコード表示位置(cm)" - #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__qr_code_width_padding msgid "Horizontal position of the QR code from the left of the label (in cm)" -msgstr "ラベル左端からのQRコード表示位置(cm)" - -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__width_padding_expiry_date -msgid "Horizontal position of the exp. date from the left of the label (in cm)" -msgstr "ラベル左端からの使用期限日の表示位置(cm)" +msgstr "ラベル左端からのQRコードの水平位置(cm)" #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__width_padding_lot msgid "Horizontal position of the lot from the left of the label (in cm)" -msgstr "ラベル左端からのロットの表示位置(cm)" - -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__width_padding_production_date -msgid "Horizontal position of the prod. date from the left of the label (in cm)" -msgstr "ラベル左端からの製造日の表示位置(cm)" +msgstr "ラベル左端からのロットの水平位置(cm)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__id msgid "ID" -msgstr "" - -#. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form -msgid "Individual QR Code Printing" -msgstr "QRコード単独印刷時の設定" +msgstr "ID" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__label_height @@ -161,8 +107,8 @@ msgid "Label Ratio" msgstr "ラベル縦横比" #. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_tree_view -#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_form_label_template +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_view_list +#: model_terms:ir.ui.view,arch_db:product_label_template.product_normal_view_form msgid "Label Templates" msgstr "ラベルテンプレート" @@ -176,11 +122,6 @@ msgstr "ラベル幅" msgid "Label Width Margin" msgstr "ラベル同士の間隔(横)" -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template____last_update -msgid "Last Modified on" -msgstr "最終更新日" - #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__write_uid msgid "Last Updated by" @@ -192,24 +133,19 @@ msgid "Last Updated on" msgstr "最終更新日" #. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_view_form msgid "Lot Information" msgstr "ロット情報" #. module: product_label_template -#: model:ir.model,name:product_label_template.model_stock_production_lot -msgid "Lot/Serial" -msgstr "ロット/シリアル" - -#. module: product_label_template -#: selection:ir.actions.report,plt_paperformat_type:0 +#: model:ir.model.fields.selection,name:product_label_template.selection__ir_actions_report__plt_paperformat_type__main msgid "Main" msgstr "メイン" #. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_view_form msgid "Main Attributes" -msgstr "基本属性" +msgstr "主要属性" #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__label_height_margin @@ -224,29 +160,23 @@ msgstr "ラベル右側の余白(cm)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__paperformat_id msgid "Paper Format" -msgstr "用紙" - -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_paperformat_id -msgid "Paper Format (QR)" -msgstr "用紙(QR)" - -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__qr_paperformat_id -msgid "Paper format used to print only QR codes." -msgstr "QRコード単独印刷で使用される用紙" +msgstr "用紙フォーマット" #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__paperformat_id msgid "Paper format used to print the PDF with" -msgstr "PDF印刷に使用する用紙" +msgstr "PDF印刷に使用する用紙フォーマット" #. module: product_label_template -#: model:ir.model,name:product_label_template.model_product_product #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__product_id msgid "Product" msgstr "プロダクト" +#. module: product_label_template +#: model:ir.actions.report,name:product_label_template.action_report_product_label +msgid "Product Label" +msgstr "プロダクトラベル" + #. module: product_label_template #: model:ir.model,name:product_label_template.model_product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_product__product_label_template_ids @@ -256,34 +186,39 @@ msgstr "プロダクトラベルテンプレート" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_ir_actions_report__plt_paperformat_type msgid "Product Label Template Paperformat Type" -msgstr "プロダクトラベルテンプレート用紙タイプ" +msgstr "プロダクトラベルテンプレート用紙フォーマット種別" #. module: product_label_template #: model:ir.actions.act_window,name:product_label_template.product_label_template_action #: model:ir.ui.menu,name:product_label_template.menu_product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_search_view -#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_view_form +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_view_search msgid "Product Label Templates" msgstr "プロダクトラベルテンプレート" #. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_form_label_template +#: model_terms:ir.ui.view,arch_db:product_label_template.product_normal_view_form msgid "Product Labels" msgstr "プロダクトラベル" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__product_tmpl_id -#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_search_view +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_view_search msgid "Product Template" msgstr "プロダクトテンプレート" #. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_search_view +#: model:ir.model,name:product_label_template.model_product_product +msgid "Product Variant" +msgstr "プロダクトバリアント" + +#. module: product_label_template +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_view_search msgid "Product variant attribute" -msgstr "製品属性" +msgstr "プロダクトバリアント属性" #. module: product_label_template -#: model_terms:ir.ui.view,arch_db:product_label_template.view_product_label_template_form +#: model_terms:ir.ui.view,arch_db:product_label_template.product_label_template_view_form msgid "QR Code" msgstr "QRコード" @@ -292,31 +227,11 @@ msgstr "QRコード" msgid "QR Code Size" msgstr "QRコードサイズ" -#. module: product_label_template -#: selection:ir.actions.report,plt_paperformat_type:0 -msgid "QR Only" -msgstr "QRコードのみ" - -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_height_margin -msgid "Qr Code Height Margin" -msgstr "QR同士の間隔(縦)" - -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_width_margin -msgid "Qr Code Width Margin" -msgstr "QR同士の間隔(横)" - #. module: product_label_template #: model:ir.model,name:product_label_template.model_ir_actions_report msgid "Report Action" msgstr "レポートアクション" -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__gs1_code_size -msgid "Size of the GS1 Data Matrix code (in cm)" -msgstr "GS1データマトリックスコードのサイズ(cm)" - #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__qr_code_size msgid "Size of the QR code (in cm)" @@ -327,66 +242,40 @@ msgstr "QRコードのサイズ(cm)" msgid "Size of the font (in cm)" msgstr "フォントのサイズ(cm)" +#. module: product_label_template +#: model:ir.model.fields,field_description:product_label_template.field_ir_actions_report__smart_search +#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__smart_search +#: model:ir.model.fields,field_description:product_label_template.field_product_product__smart_search +msgid "Smart Search" +msgstr "スマート検索" + #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__coefficient -msgid "The coefficient to convert the parameter values from 'cm' to 'mm' taking the dpi setting into account." -msgstr "パラメタ値の「cm」から「mm」への換算係数(DPIを加味)" +msgid "" +"The coefficient to convert the parameter values from 'cm' to 'mm' taking the" +" dpi setting into account." +msgstr "" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_ir_actions_report__use_plt_paperformat msgid "Use Product Label Template Paperformat" -msgstr "プロダクトラベルテンプレートの用紙設定を使用" - -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__qr_code_height_margin -msgid "Vertical margin between the QR codes (in cm)" -msgstr "別刷り時の縦方向のQRコード表示間隔(cm)" - -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__gs1_code_height_padding -msgid "Vertical position of the GS1 Data Matrix code from the top of the label (in cm)" -msgstr "ラベル上端からのGS1データマトリックスコード表示位置(cm)" +msgstr "プロダクトラベルテンプレートの用紙フォーマットを使用" #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__qr_code_height_padding msgid "Vertical position of the QR code from the top of the label (in cm)" -msgstr "ラベル上端からのQRコード表示位置(cm)" - -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__height_padding_expiry_date -msgid "Vertical position of the exp. date from the top of the label (in cm)" -msgstr "ラベル上端からの使用期限日表示位置(cm)" +msgstr "ラベル上端からのQRコードの垂直位置(cm)" #. module: product_label_template #: model:ir.model.fields,help:product_label_template.field_product_label_template__height_padding_lot msgid "Vertical position of the lot from the top of the label (in cm)" -msgstr "ラベル上端からのロット表示位置(cm)" - -#. module: product_label_template -#: model:ir.model.fields,help:product_label_template.field_product_label_template__height_padding_production_date -msgid "Vertical position of the prod. date from the top of the label (in cm)" -msgstr "ラベル上端からの製造日表示位置(cm)" - -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__width_padding_expiry_date -msgid "Width Padding (Exp. Date)" -msgstr "期限日の位置(横)" - -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__gs1_code_width_padding -msgid "Width Padding (GS1)" -msgstr "GS1画像位置(横)" +msgstr "ラベル上端からのロットの垂直位置(cm)" #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__width_padding_lot msgid "Width Padding (Lot)" msgstr "ロット位置(横)" -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__width_padding_production_date -msgid "Width Padding (Prod. Date)" -msgstr "製造日の位置(横)" - #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__qr_code_width_padding msgid "Width Padding (QR)" @@ -397,28 +286,7 @@ msgstr "QR位置(横)" msgid "Width of the printed label image (in cm)" msgstr "印刷されるラベル画像の幅(cm)" -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__with_gs1_code -msgid "With GS1 Code" -msgstr "GS1コード表示" - -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__with_individual_qr_code -msgid "With Individual QR Code" -msgstr "QRコードを単独で印刷" - #. module: product_label_template #: model:ir.model.fields,field_description:product_label_template.field_product_label_template__with_qr_code msgid "With QR Code" -msgstr "QRコード表示" - -#. module: product_label_template -#: model:ir.model.fields,field_description:product_label_template.field_product_label_template__with_prod_date -msgid "With production date" -msgstr "製造日表示" - -#. module: product_label_template -#: model:ir.model,name:product_label_template.model_report_product_label_template_product_label_reports -msgid "report.product_label_template.product_label_reports" -msgstr "" - +msgstr "QRコードを印刷" diff --git a/product_label_template/models/__init__.py b/product_label_template/models/__init__.py index 0ccd069..e670ad7 100644 --- a/product_label_template/models/__init__.py +++ b/product_label_template/models/__init__.py @@ -1,4 +1,3 @@ -from . import ir_actions_report from . import product_label_template from . import product_product -from . import stock_production_lot +from . import ir_actions_report diff --git a/product_label_template/models/ir_actions_report.py b/product_label_template/models/ir_actions_report.py index d069bd9..d5ad243 100644 --- a/product_label_template/models/ir_actions_report.py +++ b/product_label_template/models/ir_actions_report.py @@ -1,4 +1,5 @@ -# Copyright 2021 Quartile Limited +# Copyright 2021 Quartile (https://www.quartile.co) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). from odoo import api, fields, models @@ -8,22 +9,25 @@ class IrActionsReport(models.Model): use_plt_paperformat = fields.Boolean("Use Product Label Template Paperformat") plt_paperformat_type = fields.Selection( - selection=[("main", "Main"), ("qr", "QR Only")], + selection=[("main", "Main")], string="Product Label Template Paperformat Type", ) - @api.model def get_paperformat(self): - if self._context.get("plt_paperformat"): - return self._context.get("plt_paperformat") + if self.use_plt_paperformat and self.env.context.get("plt_paperformat"): + return self.env.context.get("plt_paperformat") return super().get_paperformat() @api.model def _get_product_for_active_rec(self, active_rec): - """This method is expected to be extended by modules with the print function.""" + """Return the product used to look up the product label template. + + Extend this method to support models other than ``stock.lot``. + """ + if active_rec._name == "stock.lot": + return active_rec.product_id return False - @api.model def _get_plt_paperformat(self, res_ids, plt_paperformat_type): """Return the paperformat from the relevant product label template.""" active_rec = self.env[self.model].browse(res_ids)[:1] @@ -33,21 +37,19 @@ def _get_plt_paperformat(self, res_ids, plt_paperformat_type): if not product: return False plt_rec = self.env["product.label.template"].search( - [("product_id", "=", product.id)] - )[:1] + [("product_id", "=", product.id)], limit=1 + ) if not plt_rec: return False if plt_paperformat_type == "main": return plt_rec.paperformat_id - if plt_paperformat_type == "qr": - return plt_rec.qr_paperformat_id - - @api.multi - def render_qweb_pdf(self, res_ids=None, data=None): - if self.use_plt_paperformat and self.plt_paperformat_type: - plt_paperformat = self._get_plt_paperformat( - res_ids, self.plt_paperformat_type + + def _render_qweb_pdf(self, report_ref, res_ids=None, data=None): + report = self._get_report(report_ref) + if report.use_plt_paperformat and report.plt_paperformat_type: + plt_paperformat = report._get_plt_paperformat( + res_ids, report.plt_paperformat_type ) if plt_paperformat: self = self.with_context(plt_paperformat=plt_paperformat) - return super().render_qweb_pdf(res_ids=res_ids, data=data) + return super()._render_qweb_pdf(report_ref, res_ids=res_ids, data=data) diff --git a/product_label_template/models/product_label_template.py b/product_label_template/models/product_label_template.py index 25e5d40..12f718f 100644 --- a/product_label_template/models/product_label_template.py +++ b/product_label_template/models/product_label_template.py @@ -1,5 +1,5 @@ -# Copyright 2021 Quartile Limited -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +# Copyright 2021 Quartile (https://www.quartile.co) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). import base64 import io @@ -16,7 +16,9 @@ class ProductLabelTemplate(models.Model): _description = "Product Label Template" product_id = fields.Many2one("product.product", required=True) - attribute_value_ids = fields.Many2many(related="product_id.attribute_value_ids") + product_template_attribute_value_ids = fields.Many2many( + related="product_id.product_template_attribute_value_ids" + ) product_tmpl_id = fields.Many2one(related="product_id.product_tmpl_id", store=True) paperformat_id = fields.Many2one( "report.paperformat", @@ -24,11 +26,6 @@ class ProductLabelTemplate(models.Model): required=True, help="Paper format used to print the PDF with", ) - qr_paperformat_id = fields.Many2one( - "report.paperformat", - "Paper Format (QR)", - help="Paper format used to print only QR codes.", - ) label_image = fields.Binary(attachment=True) label_width = fields.Float(help="Width of the printed label image (in cm)") label_height = fields.Float(help="Height of the printed label image (in cm)") @@ -37,50 +34,15 @@ class ProductLabelTemplate(models.Model): help="Margin on the right side of the label (in cm)" ) label_height_margin = fields.Float(help="Margin at the bottom of the label (in cm)") - - """ - NOTE: parameter of font_family has used to select font, - but latest requirement is limited to Arial font. - Codes below would be a good example to use this function again. - # When adding a new font, you add ("string for CSS", "display name") - # The string for CSS can be checked with `fc-list | awk -F ":" '{print $2}'` - font_family = fields.Selection( - [("Arial", "Arial"), ("Calibri", "Calibri")], - default="Arial", - required=True, - help="Font applied to the printed texts", - ) - """ font_size = fields.Float(help="Size of the font (in cm)") width_padding_lot = fields.Float( "Width Padding (Lot)", - oldname="width_padding", help="Horizontal position of the lot from the left of the label (in cm)", ) height_padding_lot = fields.Float( "Height Padding (Lot)", - oldname="height_padding", help="Vertical position of the lot from the top of the label (in cm)", ) - # some products do not need to show production date on label. - with_prod_date = fields.Boolean("With production date") - width_padding_production_date = fields.Float( - "Width Padding (Prod. Date)", - help="Horizontal position of the prod. date from the left of the label (in cm)", - ) - height_padding_production_date = fields.Float( - "Height Padding (Prod. Date)", - help="Vertical position of the prod. date from the top of the label (in cm)", - ) - width_padding_expiry_date = fields.Float( - "Width Padding (Exp. Date)", - help="Horizontal position of the exp. date from the left of the label (in cm)", - ) - height_padding_expiry_date = fields.Float( - "Height Padding (Exp. Date)", - help="Vertical position of the exp. date from the top of the label (in cm)", - ) - with_qr_code = fields.Boolean("With QR Code") qr_code_size = fields.Float("QR Code Size", help="Size of the QR code (in cm)") qr_code_width_padding = fields.Float( @@ -91,57 +53,22 @@ class ProductLabelTemplate(models.Model): "Height Padding (QR)", help="Vertical position of the QR code from the top of the label (in cm)", ) - - with_individual_qr_code = fields.Boolean("With Individual QR Code") - qr_code_width_margin = fields.Float( - help="Horizontal margin between the QR codes (in cm)" - ) - qr_code_height_margin = fields.Float( - help="Vertical margin between the QR codes (in cm)" - ) - - with_gs1_code = fields.Boolean("With GS1 Code") - gs1_code_size = fields.Float( - "GS1 Code Size", help="Size of the GS1 Data Matrix code (in cm)" - ) - gs1_code_width_padding = fields.Float( - "Width Padding (GS1)", - help="Horizontal position of the GS1 Data Matrix code from the left of the " - "label (in cm)", - ) - gs1_code_height_padding = fields.Float( - "Height Padding (GS1)", - help="Vertical position of the GS1 Data Matrix code from the top of the label " - "(in cm)", - ) coefficient = fields.Float( "Conversion Coefficient", - # compute="_compute_coefficient", default=38.55, help="The coefficient to convert the parameter values from 'cm' to 'mm' " "taking the dpi setting into account.", ) - """ - NOTE: dpi * 0.1285 is good value in dev. env., but it is not so in other servers. - # 13.37 under 300 dpi was reported by one whose env. is MS windows and chrome. - # 38.55 under 300 dpi and 12.7 under 100 dpi was by Macintosh user. - def _compute_coefficient(self): - for template in self: - # '0.1285' was decided by updating label width moderately to paper size - # (wide=210mm) under left and right margins are 0 mm on dev. env. of qrtl. - template.coefficient = template.paperformat_id.dpi * 0.1285 - """ - def get_label_layout_css(self, field_name): self.ensure_one() - width_margin_field = getattr(self, "%s_width_margin" % field_name) - height_margin_field = getattr(self, "%s_height_margin" % field_name) + width_margin_field = getattr(self, f"{field_name}_width_margin") + height_margin_field = getattr(self, f"{field_name}_height_margin") # margin-top and margin-left will be given by report.paperformat css_list = [ "display: inline-table", - "margin-bottom: %smm" % str(height_margin_field * self.coefficient), - "margin-right: %smm" % str(width_margin_field * self.coefficient), + f"margin-bottom: {height_margin_field * self.coefficient}mm", + f"margin-right: {width_margin_field * self.coefficient}mm", ] return ";".join(css_list) @@ -149,48 +76,34 @@ def get_label_css(self): self.ensure_one() css_list = [ "position: relative", - "background-image: url('%s')" % image_data_uri(self.label_image or b""), - "height: %smm" % str(self.label_height * self.coefficient), - "width: %smm" % str(self.label_width * self.coefficient), + f"background-image: url('{image_data_uri(self.label_image or b'')}')", + f"height: {self.label_height * self.coefficient}mm", + f"width: {self.label_width * self.coefficient}mm", "background-size: cover", ] return ";".join(css_list) def get_label_text_css(self, field_name): self.ensure_one() - width_padding_field = getattr(self, "width_padding_%s" % field_name) - height_padding_field = getattr(self, "height_padding_%s" % field_name) + width_padding_field = getattr(self, f"width_padding_{field_name}") + height_padding_field = getattr(self, f"height_padding_{field_name}") css_list = [ "position: absolute", "font-family: Arial", - "font-size: %smm" % str(self.font_size * self.coefficient), - "left: %smm" % str(width_padding_field * self.coefficient), - "top: %smm" % str(height_padding_field * self.coefficient), - ] - return ";".join(css_list) - - def get_qr_code_css(self, qr_only=False): - self.ensure_one() - css_list = [ - # When qr_only is true, there is no parent element and in that case - # 'relative' should be applied for the position attribute to avoid the - # overlap of the images. - "position: %s" % ("relative" if qr_only else "absolute"), - "left: %smm" % str(self.qr_code_width_padding * self.coefficient), - "top: %smm" % str(self.qr_code_height_padding * self.coefficient), - "width: %smm" % str(self.qr_code_size * self.coefficient), - "height: %smm" % str(self.qr_code_size * self.coefficient), + f"font-size: {self.font_size * self.coefficient}mm", + f"left: {width_padding_field * self.coefficient}mm", + f"top: {height_padding_field * self.coefficient}mm", ] return ";".join(css_list) - def get_gs1_code_css(self): + def get_qr_code_css(self): self.ensure_one() css_list = [ "position: absolute", - "left: %smm" % str(self.gs1_code_width_padding * self.coefficient), - "top: %smm" % str(self.gs1_code_height_padding * self.coefficient), - "width: %smm" % str(self.gs1_code_size * self.coefficient), - "height: %smm" % str(self.gs1_code_size * self.coefficient), + f"left: {self.qr_code_width_padding * self.coefficient}mm", + f"top: {self.qr_code_height_padding * self.coefficient}mm", + f"width: {self.qr_code_size * self.coefficient}mm", + f"height: {self.qr_code_size * self.coefficient}mm", ] return ";".join(css_list) diff --git a/product_label_template/models/product_product.py b/product_label_template/models/product_product.py index f2eb118..cf475c9 100644 --- a/product_label_template/models/product_product.py +++ b/product_label_template/models/product_product.py @@ -1,5 +1,5 @@ -# Copyright 2021 Quartile Limited -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +# Copyright 2021 Quartile (https://www.quartile.co) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). from odoo import fields, models diff --git a/product_label_template/models/stock_production_lot.py b/product_label_template/models/stock_production_lot.py deleted file mode 100644 index c7623bb..0000000 --- a/product_label_template/models/stock_production_lot.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2019-2021 Quartile Limited - -import base64 -from io import BytesIO - -import treepoem - -from odoo import api, fields, models - - -class StockProductionLot(models.Model): - _inherit = "stock.production.lot" - - gs1_string = fields.Char("GS1 String", compute="_compute_gs1_string", store=True) - gs1_image = fields.Binary( - "GS1 Image", compute="_compute_gs1_image", store=True, attachment=True - ) - - @api.depends("product_id.barcode", "ref", "date_produced", "expiry_date") - def _compute_gs1_string(self): - """See 2-2 GS1-element-strings (under #2-Encoding-data) in following document. - https://www.gs1.org/standards/gs1-datamatrix-guideline/25 - """ - for rec in self: - if all( - [rec.product_id.barcode, rec.ref, rec.date_produced, rec.expiry_date] - ): - rec.gs1_string = ( - "(01)%s" % rec.product_id.barcode - + "(10)%s" % rec.ref - + "(11)%s" % str(rec.date_produced) - + "(17)%s" % str(rec.expiry_date) - ) - - @api.depends("gs1_string") - def _compute_gs1_image(self): - for rec in self: - if rec.gs1_string: - image = treepoem.generate_barcode( - barcode_type="datamatrix", data=rec.gs1_string - ).convert( - "1" - ) # .convert("1") means monochrome output. - # Buffer the value with BytesIO() and get the image string from there. - # Keeping PIL image itself in the binary field doesn't let Odoo render - # the image when it's called in printing. - buffered = BytesIO() - image.save(buffered, format="PNG") - rec.gs1_image = base64.b64encode(buffered.getvalue()) diff --git a/product_label_template/pyproject.toml b/product_label_template/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/product_label_template/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_label_template/readme/CONFIGURE.md b/product_label_template/readme/CONFIGURE.md new file mode 100644 index 0000000..3c54824 --- /dev/null +++ b/product_label_template/readme/CONFIGURE.md @@ -0,0 +1,18 @@ +Go to *Inventory > Configuration > Products > Product Label Templates* and +create/maintain a template per product. The template can also be maintained from +the *Label Templates* tab of the product variant form. + +Product Label Template settings: + +- **Paper Format**: paper format used to print the PDF with. +- **Conversion Coefficient**: environment-dependent parameter to convert the + input values (cm) to the actual printed length, taking the dpi setting into + account. +- **Product Label**: label background image. +- **Label Width / Label Height**: size of the printed label image (in cm). +- **Label Width/Height Margin**: margins on the right/bottom of the label (in cm). +- **Font Size**: size of the printed text (in cm). +- **Width/Height Padding (Lot)**: position of the lot/serial number from the + left/top of the label (in cm). +- **With QR Code**: whether a QR code (of the lot/serial number) is printed, with + its own size and left/top position. diff --git a/product_label_template/readme/CONFIGURE.rst b/product_label_template/readme/CONFIGURE.rst deleted file mode 100644 index 1f7659b..0000000 --- a/product_label_template/readme/CONFIGURE.rst +++ /dev/null @@ -1,16 +0,0 @@ -Go to *Manufacturing > Configuratioon > Product Label Templates*, and create/maintain -product templates there. - -Product Label Template settings: - -#. Paper Format: Paper format used to print the PDF with (report.paperformat) -#. Coefficient: Environment-depending parameter to adjust the input values to actual length. -#. Product Label: Product label image -#. Label Width: Width of the printed label image (in cm) -#. Label Height: Height of the printed label image (in cm) -#. xxxx Width Margin: Margin on the right side of xxxx (in cm) -#. xxxx Height Margin: Margin at the bottom of xxxx (in cm) -#. xxxx Size: Size of xxxx (in cm) -#. With xxxx: Indicates whether xxxx should be printed on the label. -#. Width Padding xxxx: Horizontal position of xxxx from the left of the label (in cm) -#. Height Padding xxxx: Vertical position of xxxx from the top of the label (in cm) diff --git a/product_label_template/readme/CONTRIBUTORS.md b/product_label_template/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..5105ad1 --- /dev/null +++ b/product_label_template/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- [Quartile](https://www.quartile.co): + - Tim + - Yoshi Tashiro + - Tack Yabe diff --git a/product_label_template/readme/DESCRIPTION.md b/product_label_template/readme/DESCRIPTION.md new file mode 100644 index 0000000..b9b2af9 --- /dev/null +++ b/product_label_template/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +This module lets you define, per product, a label template that positions the +lot/serial number and a QR code at exact coordinates over a label background +image. + +It adds a **Product Label** print action to lots/serial numbers, so the label can +be printed from the standard *Lot/Serial Numbers > Print* menu, using the paper +format configured on the product's label template. diff --git a/product_label_template/readme/DESCRIPTION.rst b/product_label_template/readme/DESCRIPTION.rst deleted file mode 100644 index fd56b6a..0000000 --- a/product_label_template/readme/DESCRIPTION.rst +++ /dev/null @@ -1,5 +0,0 @@ -This module provides the function to maintain the label template -and parameters of individual QR printing for each product. -The module does not provide the print action per se. -The module is expected to be used as a dependency of the modules for printing. -(e.g.mrp_production_product_label_print module). diff --git a/product_label_template/readme/INSTALL.rst b/product_label_template/readme/INSTALL.rst deleted file mode 100644 index 5168c1a..0000000 --- a/product_label_template/readme/INSTALL.rst +++ /dev/null @@ -1,10 +0,0 @@ -This module uses the 'treepoem' Python library for printing two-dimentional Data Matrix -code, which depends on 'ghostscript':: - - sudo pip install treepoem - apt-get install ghostscript - -To add fonts to the server:: - - sudo apt install ttf-mscorefonts-installer - sudo fc-cache -f diff --git a/product_label_template/readme/USAGE.md b/product_label_template/readme/USAGE.md new file mode 100644 index 0000000..ddca5b2 --- /dev/null +++ b/product_label_template/readme/USAGE.md @@ -0,0 +1,3 @@ +Go to *Inventory > Products > Lots/Serial Numbers*, select one or more +lots/serial numbers, then use *Print > Product Label*. The label is rendered from +the label template configured on each lot's product. diff --git a/product_label_template/reports/product_label_report.xml b/product_label_template/reports/product_label_report.xml new file mode 100644 index 0000000..56167a9 --- /dev/null +++ b/product_label_template/reports/product_label_report.xml @@ -0,0 +1,49 @@ + + + + + + + + Product Label + stock.lot + qweb-pdf + product_label_template.report_product_label + product_label_template.report_product_label + True + main + 'Product Label - %s' % object.name + + report + + diff --git a/product_label_template/static/description/index.html b/product_label_template/static/description/index.html index f4b847b..cb32c80 100644 --- a/product_label_template/static/description/index.html +++ b/product_label_template/static/description/index.html @@ -3,7 +3,7 @@ - + Product Label Template