Browse Source

[12.0][MIG] partner_industry_secondary: Migration to v12

pull/722/head
Cristina Martin 6 years ago
committed by Jairo Llopis
parent
commit
c8480c13a0
  1. 1
      partner_industry_secondary/README.rst
  2. 5
      partner_industry_secondary/__manifest__.py
  3. 9
      partner_industry_secondary/i18n/partner_industry_secondary.pot
  4. 10
      partner_industry_secondary/i18n/partner_sector.pot
  5. 40
      partner_industry_secondary/migrations/11.0.1.0.0/openupgrade_analysis.txt
  6. 55
      partner_industry_secondary/migrations/11.0.1.0.0/openupgrade_analysis_work.txt
  7. 67
      partner_industry_secondary/migrations/11.0.1.0.0/post-migration.py
  8. 27
      partner_industry_secondary/migrations/11.0.1.0.0/pre-migration.py
  9. 9
      partner_industry_secondary/migrations/12.0.1.0.0/post-migration.py
  10. 2
      partner_industry_secondary/models/res_partner.py
  11. 6
      partner_industry_secondary/models/res_partner_industry.py
  12. 1
      partner_industry_secondary/readme/CONTRIBUTORS.rst
  13. 2
      partner_industry_secondary/views/res_partner_industry_view.xml

1
partner_industry_secondary/README.rst

@ -85,6 +85,7 @@ Contributors
* Luis M. Ontalba <luis.martinez@tecnativa.com>
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Miquel Raïch <miquel.raich@eficent.com>
* Cristina Martin R.
Maintainers
~~~~~~~~~~~

5
partner_industry_secondary/__manifest__.py

@ -1,12 +1,13 @@
# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016-2017 Tecnativa S.L. - Vicent Cubells
# Copyright 2019 Tecnativa S.L. - Cristina Martin R.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Partner Industry Secondary",
"summary": "Add secondary partner industries",
"version": "11.0.1.0.0",
"category": "Customer Relationship Management",
"version": "12.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/partner-contact",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",

9
partner_industry_secondary/i18n/partner_industry_secondary.pot

@ -56,14 +56,10 @@ msgid "Parent"
msgstr ""
#. module: partner_industry_secondary
#: model:ir.model.fields,field_description:partner_industry_secondary.field_res_partner_industry_parent_left
msgid "Parent Left"
#: model:ir.model.fields,field_description:partner_industry_secondary.field_res_partner_industry_parent_path
msgid "Parent Path"
msgstr ""
#. module: partner_industry_secondary
#: model:ir.model.fields,field_description:partner_industry_secondary.field_res_partner_industry_parent_right
msgid "Parent Right"
msgstr ""
#. module: partner_industry_secondary
#: model:ir.ui.view,arch_db:partner_industry_secondary.res_config_settings_view_form
@ -102,4 +98,3 @@ msgstr ""
#: model:ir.model,name:partner_industry_secondary.model_res_config_settings
msgid "res.config.settings"
msgstr ""

10
partner_industry_secondary/i18n/partner_sector.pot

@ -72,13 +72,8 @@ msgid "Name"
msgstr ""
#. module: partner_sector
#: model:ir.model.fields,field_description:partner_sector.field_res_partner_sector_parent_left
msgid "Parent Left"
msgstr ""
#. module: partner_sector
#: model:ir.model.fields,field_description:partner_sector.field_res_partner_sector_parent_right
msgid "Parent Right"
#: model:ir.model.fields,field_description:partner_sector.field_res_partner_sector_parent_path
msgid "Parent Path"
msgstr ""
#. module: partner_sector
@ -117,4 +112,3 @@ msgstr ""
#, python-format
msgid "The main sector must be different from the secondary sectors."
msgstr ""

40
partner_industry_secondary/migrations/11.0.1.0.0/openupgrade_analysis.txt

@ -1,40 +0,0 @@
---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

55
partner_industry_secondary/migrations/11.0.1.0.0/openupgrade_analysis_work.txt

@ -1,55 +0,0 @@
---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

67
partner_industry_secondary/migrations/11.0.1.0.0/post-migration.py

@ -1,67 +0,0 @@
# 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)

27
partner_industry_secondary/migrations/11.0.1.0.0/pre-migration.py

@ -1,27 +0,0 @@
# 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')), ),
)

9
partner_industry_secondary/migrations/12.0.1.0.0/post-migration.py

@ -0,0 +1,9 @@
# Copyright 2019 Tecnativa - Cristina Martin R.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
@openupgrade.migrate(use_env=True)
def migrate(env, version):
env['res.partner.industry']._parent_store_compute()

2
partner_industry_secondary/models/res_partner.py

@ -18,6 +18,6 @@ class ResPartner(models.Model):
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
if self.industry_id in self.secondary_industry_ids:
raise exceptions.UserError(
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))

6
partner_industry_secondary/models/res_partner_industry.py

@ -2,6 +2,7 @@
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2016 Tecnativa S.L. - Pedro M. Baeza
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# Copyright 2019 Tecnativa - Cristina Martin R.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
@ -9,7 +10,7 @@ from odoo import api, exceptions, fields, models, _
class ResPartnerIndustry(models.Model):
_inherit = 'res.partner.industry'
_order = "parent_left"
_order = "parent_path"
_parent_order = "name"
_parent_store = True
@ -19,8 +20,7 @@ class ResPartnerIndustry(models.Model):
child_ids = fields.One2many(comodel_name='res.partner.industry',
inverse_name='parent_id',
string="Children")
parent_left = fields.Integer('Parent Left', index=True)
parent_right = fields.Integer('Parent Right', index=True)
parent_path = fields.Char(index=True)
@api.multi
def name_get(self):

1
partner_industry_secondary/readme/CONTRIBUTORS.rst

@ -6,3 +6,4 @@
* Luis M. Ontalba <luis.martinez@tecnativa.com>
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Miquel Raïch <miquel.raich@eficent.com>
* Cristina Martin R.

2
partner_industry_secondary/views/res_partner_industry_view.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2015 Antiun Ingenieria S.L. - Javier Iniesta
<!-- Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
Copyright 2018 Eficent Business and IT Consulting Services, S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>

Loading…
Cancel
Save