Merge lp:~savoirfairelinux-openerp/openupgrade-addons/sale_crm into lp:openupgrade-addons

Status: Merged
Merged at revision: 8172
Proposed branch: lp:~savoirfairelinux-openerp/openupgrade-addons/sale_crm
Merge into: lp:openupgrade-addons
Diff against target: 102 lines (+88/-0)
3 files modified
sale_crm/migrations/7.0.1.0/openupgrade_analysis_work.txt (+23/-0)
sale_crm/migrations/7.0.1.0/post-migration.py (+31/-0)
sale_crm/migrations/7.0.1.0/pre-migration.py (+34/-0)
To merge this branch: bzr merge lp:~savoirfairelinux-openerp/openupgrade-addons/sale_crm
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Pedro Manuel Baeza Needs Fixing
Maxime Chambreuil (http://www.savoirfairelinux.com) (community) Approve
Review via email: mp+234126@code.launchpad.net

Description of the change

Migrate categ_id to categ_ids

To post a comment you must log in.
Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Some comments inline

review: Needs Fixing (code review)
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

My explanation

Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

Updated typos + had the files at the root instead of in sale_crm

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Please refer also in a file user_notes.txt that the migration is not completed.

review: Needs Fixing
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

I don't know if it is incomplete, there are no problems with the new fields.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Well, then put as nothing to do then. The goal is to inform people is there is something still that it hasn't been checked and might need something in the script. If you are sure that the rest of the changes doesn't need it, then put nothing to do and people will know that script is completed.

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Pedro: I don't really understand your last comment. Could you explain what you mean here?

review: Approve (code review)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

What I try to say is: if migration script is not completed or you don't know if it's completed, then say it; if it's completed, then say it also.

Revision history for this message
Yann Papouin (yann-papouin) wrote :

I'm getting the following error when upgrading from 6.1 and it seems to be related to a workflow trigger:

2014-10-29 15:33:16,648 8281 INFO db OpenUpgrade: sale_crm: post-migration script called with version 6.1.1.0
2014-10-29 15:33:16,772 8281 ERROR db openerp.tools.safe_eval: Cannot eval u"test_state('canceled')"
Traceback (most recent call last):
  File "/home/ubuntu/projects/openupgrade/server/openerp/tools/safe_eval.py", line 241, in safe_eval
    return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "", line 1, in <module>
NameError: name 'test_state' is not defined
2014-10-29 15:33:16,800 8281 ERROR db OpenUpgrade: sale_crm: error in migration script /home/ubuntu/projects/openupgrade/addons/sale_crm/migrations/7.0.1.0/post-migration.py: name 'test_state' is not defined
2014-10-29 15:33:16,800 8281 ERROR db OpenUpgrade: name 'test_state' is not defined

Traceback (most recent call last):
  File "/home/ubuntu/projects/openupgrade/server/openerp/openupgrade/openupgrade.py", line 473, in wrapped_function
    func(cr, version)
  File "/home/ubuntu/projects/openupgrade/addons/sale_crm/migrations/7.0.1.0/post-migration.py", line 31, in migrate
    openupgrade.get_legacy_name('categ_id'))
  File "/home/ubuntu/projects/openupgrade/server/openerp/openupgrade/openupgrade.py", line 414, in m2o_to_m2m
    model.write(cr, SUPERUSER_ID, row[0], {field: [(4, row[1])]})
  File "/home/ubuntu/projects/openupgrade/addons/mail/mail_thread.py", line 264, in write
    result = super(mail_thread, self).write(cr, uid, ids, values, context=context)
  File "/home/ubuntu/projects/openupgrade/server/openerp/osv/orm.py", line 4299, in write
    self._workflow_trigger(cr, user, ids, 'trg_write', context=context)
  File "/home/ubuntu/projects/openupgrade/server/openerp/osv/orm.py", line 3946, in _workflow_trigger
    getattr(wf_service, trigger)(uid, self._name, res_id, cr)
  File "/home/ubuntu/projects/openupgrade/server/openerp/workflow/wkf_service.py", line 55, in trg_write
    instance.update(cr, id, ident)
  File "/home/ubuntu/projects/openupgrade/server/openerp/workflow/instance.py", line 52, in update
    workitem.process(cr, witem, ident, stack=stack)
  File "/home/ubuntu/projects/openupgrade/server/openerp/workflow/workitem.py", line 60, in process
    ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack)
  File "/home/ubuntu/projects/openupgrade/server/openerp/workflow/workitem.py", line 157, in _split_test
    if wkf_expr.check(cr, workitem, ident, transition,signal):
  File "/home/ubuntu/projects/openupgrade/server/openerp/workflow/wkf_expr.py", line 80, in check
    return _eval_expr(cr, ident, workitem, transition['condition'])
  File "/home/ubuntu/projects/openupgrade/server/openerp/workflow/wkf_expr.py", line 57, in _eval_expr
    ret = eval(line, env, nocopy=True)
  File "/home/ubuntu/projects/openupgrade/server/openerp/tools/safe_eval.py", line 241, in safe_eval
    return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "", line 1, in <module>
NameError: name 'test_state' is not defined

I'm watching into this but any tip to fix this is welcome :)

Revision history for this message
Yann Papouin (yann-papouin) wrote :

