From bd7556a82fcbd92835abf9b130cb718ab37c8fff Mon Sep 17 00:00:00 2001 From: sergio-teruel Date: Wed, 11 Oct 2023 17:03:22 +0200 Subject: [PATCH 1/2] [ADD] product_ingredient: New module --- product_ingredient/README.rst | 98 ++++ product_ingredient/__init__.py | 1 + product_ingredient/__manifest__.py | 24 + .../data/product_allergen_data.xml | 10 + product_ingredient/models/__init__.py | 8 + .../models/product_attribute.py | 14 + .../models/product_attribute_value.py | 14 + .../models/product_ingredient.py | 19 + .../models/product_ingredient_value.py | 18 + product_ingredient/models/product_product.py | 31 ++ product_ingredient/models/product_template.py | 18 + .../models/production_lot_ingredient_value.py | 19 + .../models/stock_production_lot.py | 45 ++ product_ingredient/readme/CONTRIBUTORS.rst | 4 + product_ingredient/readme/DESCRIPTION.rst | 1 + product_ingredient/readme/USAGE.rst | 7 + .../security/ir.model.access.csv | 4 + .../static/description/index.html | 438 ++++++++++++++++++ .../views/product_attribute_value_views.xml | 17 + .../views/product_ingredient_views.xml | 19 + product_ingredient/views/product_views.xml | 76 +++ .../views/stock_production_lot_view.xml | 36 ++ .../odoo/addons/product_ingredient | 1 + setup/product_ingredient/setup.py | 6 + 24 files changed, 928 insertions(+) create mode 100644 product_ingredient/README.rst create mode 100644 product_ingredient/__init__.py create mode 100644 product_ingredient/__manifest__.py create mode 100644 product_ingredient/data/product_allergen_data.xml create mode 100644 product_ingredient/models/__init__.py create mode 100644 product_ingredient/models/product_attribute.py create mode 100644 product_ingredient/models/product_attribute_value.py create mode 100644 product_ingredient/models/product_ingredient.py create mode 100644 product_ingredient/models/product_ingredient_value.py create mode 100644 product_ingredient/models/product_product.py create mode 100644 product_ingredient/models/product_template.py create mode 100644 product_ingredient/models/production_lot_ingredient_value.py create mode 100644 product_ingredient/models/stock_production_lot.py create mode 100644 product_ingredient/readme/CONTRIBUTORS.rst create mode 100644 product_ingredient/readme/DESCRIPTION.rst create mode 100644 product_ingredient/readme/USAGE.rst create mode 100644 product_ingredient/security/ir.model.access.csv create mode 100644 product_ingredient/static/description/index.html create mode 100644 product_ingredient/views/product_attribute_value_views.xml create mode 100644 product_ingredient/views/product_ingredient_views.xml create mode 100644 product_ingredient/views/product_views.xml create mode 100644 product_ingredient/views/stock_production_lot_view.xml create mode 120000 setup/product_ingredient/odoo/addons/product_ingredient create mode 100644 setup/product_ingredient/setup.py diff --git a/product_ingredient/README.rst b/product_ingredient/README.rst new file mode 100644 index 00000000000..9c87a2ae9eb --- /dev/null +++ b/product_ingredient/README.rst @@ -0,0 +1,98 @@ +=================== +Product Ingredients +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:1dc7d3334f8ad49a0cd0b9009ef8e79c847ce6603f4dc701c86765ab23097d56 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github + :target: https://github.com/OCA/product-attribute/tree/15.0/product_ingredient + :alt: OCA/product-attribute +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/product-attribute-15-0/product-attribute-15-0-product_ingredient + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/product-attribute&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to set ingredients information for a given product. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module you have to: + +- Create or edit a product variant or product template with just a variant. +- Go to ingredients page +- Create some ingredients for the product. + +Now you can print the "Ingredients Info" report label. + +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 +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_ + + * Sergio Teruel + * Carlos Dauden + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-sergio-teruel| image:: https://github.com/sergio-teruel.png?size=40px + :target: https://github.com/sergio-teruel + :alt: sergio-teruel + +Current `maintainer `__: + +|maintainer-sergio-teruel| + +This module is part of the `OCA/product-attribute `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_ingredient/__init__.py b/product_ingredient/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/product_ingredient/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_ingredient/__manifest__.py b/product_ingredient/__manifest__.py new file mode 100644 index 00000000000..e163b299dee --- /dev/null +++ b/product_ingredient/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Product Ingredients", + "summary": "Product ingredients", + "version": "15.0.1.0.0", + "development_status": "Beta", + "category": "Technical Settings", + "website": "https://github.com/OCA/product-attribute", + "author": "Tecnativa, Odoo Community Association (OCA)", + "maintainers": ["sergio-teruel"], + "license": "AGPL-3", + "depends": ["product", "stock"], + "data": [ + "security/ir.model.access.csv", + "data/product_allergen_data.xml", + "views/product_attribute_value_views.xml", + "views/product_ingredient_views.xml", + "views/product_views.xml", + "views/stock_production_lot_view.xml", + ], + "application": False, + "installable": True, +} diff --git a/product_ingredient/data/product_allergen_data.xml b/product_ingredient/data/product_allergen_data.xml new file mode 100644 index 00000000000..c132ce4a922 --- /dev/null +++ b/product_ingredient/data/product_allergen_data.xml @@ -0,0 +1,10 @@ + + + + + Allergens + no_variant + select + + + diff --git a/product_ingredient/models/__init__.py b/product_ingredient/models/__init__.py new file mode 100644 index 00000000000..282fb8e3a8d --- /dev/null +++ b/product_ingredient/models/__init__.py @@ -0,0 +1,8 @@ +from . import product_attribute +from . import product_attribute_value +from . import stock_production_lot +from . import product_ingredient +from . import product_ingredient_value +from . import production_lot_ingredient_value +from . import product_product +from . import product_template diff --git a/product_ingredient/models/product_attribute.py b/product_ingredient/models/product_attribute.py new file mode 100644 index 00000000000..edacd1a0ba7 --- /dev/null +++ b/product_ingredient/models/product_attribute.py @@ -0,0 +1,14 @@ +# Copyright 2023 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, models +from odoo.tools import ormcache + + +class ProductAttribute(models.Model): + _inherit = "product.attribute" + + @api.model + @ormcache() + def get_allergen_id(self): + """Helper to get allergen attribute id""" + return self.env.ref("product_ingredient.product_allergen_attribute").id diff --git a/product_ingredient/models/product_attribute_value.py b/product_ingredient/models/product_attribute_value.py new file mode 100644 index 00000000000..9c00eaad9e5 --- /dev/null +++ b/product_ingredient/models/product_attribute_value.py @@ -0,0 +1,14 @@ +# Copyright 2023 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, models + + +class ProductAttributeValue(models.Model): + _inherit = "product.attribute.value" + + @api.model + def default_get(self, fields_list): + res = super().default_get(fields_list) + if self.env.context.get("set_allergen_attribute"): + res["attribute_id"] = self.env["product.attribute"].get_allergen_id() + return res diff --git a/product_ingredient/models/product_ingredient.py b/product_ingredient/models/product_ingredient.py new file mode 100644 index 00000000000..b102dfffa5f --- /dev/null +++ b/product_ingredient/models/product_ingredient.py @@ -0,0 +1,19 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProductIngredients(models.Model): + _name = "product.ingredient" + _description = "Ingredients of a product." + + name = fields.Char(translate=True) + scientific_name = fields.Char() + allergen_id = fields.Many2one( + comodel_name="product.attribute.value", + domain=lambda self: [ + ("attribute_id", "=", self.env["product.attribute"].get_allergen_id()) + ], + context={"set_allergen_attribute": True, "show_attribute": False}, + ) + is_allergen = fields.Boolean() diff --git a/product_ingredient/models/product_ingredient_value.py b/product_ingredient/models/product_ingredient_value.py new file mode 100644 index 00000000000..9a295824c9c --- /dev/null +++ b/product_ingredient/models/product_ingredient_value.py @@ -0,0 +1,18 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProductIngredientValue(models.Model): + _name = "product.ingredient.value" + _description = "Ingredient values for a product." + _rec_name = "ingredient_id" + _order = "sequence, id" + + sequence = fields.Integer() + product_id = fields.Many2one(comodel_name="product.product") + ingredient_id = fields.Many2one(comodel_name="product.ingredient") + scientific_name = fields.Char(related="ingredient_id.scientific_name") + allergen_id = fields.Many2one(related="ingredient_id.allergen_id") + percentage = fields.Float(digits="Product Unit of Measure") + is_allergen = fields.Boolean(related="ingredient_id.is_allergen") diff --git a/product_ingredient/models/product_product.py b/product_ingredient/models/product_product.py new file mode 100644 index 00000000000..c521587ad57 --- /dev/null +++ b/product_ingredient/models/product_product.py @@ -0,0 +1,31 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class ProductProduct(models.Model): + _inherit = "product.product" + + allergen_id = fields.Many2many( + comodel_name="product.attribute.value", compute="_compute_allergen_id" + ) + ingredient_ids = fields.One2many( + comodel_name="product.ingredient.value", inverse_name="product_id" + ) + ingredient_allergen_trace_ids = fields.Many2many( + comodel_name="product.attribute.value", + string="Allergen traces", + domain=lambda self: [ + ("attribute_id", "=", self.env["product.attribute"].get_allergen_id()) + ], + context={"set_allergen_attribute": True, "show_attribute": False}, + ) + ingredient_additional_info = fields.Text(translate=True) + + @api.depends("ingredient_ids", "ingredient_allergen_trace_ids") + def _compute_allergen_id(self): + for product in self: + product.allergen_id = ( + product.ingredient_ids.mapped("allergen_id") + + product.ingredient_allergen_trace_ids + ) diff --git a/product_ingredient/models/product_template.py b/product_ingredient/models/product_template.py new file mode 100644 index 00000000000..c7b497f02a5 --- /dev/null +++ b/product_ingredient/models/product_template.py @@ -0,0 +1,18 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + allergen_id = fields.Many2many(related="product_variant_ids.allergen_id") + ingredient_ids = fields.One2many( + related="product_variant_ids.ingredient_ids", readonly=False + ) + ingredient_allergen_trace_ids = fields.Many2many( + related="product_variant_ids.ingredient_allergen_trace_ids", readonly=False + ) + ingredient_additional_info = fields.Text( + related="product_variant_ids.ingredient_additional_info", readonly=False + ) diff --git a/product_ingredient/models/production_lot_ingredient_value.py b/product_ingredient/models/production_lot_ingredient_value.py new file mode 100644 index 00000000000..26abb033087 --- /dev/null +++ b/product_ingredient/models/production_lot_ingredient_value.py @@ -0,0 +1,19 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProductionLotIngredientValue(models.Model): + _name = "production.lot.ingredient.value" + _description = "Ingredient values for a product lots." + _rec_name = "ingredient_id" + _order = "sequence, id" + + sequence = fields.Integer() + lot_id = fields.Many2one(comodel_name="stock.production.lot") + # product_id = fields.Many2one(related='lot_id.product_id') + ingredient_id = fields.Many2one(comodel_name="product.ingredient") + scientific_name = fields.Char(related="ingredient_id.scientific_name") + allergen_id = fields.Many2one(related="ingredient_id.allergen_id") + percentage = fields.Float(digits="Product Unit of Measure") + is_allergen = fields.Boolean(related="ingredient_id.is_allergen") diff --git a/product_ingredient/models/stock_production_lot.py b/product_ingredient/models/stock_production_lot.py new file mode 100644 index 00000000000..c6b2bfc6373 --- /dev/null +++ b/product_ingredient/models/stock_production_lot.py @@ -0,0 +1,45 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class StockProductionLot(models.Model): + _inherit = "stock.production.lot" + + ingredient_ids = fields.One2many( + comodel_name="production.lot.ingredient.value", + inverse_name="lot_id", + compute="_compute_ingredient_values", + store=True, + readonly=False, + ) + ingredient_allergen_trace_ids = fields.Many2many( + comodel_name="product.attribute.value", + compute="_compute_ingredient_values", + readonly=False, + domain=lambda self: [ + ("attribute_id", "=", self.env["product.attribute"].get_allergen_id()) + ], + context={"set_allergen_attribute": True, "show_attribute": False}, + store=True, + ) + ingredient_additional_info = fields.Text( + compute="_compute_ingredient_values", readonly=False, store=True, translate=True + ) + + @api.depends("product_id") + def _compute_ingredient_values(self): + self.ingredient_ids = False + for lot in self: + for ingredient_line in lot.product_id.ingredient_ids: + lot.ingredient_ids += self.env["production.lot.ingredient.value"].new( + { + "sequence": ingredient_line.sequence, + "ingredient_id": ingredient_line.ingredient_id.id, + "percentage": ingredient_line.percentage, + } + ) + lot.ingredient_allergen_trace_ids = ( + lot.product_id.ingredient_allergen_trace_ids + ) + lot.ingredient_additional_info = lot.product_id.ingredient_additional_info diff --git a/product_ingredient/readme/CONTRIBUTORS.rst b/product_ingredient/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..12df71f65d4 --- /dev/null +++ b/product_ingredient/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_ + + * Sergio Teruel + * Carlos Dauden diff --git a/product_ingredient/readme/DESCRIPTION.rst b/product_ingredient/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..f5490ee8b09 --- /dev/null +++ b/product_ingredient/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to set ingredients information for a given product. diff --git a/product_ingredient/readme/USAGE.rst b/product_ingredient/readme/USAGE.rst new file mode 100644 index 00000000000..0c76da39252 --- /dev/null +++ b/product_ingredient/readme/USAGE.rst @@ -0,0 +1,7 @@ +To use this module you have to: + +- Create or edit a product variant or product template with just a variant. +- Go to ingredients page +- Create some ingredients for the product. + +Now you can print the "Ingredients Info" report label. diff --git a/product_ingredient/security/ir.model.access.csv b/product_ingredient/security/ir.model.access.csv new file mode 100644 index 00000000000..bccc1b2e6ad --- /dev/null +++ b/product_ingredient/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +product_ingredient.access_product_ingredient,access_product_ingredient,product_ingredient.model_product_ingredient,base.group_user,1,1,1,1 +product_ingredient.access_product_ingredient_value,access_product_ingredient_value,product_ingredient.model_product_ingredient_value,base.group_user,1,1,1,1 +product_ingredient.access_production_lot_ingredient_value,access_production_lot_ingredient_value,product_ingredient.model_production_lot_ingredient_value,base.group_user,1,1,1,1 diff --git a/product_ingredient/static/description/index.html b/product_ingredient/static/description/index.html new file mode 100644 index 00000000000..51eba693b12 --- /dev/null +++ b/product_ingredient/static/description/index.html @@ -0,0 +1,438 @@ + + + + + + +Product Ingredients + + + +
+

