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

[17.0][OU-ADD] product: migrate to 17.0 #4598

Open
wants to merge 2 commits into
base: 17.0
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 docsource/modules160-170.rst
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ Module coverage 16.0 -> 17.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| privacy_lookup | |No DB layout changes. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| product | | |
| product | Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| product_email_template | |No DB layout changes. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
22 changes: 22 additions & 0 deletions openupgrade_scripts/scripts/product/17.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env, "product", "17.0.1.2/noupdate_changes.xml")
openupgrade.delete_records_safely_by_xml_id(env, ["product.list0"])
openupgrade.logged_query(
env.cr,
"""
INSERT INTO product_document (
ir_attachment_id, active, create_uid, write_uid, create_date, write_date
)
SELECT id, True, create_uid, write_uid, create_date, write_date
FROM ir_attachment
WHERE res_model IN ('product.product', 'product.template')
AND res_field IS NULL
""",
)
31 changes: 31 additions & 0 deletions openupgrade_scripts/scripts/product/17.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE product_tag
ALTER COLUMN color TYPE VARCHAR USING color::VARCHAR;

UPDATE product_tag
SET color = CASE
WHEN color = '1' THEN '#F06050'
WHEN color = '2' THEN '#F4A460'
WHEN color = '3' THEN '#F7CD1F'
WHEN color = '4' THEN '#6CC1ED'
WHEN color = '5' THEN '#814968'
WHEN color = '6' THEN '#EB7E7F'
WHEN color = '7' THEN '#2C8397'
WHEN color = '8' THEN '#475577'
WHEN color = '9' THEN '#D6145F'
WHEN color = '10' THEN '#30C381'
WHEN color = '11' THEN '#9365B8'
ELSE '#3C3C3C'
END;
""",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---Models in module 'product'---
obsolete model report.product.report_producttemplatelabel [abstract]
new model product.catalog.mixin [abstract]
new model product.document
new model report.product.report_producttemplatelabel2x7 [abstract]
new model report.product.report_producttemplatelabel4x12 [abstract]
new model report.product.report_producttemplatelabel4x12noprice [abstract]
new model report.product.report_producttemplatelabel4x7 [abstract]
# NOTHING TO DO

---Fields in module 'product'---
product / product.attribute / display_type (selection) : selection_keys is now '['color', 'multi', 'pills', 'radio', 'select']' ('['color', 'pills', 'radio', 'select']')
# NOTHING TO DO: add new selection: multi

product / product.attribute.value / default_extra_price (float) : NEW
product / product.attribute.value / image (binary) : NEW attachment: True
product / product.category / product_properties_definition (properties_definition): NEW
# NOTHING TO DO: new feature

product / product.document / _inherits : NEW _inherits: {'ir.attachment': 'ir_attachment_id'}
product / product.document / active (boolean) : NEW hasdefault: default
product / product.document / ir_attachment_id (many2one) : NEW relation: ir.attachment, required
# DONE: populated in post-migration with attachments on products

product / product.packaging / product_id (many2one) : now required
# NOTHING TO DO

product / product.pricelist / _order : _order is now 'sequence asc, id asc' ('sequence asc, id desc')
product / product.pricelist / activity_ids (one2many) : NEW relation: mail.activity
product / product.pricelist / message_follower_ids (one2many): NEW relation: mail.followers
product / product.pricelist / message_ids (one2many) : NEW relation: mail.message
# NOTHING TO DO

product / product.pricelist.item / active (boolean) : DEL
# NOTHING TO DO

product / product.product / activity_user_id (many2one) : not related anymore
product / product.product / activity_user_id (many2one) : now a function
product / product.product / message_main_attachment_id (many2one): DEL relation: ir.attachment
# NOTHING TO DO

product / product.product / product_document_ids (one2many): NEW relation: product.document
# DONE: populated in post-migration with attachments on products

product / product.supplierinfo / discount (float) : NEW
# NOTHING TO DO

product / product.tag / color (integer) : type is now 'char' ('integer')
# DONE: handled in pre-migration

product / product.template / activity_user_id (many2one) : not related anymore
product / product.template / activity_user_id (many2one) : now a function
product / product.template / message_main_attachment_id (many2one): DEL relation: ir.attachment
product / product.template / product_properties (properties): NEW hasdefault: compute
# NOTHING TO DO

product / product.template / product_document_ids (one2many): NEW relation: product.document
# DONE: populated in post-migration with attachments on products

product / product.template.attribute.line / _order : _order is now 'sequence, attribute_id, id' ('attribute_id, id')
product / product.template.attribute.line / sequence (integer) : NEW hasdefault: default
# NOTHING TO DO: new feature

---XML records in module 'product'---
NEW ir.actions.report: product.report_product_template_label_2x7
NEW ir.actions.report: product.report_product_template_label_4x12
NEW ir.actions.report: product.report_product_template_label_4x12_noprice
NEW ir.actions.report: product.report_product_template_label_4x7
DEL ir.actions.report: product.report_product_template_label
NEW ir.model.access: product.access_product_document_user
NEW ir.model.constraint: product.constraint_product_attribute_check_multi_checkbox_no_variant
# NOTHING TO DO

NEW ir.rule: product.product_document_comp_rule (noupdate)
NEW ir.ui.view: product.product_attribute_value_list
NEW ir.ui.view: product.product_document_form
NEW ir.ui.view: product.product_document_kanban
NEW ir.ui.view: product.product_document_list
NEW ir.ui.view: product.product_document_search
NEW ir.ui.view: product.product_product_view_tree_tag
NEW ir.ui.view: product.product_template_view_tree_tag
NEW ir.ui.view: product.product_view_kanban_catalog
NEW ir.ui.view: product.product_view_search_catalog
NEW ir.ui.view: product.report_producttemplatelabel2x7
NEW ir.ui.view: product.report_producttemplatelabel4x12
NEW ir.ui.view: product.report_producttemplatelabel4x12noprice
NEW ir.ui.view: product.report_producttemplatelabel4x7
NEW ir.ui.view: product.report_simple_label4x12_no_price
# NOTHING TO DO

DEL ir.ui.view: product.report_producttemplatelabel
# NOTHING TO DO

DEL product.pricelist: product.list0 (noupdate)
DONE: delete in post-migration
Loading