Ok it is fixed for me.
"test_state" is defined in the "sale_stock" module, so I retry an upgrade by forcing

[openupgrade]
forced_deps = {'sale_crm': ['sale_stock']}

But it was not working, I had to edit the "sale_crm" manifest:
'depends': ['sale', 'crm', 'sale_stock'],

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

@yann thanks for the feedback. I created a bug to track this issue separately: https://bugs.launchpad.net/openupgrade-addons/+bug/1387613

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'sale_crm/migrations/7.0.1.0/openupgrade_analysis_work.txt'
2--- sale_crm/migrations/7.0.1.0/openupgrade_analysis_work.txt 1970-01-01 00:00:00 +0000
3+++ sale_crm/migrations/7.0.1.0/openupgrade_analysis_work.txt 2014-09-10 18:44:45 +0000
4@@ -0,0 +1,23 @@
5+---Fields in module 'sale_crm'---
6+
7+# Convert from m2o to m2m
8+sale_crm / sale.order / categ_id (many2one) : DEL relation: crm.case.categ
9+sale_crm / sale.order / categ_ids (many2many) : NEW relation: crm.case.categ
10+
11+sale_crm / account.invoice / section_id (many2one) : NEW relation: crm.case.section
12+sale_crm / account.invoice.report / section_id (many2one) : NEW relation: crm.case.section
13+sale_crm / res.users / default_section_id (many2one) : NEW relation: crm.case.section
14+
15+
16+---XML records in module 'sale_crm'---
17+DEL ir.ui.menu: base.menu_base_partner
18+NEW ir.ui.view: sale_crm.account_invoice_form
19+NEW ir.ui.view: sale_crm.account_invoice_groupby_inherit
20+NEW ir.ui.view: sale_crm.account_invoice_report_tree
21+NEW ir.ui.view: sale_crm.account_invoice_tree
22+NEW ir.ui.view: sale_crm.res_user_form
23+NEW ir.ui.view: sale_crm.view_users_form_preferences
24+DEL ir.ui.view: sale_crm.board_crm_form_inherit_replace1
25+DEL ir.ui.view: sale_crm.board_crm_form_inherit_replace3
26+NEW mail.message.subtype: sale_crm.mt_salesteam_order_confirmed
27+NEW mail.message.subtype: sale_crm.mt_salesteam_order_sent
28
29=== added file 'sale_crm/migrations/7.0.1.0/post-migration.py'
30--- sale_crm/migrations/7.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
31+++ sale_crm/migrations/7.0.1.0/post-migration.py 2014-09-10 18:44:45 +0000
32@@ -0,0 +1,31 @@
33+# -*- encoding: utf-8 -*-
34+##############################################################################
35+#
36+# OpenERP, Open Source Management Solution
37+# This module copyright (C) 2014 Savoir-faire Linux
38+# (<http://www.savoirfairelinux.com>).
39+#
40+# This program is free software: you can redistribute it and/or modify
41+# it under the terms of the GNU Affero General Public License as
42+# published by the Free Software Foundation, either version 3 of the
43+# License, or (at your option) any later version.
44+#
45+# This program is distributed in the hope that it will be useful,
46+# but WITHOUT ANY WARRANTY; without even the implied warranty of
47+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48+# GNU Affero General Public License for more details.
49+#
50+# You should have received a copy of the GNU Affero General Public License
51+# along with this program. If not, see <http://www.gnu.org/licenses/>.
52+#
53+##############################################################################
54+
55+from openerp import pooler
56+from openupgrade import openupgrade
57+
58+
59+@openupgrade.migrate()
60+def migrate(cr, version):
61+ pool = pooler.get_pool(cr.dbname)
62+ openupgrade.m2o_to_m2m(cr, pool['sale.order'], 'sale_order', 'categ_ids',
63+ openupgrade.get_legacy_name('categ_id'))
64
65=== added file 'sale_crm/migrations/7.0.1.0/pre-migration.py'
66--- sale_crm/migrations/7.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
67+++ sale_crm/migrations/7.0.1.0/pre-migration.py 2014-09-10 18:44:45 +0000
68@@ -0,0 +1,34 @@
69+# -*- encoding: utf-8 -*-
70+##############################################################################
71+#
72+# OpenERP, Open Source Management Solution
73+# This module copyright (C) 2014 Savoir-faire Linux
74+# (<http://www.savoirfairelinux.com>).
75+#
76+# This program is free software: you can redistribute it and/or modify
77+# it under the terms of the GNU Affero General Public License as
78+# published by the Free Software Foundation, either version 3 of the
79+# License, or (at your option) any later version.
80+#
81+# This program is distributed in the hope that it will be useful,
82+# but WITHOUT ANY WARRANTY; without even the implied warranty of
83+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84+# GNU Affero General Public License for more details.
85+#
86+# You should have received a copy of the GNU Affero General Public License
87+# along with this program. If not, see <http://www.gnu.org/licenses/>.
88+#
89+##############################################################################
90+
91+from openupgrade import openupgrade
92+
93+column_renames = {
94+ 'sale_order': [
95+ ('categ_id', None),
96+ ],
97+}
98+
99+
100+@openupgrade.migrate()
101+def migrate(cr, version):
102+ openupgrade.rename_columns(cr, column_renames)

Subscribers

People subscribed via source and target branches