diff --git a/sale_order_line_product_attribute_report/README.rst b/sale_order_line_product_attribute_report/README.rst new file mode 100644 index 000000000..700b60af3 --- /dev/null +++ b/sale_order_line_product_attribute_report/README.rst @@ -0,0 +1,30 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================================== +sale order line product attribute report +======================================== + +* In sale order, and sale order line new report "Sale line products attributes". +* For the line to be printed it must have one of these attributes: + "Bottom Graphic", "Top Graphic", "TALLA", "SHAPE". + +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 smash it by providing detailed and welcomed feedback. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Contributors +------------ + +* Ana Juaristi +* Alfredo de la Fuente \ No newline at end of file diff --git a/sale_order_line_product_attribute_report/__init__.py b/sale_order_line_product_attribute_report/__init__.py new file mode 100644 index 000000000..cd4bd41dd --- /dev/null +++ b/sale_order_line_product_attribute_report/__init__.py @@ -0,0 +1,2 @@ +from . import models +from .init_hook import pre_init_hook diff --git a/sale_order_line_product_attribute_report/__manifest__.py b/sale_order_line_product_attribute_report/__manifest__.py new file mode 100644 index 000000000..97dbd776c --- /dev/null +++ b/sale_order_line_product_attribute_report/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2025 Alfredo de la Fuente - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Sale Order Line Product Attribute Report", + "version": "12.0.1.0.0", + "category": "Sales", + "license": "AGPL-3", + "author": "AvanzOSC", + "website": "https://github.com/avanzosc/sale-addons", + "depends": [ + "sale", + "product_attribute_value_image" + ], + "data": [ + "data/layouts.xml", + "data/sale_order_line_product_attribute_report.xml", + "reports/sale_order_line_product_attribute_report.xml", + "views/sale_order_views.xml", + "views/sale_order_line_views.xml", + ], + "installable": True, + "pre_init_hook": "pre_init_hook", +} diff --git a/sale_order_line_product_attribute_report/_common.py b/sale_order_line_product_attribute_report/_common.py new file mode 100644 index 000000000..75266d9a0 --- /dev/null +++ b/sale_order_line_product_attribute_report/_common.py @@ -0,0 +1,13 @@ +# Copyright 2025 Alfredo de la Fuente - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + + +def _catch_top_bottom_graphic_info(sale_line): + top_graphic = "ZZZZZ" + bottom_graphic = "ZZZZZ" + for description_line in sale_line.name.split('\n'): + if description_line.startswith(f"Top Graphic"): + top_graphic = description_line.split(":", 1)[1].strip() + if description_line.startswith(f"Bottom Graphic"): + bottom_graphic = description_line.split(":", 1)[1].strip() + return top_graphic, bottom_graphic diff --git a/sale_order_line_product_attribute_report/data/layouts.xml b/sale_order_line_product_attribute_report/data/layouts.xml new file mode 100644 index 000000000..b4edb84ea --- /dev/null +++ b/sale_order_line_product_attribute_report/data/layouts.xml @@ -0,0 +1,26 @@ + + + + + + diff --git a/sale_order_line_product_attribute_report/data/sale_order_line_product_attribute_report.xml b/sale_order_line_product_attribute_report/data/sale_order_line_product_attribute_report.xml new file mode 100644 index 000000000..aad29e200 --- /dev/null +++ b/sale_order_line_product_attribute_report/data/sale_order_line_product_attribute_report.xml @@ -0,0 +1,18 @@ + + + + Sale line products attributes + + A4 + 0 + 0 + Portrait + 0 + 0 + 0 + 0 + + 00 + 90 + + diff --git a/sale_order_line_product_attribute_report/i18n/en_US.po b/sale_order_line_product_attribute_report/i18n/en_US.po new file mode 100644 index 000000000..c625a4b98 --- /dev/null +++ b/sale_order_line_product_attribute_report/i18n/en_US.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_order_line_product_attribute_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-05-15 08:23+0000\n" +"PO-Revision-Date: 2025-05-15 08:23+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: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__bottom_graphic +msgid "Botton Graphic" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__quantities_shapes +msgid "Quantities & Shapes" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.actions.report,name:sale_order_line_product_attribute_report.report_sale_line_product_attribute_report +#: model:ir.actions.report,name:sale_order_line_product_attribute_report.report_sale_order_product_attribute_report +msgid "Sale line products attributes" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model,name:sale_order_line_product_attribute_report.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__top_graphic +msgid "Top Graphic" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__with_all_attributes +msgid "With All Attributes" +msgstr "" + diff --git a/sale_order_line_product_attribute_report/i18n/es.po b/sale_order_line_product_attribute_report/i18n/es.po new file mode 100644 index 000000000..a52f7aff5 --- /dev/null +++ b/sale_order_line_product_attribute_report/i18n/es.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_order_line_product_attribute_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-05-15 08:24+0000\n" +"PO-Revision-Date: 2025-05-15 08:24+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: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__bottom_graphic +msgid "Botton Graphic" +msgstr "Gráfico interior" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__quantities_shapes +msgid "Quantities & Shapes" +msgstr "Cantidades y formas" + +#. module: sale_order_line_product_attribute_report +#: model:ir.actions.report,name:sale_order_line_product_attribute_report.report_sale_line_product_attribute_report +#: model:ir.actions.report,name:sale_order_line_product_attribute_report.report_sale_order_product_attribute_report +msgid "Sale line products attributes" +msgstr "Atributos de los productos" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model,name:sale_order_line_product_attribute_report.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línea de pedido de venta" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__top_graphic +msgid "Top Graphic" +msgstr "Gráfico superior" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__with_all_attributes +msgid "With All Attributes" +msgstr "Con todos los atributos" + diff --git a/sale_order_line_product_attribute_report/i18n/fr.po b/sale_order_line_product_attribute_report/i18n/fr.po new file mode 100644 index 000000000..efc85a2c9 --- /dev/null +++ b/sale_order_line_product_attribute_report/i18n/fr.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_order_line_product_attribute_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-05-15 08:24+0000\n" +"PO-Revision-Date: 2025-05-15 08:24+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: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__bottom_graphic +msgid "Botton Graphic" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__quantities_shapes +msgid "Quantities & Shapes" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.actions.report,name:sale_order_line_product_attribute_report.report_sale_line_product_attribute_report +#: model:ir.actions.report,name:sale_order_line_product_attribute_report.report_sale_order_product_attribute_report +msgid "Sale line products attributes" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model,name:sale_order_line_product_attribute_report.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__top_graphic +msgid "Top Graphic" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__with_all_attributes +msgid "With All Attributes" +msgstr "" + diff --git a/sale_order_line_product_attribute_report/i18n/sale_order_line_product_attribute_report.pot b/sale_order_line_product_attribute_report/i18n/sale_order_line_product_attribute_report.pot new file mode 100644 index 000000000..c625a4b98 --- /dev/null +++ b/sale_order_line_product_attribute_report/i18n/sale_order_line_product_attribute_report.pot @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_order_line_product_attribute_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-05-15 08:23+0000\n" +"PO-Revision-Date: 2025-05-15 08:23+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: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__bottom_graphic +msgid "Botton Graphic" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__quantities_shapes +msgid "Quantities & Shapes" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.actions.report,name:sale_order_line_product_attribute_report.report_sale_line_product_attribute_report +#: model:ir.actions.report,name:sale_order_line_product_attribute_report.report_sale_order_product_attribute_report +msgid "Sale line products attributes" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model,name:sale_order_line_product_attribute_report.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__top_graphic +msgid "Top Graphic" +msgstr "" + +#. module: sale_order_line_product_attribute_report +#: model:ir.model.fields,field_description:sale_order_line_product_attribute_report.field_sale_order_line__with_all_attributes +msgid "With All Attributes" +msgstr "" + diff --git a/sale_order_line_product_attribute_report/init_hook.py b/sale_order_line_product_attribute_report/init_hook.py new file mode 100644 index 000000000..b8aa12fc6 --- /dev/null +++ b/sale_order_line_product_attribute_report/init_hook.py @@ -0,0 +1,47 @@ +# Copyright 2025 Alfredo de la Fuente - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, SUPERUSER_ID +from ._common import _catch_top_bottom_graphic_info +import logging + +try: + from openupgradelib import openupgrade +except Exception: + from odoo.tools import sql as openupgrade + +_logger = logging.getLogger(__name__) + + +def pre_init_hook(cr): + env = api.Environment(cr, SUPERUSER_ID, {}) + _logger.info("Pre-creating column top_graphic for table sale_order_line") + if not openupgrade.column_exists(cr, "sale_order_line", "top_graphic"): + cr.execute( + """ + ALTER TABLE sale_order_line + ADD COLUMN top_graphic varchar; + COMMENT ON COLUMN sale_order_line.top_graphic + IS 'Top Graphic'; + """ + ) + _logger.info("Pre-creating column bottom_graphic for table sale_order_line") + if not openupgrade.column_exists(cr, "sale_order_line", "bottom_graphic"): + cr.execute( + """ + ALTER TABLE sale_order_line + ADD COLUMN bottom_graphic varchar; + COMMENT ON COLUMN sale_order_line.bottom_graphic + IS 'Bottom Graphic'; + """ + ) + sale_lines = env["sale.order.line"].search([]) + for sale_line in sale_lines: + top_graphic, bottom_graphic = _catch_top_bottom_graphic_info(sale_line) + top_graphic = top_graphic.replace("'", "''") + bottom_graphic = bottom_graphic.replace("'", "''") + cr.execute(""" + UPDATE sale_order_line + SET top_graphic = '%s', + bottom_graphic = '%s' + WHERE id = %s; + """ % (top_graphic, bottom_graphic, sale_line.id)) diff --git a/sale_order_line_product_attribute_report/models/__init__.py b/sale_order_line_product_attribute_report/models/__init__.py new file mode 100644 index 000000000..8eb9d1d40 --- /dev/null +++ b/sale_order_line_product_attribute_report/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order_line diff --git a/sale_order_line_product_attribute_report/models/sale_order_line.py b/sale_order_line_product_attribute_report/models/sale_order_line.py new file mode 100644 index 000000000..ded291210 --- /dev/null +++ b/sale_order_line_product_attribute_report/models/sale_order_line.py @@ -0,0 +1,64 @@ +# Copyright 2025 Alfredo de la Fuente - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models +from .._common import _catch_top_bottom_graphic_info + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + _order = "order_id, bottom_graphic, top_graphic, sequence, id" + + with_all_attributes = fields.Boolean( + string="With All Attributes", + compute="_compute_with_all_attributes", + store=True, + ) + quantities_shapes = fields.Char( + string="Quantities & Shapes", compute="_compute_quantities_shapes" + ) + top_graphic = fields.Char( + string="Top Graphic", compute="_compute_top_bottom_graphic", + store=True, copy=False + ) + bottom_graphic = fields.Char( + string="Bottom Graphic", compute="_compute_top_bottom_graphic", + store=True, copy=False + ) + + @api.depends("product_id", "product_id.attribute_value_ids", + "product_id.attribute_value_ids.attribute_id", + "product_id.attribute_value_ids.attribute_id.name", + "product_id.attribute_value_ids.name") + def _compute_with_all_attributes(self): + attribute_names = {"Bottom Graphic", "Top Graphic", "TALLA", "SHAPE"} + for line in self: + attributes = line.product_id.attribute_value_ids + line.with_all_attributes = any( + attr.attribute_id.name in attribute_names for attr in attributes + ) + + def _compute_quantities_shapes(self): + for line in self: + quantities_shapes = "%(quantity)s X " % { + "quantity": line.product_uom_qty, + } + attribute = line.product_id.attribute_value_ids.filtered( + lambda x: x.attribute_id.name == "TALLA") + if attribute: + quantities_shapes = "%(quantities_shapes)s %(value)s" % { + "quantities_shapes": quantities_shapes, + "value": attribute.name, + } + attribute = line.product_id.attribute_value_ids.filtered( + lambda x: x.attribute_id.name == "SHAPE") + if attribute: + quantities_shapes = "%(quantities_shapes)s %(shape)s" % { + "quantities_shapes": quantities_shapes, + "shape": attribute.name, + } + line.quantities_shapes = quantities_shapes + + @api.depends("name") + def _compute_top_bottom_graphic(self): + for sale_line in self: + sale_line.top_graphic, sale_line.bottom_graphic = _catch_top_bottom_graphic_info(sale_line) diff --git a/sale_order_line_product_attribute_report/reports/sale_order_line_product_attribute_report.xml b/sale_order_line_product_attribute_report/reports/sale_order_line_product_attribute_report.xml new file mode 100644 index 000000000..0a29c1b9a --- /dev/null +++ b/sale_order_line_product_attribute_report/reports/sale_order_line_product_attribute_report.xml @@ -0,0 +1,163 @@ + + + + + + + + + + + + diff --git a/sale_order_line_product_attribute_report/static/src/img/background.png b/sale_order_line_product_attribute_report/static/src/img/background.png new file mode 100644 index 000000000..1ac0eea87 Binary files /dev/null and b/sale_order_line_product_attribute_report/static/src/img/background.png differ diff --git a/sale_order_line_product_attribute_report/views/sale_order_line_views.xml b/sale_order_line_product_attribute_report/views/sale_order_line_views.xml new file mode 100644 index 000000000..a7c07b7bd --- /dev/null +++ b/sale_order_line_product_attribute_report/views/sale_order_line_views.xml @@ -0,0 +1,13 @@ + + + + sale.order.line + + + + + + + + + diff --git a/sale_order_line_product_attribute_report/views/sale_order_views.xml b/sale_order_line_product_attribute_report/views/sale_order_views.xml new file mode 100644 index 000000000..657a2f8f7 --- /dev/null +++ b/sale_order_line_product_attribute_report/views/sale_order_views.xml @@ -0,0 +1,20 @@ + + + + sale.order + + + + + + + + + + + + order_id, bottom_graphic, top_graphic, sequence, id + + + +