Skip to content

Commit

Permalink
Rename xmlids to avoid conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
cubells committed Feb 3, 2017
1 parent a6eba81 commit 6c26edc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions crm_phonecall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,32 @@
from . import models
from . import wizard
from . import report


xmlid_renames = [
('crm.group_scheduled_calls', 'crm_phonecall.group_scheduled_calls'),
('crm.filter_crm_phonecall_phone_call_to_do',
'crm_phonecall.filter_crm_phonecall_phone_call_to_do'),
('crm.filter_crm_phonecall_delay_to_close',
'crm_phonecall.filter_crm_phonecall_delay_to_close'),
('crm.filter_crm_phonecall_sales_team',
'crm_phonecall.filter_crm_phonecall_sales_team'),
]


def column_exists(cr, table, column):
cr.execute("""
SELECT column_name
FROM information_schema.columns
WHERE table_name = %s AND column_name = %s""", (table, column))
return bool(cr.fetchall())


def rename_xmlids_hook(cr):
# Retrieve column phone_id saved on crm migration
if column_exists(cr, 'calendar_event', 'phone_id'):
cr.execute("""
ALTER TABLE calendar_event
RENAME COLUMN openupgrade_legacy_90_phone_id TO phone_id""")
from openupgradelib import openupgrade
openupgrade.rename_xmlids(cr, xmlid_renames)
4 changes: 4 additions & 0 deletions crm_phonecall/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'crm',
'calendar',
],
'external_dependencies': {
'python': ['openupgradelib'],
},
"data": [
'security/crm_security.xml',
'security/ir.model.access.csv',
Expand All @@ -27,4 +30,5 @@
'report/crm_phonecall_report_view.xml',
],
'installable': True,
"pre_init_hook": "rename_xmlids_hook",
}

0 comments on commit 6c26edc

Please sign in to comment.