diff --git a/product_attribute_laser/README.rst b/product_attribute_laser/README.rst new file mode 100644 index 0000000000..a6c26b9050 --- /dev/null +++ b/product_attribute_laser/README.rst @@ -0,0 +1,32 @@ +.. 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 + +======================= +Product attribute laser +======================= + +* New object "Material". In products new field "Material". +* In product variants new fields: "Grade" and "Thickness". +* In product attributes you must define "GRADE" and "THICKNESS" attributes. + + +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 to smash it by providing a detailed and welcomed +feedback. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Contributors +------------ +* Ana Juaristi +* Alfredo de la Fuente + +Do not contact contributors directly about support or help with technical issues. diff --git a/product_attribute_laser/__init__.py b/product_attribute_laser/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/product_attribute_laser/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_attribute_laser/__manifest__.py b/product_attribute_laser/__manifest__.py new file mode 100644 index 0000000000..c6c724a7af --- /dev/null +++ b/product_attribute_laser/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Alfredo de la Fuente - AvanzOSC +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +{ + "name": "Product Attribute Laser", + "version": "16.0.1.0.0", + "author": "AvanzOSC", + "website": "https://github.com/avanzosc/odoo-addons", + "category": "Sales/Sales", + "license": "AGPL-3", + "depends": ["product"], + "data": [ + "security/ir.model.access.csv", + "views/product_material_views.xml", + "views/product_template_views.xml", + "views/product_product_views.xml", + ], + "installable": True, +} diff --git a/product_attribute_laser/i18n/en_GB.po b/product_attribute_laser/i18n/en_GB.po new file mode 100644 index 0000000000..a2f2b90e6c --- /dev/null +++ b/product_attribute_laser/i18n/en_GB.po @@ -0,0 +1,95 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_attribute_laser +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-07-11 07:43+0000\n" +"PO-Revision-Date: 2024-07-11 07:43+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_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__create_uid +msgid "Created by" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__create_date +msgid "Created on" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__name +msgid "Description" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__display_name +msgid "Display Name" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_grade_id +msgid "Grade" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__id +msgid "ID" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material____last_update +msgid "Last Modified on" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__write_date +msgid "Last Updated on" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_material_id +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_template__product_material_id +#: model_terms:ir.ui.view,arch_db:product_attribute_laser.product_template_search_view +msgid "Material" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.actions.act_window,name:product_attribute_laser.product_material_action +#: model:ir.ui.menu,name:product_attribute_laser.menu_product_material +#: model_terms:ir.ui.view,arch_db:product_attribute_laser.product_material_tree_view +msgid "Materials" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_template +msgid "Product" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_material +msgid "Product Material" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_thickness_id +msgid "Thickness" +msgstr "" diff --git a/product_attribute_laser/i18n/en_US.po b/product_attribute_laser/i18n/en_US.po new file mode 100644 index 0000000000..a2f2b90e6c --- /dev/null +++ b/product_attribute_laser/i18n/en_US.po @@ -0,0 +1,95 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_attribute_laser +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-07-11 07:43+0000\n" +"PO-Revision-Date: 2024-07-11 07:43+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_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__create_uid +msgid "Created by" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__create_date +msgid "Created on" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__name +msgid "Description" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__display_name +msgid "Display Name" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_grade_id +msgid "Grade" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__id +msgid "ID" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material____last_update +msgid "Last Modified on" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__write_date +msgid "Last Updated on" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_material_id +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_template__product_material_id +#: model_terms:ir.ui.view,arch_db:product_attribute_laser.product_template_search_view +msgid "Material" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.actions.act_window,name:product_attribute_laser.product_material_action +#: model:ir.ui.menu,name:product_attribute_laser.menu_product_material +#: model_terms:ir.ui.view,arch_db:product_attribute_laser.product_material_tree_view +msgid "Materials" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_template +msgid "Product" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_material +msgid "Product Material" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_thickness_id +msgid "Thickness" +msgstr "" diff --git a/product_attribute_laser/i18n/es.po b/product_attribute_laser/i18n/es.po new file mode 100644 index 0000000000..af5d31a959 --- /dev/null +++ b/product_attribute_laser/i18n/es.po @@ -0,0 +1,96 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_attribute_laser +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-07-11 07:44+0000\n" +"PO-Revision-Date: 2024-07-11 07:44+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_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__name +msgid "Description" +msgstr "Descripción" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__display_name +msgid "Display Name" +msgstr "Mostrar nombre" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_grade_id +msgid "Grade" +msgstr "Grado" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__id +msgid "ID" +msgstr "ID" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material____last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__write_uid +msgid "Last Updated by" +msgstr "Última actualización por" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__write_date +msgid "Last Updated on" +msgstr "Última actualización el" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_material_id +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_template__product_material_id +#: model_terms:ir.ui.view,arch_db:product_attribute_laser.product_template_search_view +msgid "Material" +msgstr "Material" + +#. module: product_attribute_laser +#: model:ir.actions.act_window,name:product_attribute_laser.product_material_action +#: model:ir.ui.menu,name:product_attribute_laser.menu_product_material +#: model_terms:ir.ui.view,arch_db:product_attribute_laser.product_material_tree_view +msgid "Materials" +msgstr "Materiales" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_template +msgid "Product" +msgstr "Producto" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_material +msgid "Product Material" +msgstr "Material producto" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_product +msgid "Product Variant" +msgstr "Variantes de producto" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_thickness_id +msgid "Thickness" +msgstr "Espesor" + diff --git a/product_attribute_laser/i18n/product_attribute_laser.pot b/product_attribute_laser/i18n/product_attribute_laser.pot new file mode 100644 index 0000000000..a2f2b90e6c --- /dev/null +++ b/product_attribute_laser/i18n/product_attribute_laser.pot @@ -0,0 +1,95 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_attribute_laser +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-07-11 07:43+0000\n" +"PO-Revision-Date: 2024-07-11 07:43+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_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__create_uid +msgid "Created by" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__create_date +msgid "Created on" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__name +msgid "Description" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__display_name +msgid "Display Name" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_grade_id +msgid "Grade" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__id +msgid "ID" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material____last_update +msgid "Last Modified on" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_material__write_date +msgid "Last Updated on" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_material_id +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_template__product_material_id +#: model_terms:ir.ui.view,arch_db:product_attribute_laser.product_template_search_view +msgid "Material" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.actions.act_window,name:product_attribute_laser.product_material_action +#: model:ir.ui.menu,name:product_attribute_laser.menu_product_material +#: model_terms:ir.ui.view,arch_db:product_attribute_laser.product_material_tree_view +msgid "Materials" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_template +msgid "Product" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_material +msgid "Product Material" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model,name:product_attribute_laser.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: product_attribute_laser +#: model:ir.model.fields,field_description:product_attribute_laser.field_product_product__product_thickness_id +msgid "Thickness" +msgstr "" diff --git a/product_attribute_laser/models/__init__.py b/product_attribute_laser/models/__init__.py new file mode 100644 index 0000000000..d0099e385a --- /dev/null +++ b/product_attribute_laser/models/__init__.py @@ -0,0 +1,3 @@ +from . import product_material +from . import product_template +from . import product_product diff --git a/product_attribute_laser/models/product_material.py b/product_attribute_laser/models/product_material.py new file mode 100644 index 0000000000..833732f449 --- /dev/null +++ b/product_attribute_laser/models/product_material.py @@ -0,0 +1,11 @@ +# Copyright 2024 Alfredo de la Fuente - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import fields, models + + +class ProductMaterial(models.Model): + _name = "product.material" + _description = "Product Material" + _order = "name" + + name = fields.Char(string="Description") diff --git a/product_attribute_laser/models/product_product.py b/product_attribute_laser/models/product_product.py new file mode 100644 index 0000000000..1fd1be230b --- /dev/null +++ b/product_attribute_laser/models/product_product.py @@ -0,0 +1,44 @@ +# Copyright 2024 Alfredo de la Fuente - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models + + +class ProductProduct(models.Model): + _inherit = "product.product" + + product_grade_id = fields.Many2one( + string="Grade", + comodel_name="product.template.attribute.value", + compute="_compute_product_grade_id", + copy=False, + store=True, + ) + product_thickness_id = fields.Many2one( + string="Thickness", + comodel_name="product.template.attribute.value", + compute="_compute_product_thickness_id", + copy=False, + store=True, + ) + + @api.depends("product_template_attribute_value_ids") + def _compute_product_grade_id(self): + grade_att = self.env["product.attribute"].search( + [("name", "=", "GRADE")], limit=1 + ) + for record in self: + grade = record.product_template_attribute_value_ids.filtered( + lambda v: v.attribute_id == grade_att + ) + record.product_grade_id = grade or False + + @api.depends("product_template_attribute_value_ids") + def _compute_product_thickness_id(self): + thickness_att = self.env["product.attribute"].search( + [("name", "=", "THICKNESS")], limit=1 + ) + for record in self: + thickness = record.product_template_attribute_value_ids.filtered( + lambda v: v.attribute_id == thickness_att + ) + record.product_thickness_id = thickness or False diff --git a/product_attribute_laser/models/product_template.py b/product_attribute_laser/models/product_template.py new file mode 100644 index 0000000000..ec2e4fb625 --- /dev/null +++ b/product_attribute_laser/models/product_template.py @@ -0,0 +1,11 @@ +# Copyright 2024 Alfredo de la Fuente - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + product_material_id = fields.Many2one( + string="Material", comodel_name="product.material", copy=False + ) diff --git a/product_attribute_laser/security/ir.model.access.csv b/product_attribute_laser/security/ir.model.access.csv new file mode 100644 index 0000000000..b612fa601c --- /dev/null +++ b/product_attribute_laser/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_material_user,access_product_material_user,model_product_material,base.group_user,1,0,0,0 +access_product_material_manager,access_product_material_manager,model_product_material,base.group_system,1,1,1,1 diff --git a/product_attribute_laser/views/product_material_views.xml b/product_attribute_laser/views/product_material_views.xml new file mode 100644 index 0000000000..5cdf572eb9 --- /dev/null +++ b/product_attribute_laser/views/product_material_views.xml @@ -0,0 +1,26 @@ + + + + product.material.tree.view + product.material + + + + + + + + + Materials + product.material + tree,form + + + + diff --git a/product_attribute_laser/views/product_product_views.xml b/product_attribute_laser/views/product_product_views.xml new file mode 100644 index 0000000000..191dbb69e4 --- /dev/null +++ b/product_attribute_laser/views/product_product_views.xml @@ -0,0 +1,25 @@ + + + + product.product + + + + + + + + + + + product.product + + + + + + + + + + diff --git a/product_attribute_laser/views/product_template_views.xml b/product_attribute_laser/views/product_template_views.xml new file mode 100644 index 0000000000..fb6be861c4 --- /dev/null +++ b/product_attribute_laser/views/product_template_views.xml @@ -0,0 +1,38 @@ + + + + product.template + + + + + + + + + + product.template + + + + + + + + + + product.template + + + + + + + + + +