Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14.0 mig product multi ean fix setup #12

Open
wants to merge 2 commits into
base: 14.0-mig-product_multi_ean
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion product_multi_barcode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
from .hooks import post_init_hook
from .hooks import pre_init_hook, post_init_hook
1 change: 1 addition & 0 deletions product_multi_barcode/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"security/ir.model.access.csv",
],
"installable": True,
"pre_init_hook": "pre_init_hook",
"post_init_hook": "post_init_hook",
}
56 changes: 50 additions & 6 deletions product_multi_barcode/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,57 @@
# © 2018 Xavier Jimenez (QubiQ)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import logging

def post_init_hook(cr, registry):
_logger = logging.getLogger(__name__)

try:
from openupgradelib import openupgrade
except (ImportError, IOError) as err:
_logger.debug(err)


def pre_init_hook(cr):
cr.execute(
"""
INSERT INTO product_barcode
(product_id, name, sequence)
SELECT id, barcode, 0
FROM product_product
WHERE barcode IS NOT NULL"""
SELECT name
FROM ir_module_module
WHERE name = 'product_multi_ean'"""
)
row = cr.fetchone()
if row:
# import pdb; pdb.set_trace();
openupgrade.update_module_names(
cr,
[("product_multi_ean", "product_multi_barcode")],
merge_modules=True,
)


def post_init_hook(cr, registry):
cr.execute("select name,model from ir_model where model = 'product.ean13';")
row = cr.fetchone()
if row:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cette partie ira de le script de migration (d'ailleur tu peux renommer l'object et les champs) il y a une méthode openupgrade pour ça

cr.execute(
"""
INSERT INTO product_barcode
(product_id, name, sequence)
SELECT ean13.product_id, ean13.name, ean13.sequence
FROM product_ean13 ean13
"""
)
cr.execute(
"""
DROP TABLE product_ean13
"""
)

else:
cr.execute(
"""
INSERT INTO product_barcode
(product_id, name, sequence)
SELECT id, barcode, 0
FROM product_product
WHERE barcode IS NOT NULL"""
)
File renamed without changes.
1 change: 0 additions & 1 deletion setup/product_multi_ean/odoo/addons/product_multi_ean

This file was deleted.