Skip to content

Commit

Permalink
[FIX] product_ingredient: Create product_allergen_attribute in pre_in…
Browse files Browse the repository at this point in the history
…it_hook
  • Loading branch information
carlosdauden committed Nov 6, 2023
1 parent bd7556a commit fa5f660
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions product_ingredient/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from .hooks import pre_init_hook
1 change: 1 addition & 0 deletions product_ingredient/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"views/product_views.xml",
"views/stock_production_lot_view.xml",
],
"pre_init_hook": "pre_init_hook",
"application": False,
"installable": True,
}
3 changes: 1 addition & 2 deletions product_ingredient/data/product_allergen_data.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- This file is preloaded with pre_init_hook. Use other file if is needed -->
<odoo noupdate="1">

<record id="product_allergen_attribute" model="product.attribute">
<field name="name">Allergens</field>
<field name="create_variant">no_variant</field>
<field name="display_type">select</field>
</record>

</odoo>
11 changes: 11 additions & 0 deletions product_ingredient/hooks.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit fa5f660

Please sign in to comment.