Product Ingredients

+ + +

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runboat

+

This module allows to set ingredients information for a given product.

+

Table of contents

+ +
+

Usage

+

To use this module you have to:

+
    +
  • Create or edit a product variant or product template with just a variant.
  • +
  • Go to ingredients page
  • +
  • Create some ingredients for the product.
  • +
+

Now you can print the “Ingredients Info” report label.

+
+
+

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

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa
      +
    • Sergio Teruel
    • +
    • Carlos Dauden
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

sergio-teruel

+

This module is part of the OCA/product-attribute project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/product_ingredient/views/product_attribute_value_views.xml b/product_ingredient/views/product_attribute_value_views.xml new file mode 100644 index 00000000000..536b0f78995 --- /dev/null +++ b/product_ingredient/views/product_attribute_value_views.xml @@ -0,0 +1,17 @@ + + + + product.attribute.value.form + product.attribute.value + +
+ + + + + + +
+
+
+
diff --git a/product_ingredient/views/product_ingredient_views.xml b/product_ingredient/views/product_ingredient_views.xml new file mode 100644 index 00000000000..0f466a9128e --- /dev/null +++ b/product_ingredient/views/product_ingredient_views.xml @@ -0,0 +1,19 @@ + + + + product.ingredient.form.view + product.ingredient + +
+ + + + + + + + +
+
+
+
diff --git a/product_ingredient/views/product_views.xml b/product_ingredient/views/product_views.xml new file mode 100644 index 00000000000..7d750d19391 --- /dev/null +++ b/product_ingredient/views/product_views.xml @@ -0,0 +1,76 @@ + + + + + product.product + + + + + + + + + + + + + + + + + + + + + + + + + + + + product.template + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/product_ingredient/views/stock_production_lot_view.xml b/product_ingredient/views/stock_production_lot_view.xml new file mode 100644 index 00000000000..4557d5e8713 --- /dev/null +++ b/product_ingredient/views/stock_production_lot_view.xml @@ -0,0 +1,36 @@ + + + + + + stock.production.lot + + + + + + + + + + + + + + + + + + + + + + + diff --git a/setup/product_ingredient/odoo/addons/product_ingredient b/setup/product_ingredient/odoo/addons/product_ingredient new file mode 120000 index 00000000000..9c706710f93 --- /dev/null +++ b/setup/product_ingredient/odoo/addons/product_ingredient @@ -0,0 +1 @@ +../../../../product_ingredient \ No newline at end of file diff --git a/setup/product_ingredient/setup.py b/setup/product_ingredient/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/product_ingredient/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From 006fbec579d696cb8fde59ebb3b283d4117569b1 Mon Sep 17 00:00:00 2001 From: Carlos Dauden Date: Mon, 6 Nov 2023 19:40:41 +0100 Subject: [PATCH 2/2] [FIX] product_ingredient: Create product_allergen_attribute in pre_init_hook --- product_ingredient/__init__.py | 1 + product_ingredient/__manifest__.py | 2 ++ product_ingredient/data/product_allergen_data.xml | 3 +-- product_ingredient/hooks.py | 11 +++++++++++ requirements.txt | 2 ++ 5 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 product_ingredient/hooks.py create mode 100644 requirements.txt diff --git a/product_ingredient/__init__.py b/product_ingredient/__init__.py index 0650744f6bc..6d58305f5dd 100644 --- a/product_ingredient/__init__.py +++ b/product_ingredient/__init__.py @@ -1 +1,2 @@ from . import models +from .hooks import pre_init_hook diff --git a/product_ingredient/__manifest__.py b/product_ingredient/__manifest__.py index e163b299dee..6035d0ddac4 100644 --- a/product_ingredient/__manifest__.py +++ b/product_ingredient/__manifest__.py @@ -11,6 +11,7 @@ "maintainers": ["sergio-teruel"], "license": "AGPL-3", "depends": ["product", "stock"], + "external_dependencies": {"python": ["openupgradelib"]}, "data": [ "security/ir.model.access.csv", "data/product_allergen_data.xml", @@ -19,6 +20,7 @@ "views/product_views.xml", "views/stock_production_lot_view.xml", ], + "pre_init_hook": "pre_init_hook", "application": False, "installable": True, } diff --git a/product_ingredient/data/product_allergen_data.xml b/product_ingredient/data/product_allergen_data.xml index c132ce4a922..b092685c9d8 100644 --- a/product_ingredient/data/product_allergen_data.xml +++ b/product_ingredient/data/product_allergen_data.xml @@ -1,10 +1,9 @@ + - Allergens no_variant select - diff --git a/product_ingredient/hooks.py b/product_ingredient/hooks.py new file mode 100644 index 00000000000..5697fddbe41 --- /dev/null +++ b/product_ingredient/hooks.py @@ -0,0 +1,11 @@ +# Copyright 2023 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +def pre_init_hook(cr): + """ + Create product_allergen_attribute to can be used in get_allergen_id() used in compute + methods + """ + openupgrade.load_data(cr, "product_ingredient", "data/product_allergen_data.xml") diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000000..180fc49789b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +openupgradelib