mreficent
6 years ago
committed by
Jairo Llopis
4 changed files with 189 additions and 0 deletions
-
40partner_industry_secondary/migrations/11.0.1.0.0/openupgrade_analysis.txt
-
55partner_industry_secondary/migrations/11.0.1.0.0/openupgrade_analysis_work.txt
-
67partner_industry_secondary/migrations/11.0.1.0.0/post-migration.py
-
27partner_industry_secondary/migrations/11.0.1.0.0/pre-migration.py
@ -0,0 +1,40 @@ |
|||
---Fields in module 'partner_industry_secondary'--- |
|||
partner_industry_secondary / res.partner / secondary_industry_ids (many2many): NEW relation: res.partner.industry |
|||
partner_industry_secondary / res.partner.industry / child_ids (one2many) : NEW relation: res.partner.industry |
|||
partner_industry_secondary / res.partner.industry / name (False) : NEW required: required, mode: modify |
|||
partner_industry_secondary / res.partner.industry / parent_id (many2one) : NEW relation: res.partner.industry |
|||
partner_industry_secondary / res.partner.industry / parent_left (integer) : NEW |
|||
partner_industry_secondary / res.partner.industry / parent_right (integer) : NEW |
|||
partner_sector / res.partner / secondary_sector_ids (many2many): DEL relation: res.partner.sector |
|||
partner_sector / res.partner / sector_id (many2one) : DEL relation: res.partner.sector |
|||
---XML records in module 'partner_industry_secondary'--- |
|||
DEL ir.actions.act_window: partner_sector.res_partner_sector_action |
|||
NEW ir.model.access: partner_industry_secondary.access_res_partner_industry_group_partner_manager |
|||
NEW ir.model.access: partner_industry_secondary.access_res_partner_industry_portal |
|||
NEW ir.model.access: partner_industry_secondary.access_res_partner_industry_public |
|||
DEL ir.model.access: partner_sector.access_res_partner_sector_group_partner_manager |
|||
DEL ir.model.access: partner_sector.access_res_partner_sector_group_user |
|||
DEL ir.model.access: partner_sector.access_res_partner_sector_portal |
|||
DEL ir.model.access: partner_sector.access_res_partner_sector_public |
|||
DEL ir.ui.menu: partner_sector.menu_res_partner_sector |
|||
NEW ir.ui.view: partner_industry_secondary.res_config_settings_view_form |
|||
NEW ir.ui.view: partner_industry_secondary.res_partner_industry_view_form |
|||
NEW ir.ui.view: partner_industry_secondary.res_partner_industry_view_tree |
|||
NEW ir.ui.view: partner_industry_secondary.view_partner_form_industry |
|||
NEW ir.ui.view: partner_industry_secondary.view_partner_form_industry_person |
|||
NEW ir.ui.view: partner_industry_secondary.view_partner_form_industry_person0 |
|||
NEW ir.ui.view: partner_industry_secondary.view_partner_tree_industry |
|||
NEW ir.ui.view: partner_industry_secondary.view_partner_tree_industry_person |
|||
NEW ir.ui.view: partner_industry_secondary.view_res_partner_filter_industry |
|||
NEW ir.ui.view: partner_industry_secondary.view_res_partner_filter_industry_person |
|||
DEL ir.ui.view: partner_sector.res_partner_sector_tree_view |
|||
DEL ir.ui.view: partner_sector.view_general_configuration |
|||
DEL ir.ui.view: partner_sector.view_partner_form_sector |
|||
DEL ir.ui.view: partner_sector.view_partner_form_sector_person |
|||
DEL ir.ui.view: partner_sector.view_partner_tree_sector |
|||
DEL ir.ui.view: partner_sector.view_partner_tree_sector_person |
|||
DEL ir.ui.view: partner_sector.view_res_partner_filter_sector |
|||
DEL ir.ui.view: partner_sector.view_res_partner_filter_sector_person |
|||
DEL ir.ui.view: partner_sector.view_sale_config_settings |
|||
NEW res.groups: partner_industry_secondary.group_use_partner_industry_for_person |
|||
DEL res.groups: partner_sector.group_use_partner_sector_for_person |
@ -0,0 +1,55 @@ |
|||
---Fields in module 'partner_industry_secondary'--- |
|||
partner_industry_secondary / res.partner.industry / child_ids (one2many) : NEW relation: res.partner.industry |
|||
# nothing to do |
|||
|
|||
partner_industry_secondary / res.partner.industry / name (False) : NEW required: required, mode: modify |
|||
partner_industry_secondary / res.partner.industry / parent_id (many2one) : NEW relation: res.partner.industry |
|||
# fill this table with old res_partner_sector table |
|||
|
|||
partner_industry_secondary / res.partner.industry / parent_left (integer) : NEW |
|||
partner_industry_secondary / res.partner.industry / parent_right (integer) : NEW |
|||
# recompute |
|||
|
|||
---Fields in module 'res_partner'--- |
|||
|
|||
partner_sector / res.partner / sector_id (many2one) : DEL relation: res.partner.sector |
|||
# DONE in pre-migration: rename |
|||
|
|||
partner_sector / res.partner / secondary_sector_ids (many2many): DEL relation: res.partner.sector |
|||
partner_industry_secondary / res.partner / secondary_industry_ids (many2many): NEW relation: res.partner.industry |
|||
# DONE in post-migration: refill new rel table with old rel table |
|||
|
|||
---XML records in module 'partner_industry_secondary'--- |
|||
DEL ir.actions.act_window: partner_sector.res_partner_sector_action |
|||
NEW ir.model.access: partner_industry_secondary.access_res_partner_industry_group_partner_manager |
|||
NEW ir.model.access: partner_industry_secondary.access_res_partner_industry_portal |
|||
NEW ir.model.access: partner_industry_secondary.access_res_partner_industry_public |
|||
DEL ir.model.access: partner_sector.access_res_partner_sector_group_partner_manager |
|||
DEL ir.model.access: partner_sector.access_res_partner_sector_group_user |
|||
DEL ir.model.access: partner_sector.access_res_partner_sector_portal |
|||
DEL ir.model.access: partner_sector.access_res_partner_sector_public |
|||
DEL ir.ui.menu: partner_sector.menu_res_partner_sector |
|||
NEW ir.ui.view: partner_industry_secondary.res_config_settings_view_form |
|||
NEW ir.ui.view: partner_industry_secondary.res_partner_industry_view_form |
|||
NEW ir.ui.view: partner_industry_secondary.res_partner_industry_view_tree |
|||
NEW ir.ui.view: partner_industry_secondary.view_partner_form_industry |
|||
NEW ir.ui.view: partner_industry_secondary.view_partner_form_industry_person |
|||
NEW ir.ui.view: partner_industry_secondary.view_partner_form_industry_person0 |
|||
NEW ir.ui.view: partner_industry_secondary.view_partner_tree_industry |
|||
NEW ir.ui.view: partner_industry_secondary.view_partner_tree_industry_person |
|||
NEW ir.ui.view: partner_industry_secondary.view_res_partner_filter_industry |
|||
NEW ir.ui.view: partner_industry_secondary.view_res_partner_filter_industry_person |
|||
DEL ir.ui.view: partner_sector.res_partner_sector_tree_view |
|||
DEL ir.ui.view: partner_sector.view_general_configuration |
|||
DEL ir.ui.view: partner_sector.view_partner_form_sector |
|||
DEL ir.ui.view: partner_sector.view_partner_form_sector_person |
|||
DEL ir.ui.view: partner_sector.view_partner_tree_sector |
|||
DEL ir.ui.view: partner_sector.view_partner_tree_sector_person |
|||
DEL ir.ui.view: partner_sector.view_res_partner_filter_sector |
|||
DEL ir.ui.view: partner_sector.view_res_partner_filter_sector_person |
|||
DEL ir.ui.view: partner_sector.view_sale_config_settings |
|||
# NOTHING TO DO |
|||
|
|||
NEW res.groups: partner_industry_secondary.group_use_partner_industry_for_person |
|||
DEL res.groups: partner_sector.group_use_partner_sector_for_person |
|||
# DONE in pre-migration: rename of xmlids |
@ -0,0 +1,67 @@ |
|||
# Copyright 2018 Eficent Business and IT Consulting Services, S.L. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from openupgradelib import openupgrade |
|||
from psycopg2.extensions import AsIs |
|||
|
|||
|
|||
def fill_res_partner_industry(cr): |
|||
cr.execute( |
|||
""" |
|||
INSERT INTO res_partner_industry (name, active, create_uid, |
|||
create_date, write_uid, write_date, %s) |
|||
SELECT name, TRUE as active, create_uid, create_date, write_uid, |
|||
write_date, id |
|||
FROM res_partner_sector |
|||
""", (AsIs(openupgrade.get_legacy_name('old_sector_id')), ), |
|||
) |
|||
# corrected parent_id here: |
|||
cr.execute( |
|||
""" |
|||
UPDATE res_partner_industry rpi |
|||
SET parent_id = rpi2.id |
|||
FROM res_partner_sector rps |
|||
INNER JOIN res_partner_industry rpi2 ON rps.parent_id = rpi2.%s |
|||
WHERE rpi.%s = rps.id |
|||
""", ( |
|||
AsIs(openupgrade.get_legacy_name('old_sector_id')), |
|||
AsIs(openupgrade.get_legacy_name('old_sector_id')), |
|||
), |
|||
) |
|||
|
|||
|
|||
def update_res_partner_industry(cr): |
|||
cr.execute( |
|||
""" |
|||
UPDATE res_partner rp |
|||
SET industry_id = rpi.id |
|||
FROM res_partner_industry rpi |
|||
WHERE rp.%s IS NOT NULL AND rp.%s = rpi.%s |
|||
""", ( |
|||
AsIs(openupgrade.get_legacy_name('sector_id')), |
|||
AsIs(openupgrade.get_legacy_name('sector_id')), |
|||
AsIs(openupgrade.get_legacy_name('old_sector_id')), |
|||
), |
|||
) |
|||
|
|||
|
|||
def fill_res_partner_industry_secondary(cr): |
|||
cr.execute( |
|||
""" |
|||
INSERT INTO res_partner_res_partner_industry_rel (res_partner_id, |
|||
res_partner_industry_id) |
|||
SELECT rel.res_partner_id, rpi.id |
|||
FROM res_partner_res_partner_sector_rel rel |
|||
LEFT JOIN res_partner_industry rpi |
|||
ON rel.res_partner_sector_id = rpi.%s |
|||
""", (AsIs(openupgrade.get_legacy_name('old_sector_id')), ), |
|||
) |
|||
|
|||
|
|||
@openupgrade.migrate(use_env=True) |
|||
def migrate(env, version): |
|||
cr = env.cr |
|||
if openupgrade.table_exists(cr, 'res_partner_sector'): |
|||
fill_res_partner_industry(cr) |
|||
env['res.partner.industry']._parent_store_compute() |
|||
update_res_partner_industry(cr) |
|||
fill_res_partner_industry_secondary(cr) |
@ -0,0 +1,27 @@ |
|||
# Copyright 2018 Eficent Business and IT Consulting Services, S.L. |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
from openupgradelib import openupgrade |
|||
from psycopg2.extensions import AsIs |
|||
|
|||
_column_renames = { |
|||
'res_partner': [('sector_id', None)], |
|||
} |
|||
|
|||
_xmlid_renames = [ |
|||
('partner_sector.group_use_partner_sector_for_person', |
|||
'partner_industry_secondary.group_use_partner_industry_for_person'), |
|||
] |
|||
|
|||
|
|||
@openupgrade.migrate(use_env=True) |
|||
def migrate(env, version): |
|||
cr = env.cr |
|||
if openupgrade.table_exists(cr, 'res_partner_sector'): |
|||
openupgrade.rename_columns(cr, _column_renames) |
|||
openupgrade.rename_xmlids(cr, _xmlid_renames) |
|||
cr.execute( |
|||
""" |
|||
ALTER TABLE res_partner_industry |
|||
ADD COLUMN %s integer; |
|||
""", (AsIs(openupgrade.get_legacy_name('old_sector_id')), ), |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue