Merge lp:~sylvain-legal/openupgrade-addons/7.0_purchase into lp:openupgrade-addons

Proposed by Sylvain LE GAL (GRAP)
Status: Merged
Merged at revision: 8145
Proposed branch: lp:~sylvain-legal/openupgrade-addons/7.0_purchase
Merge into: lp:openupgrade-addons
Diff against target: 249 lines (+230/-0)
4 files modified
purchase/migrations/7.0.1.1/openupgrade_analysis_work.txt (+109/-0)
purchase/migrations/7.0.1.1/post-migration.py (+81/-0)
purchase/migrations/7.0.1.1/pre-migration.py (+36/-0)
purchase/migrations/7.0.1.1/user_notes.txt (+4/-0)
To merge this branch: bzr merge lp:~sylvain-legal/openupgrade-addons/7.0_purchase
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Review via email: mp+186124@code.launchpad.net

Description of the change

'purchase' module.

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'purchase/migrations/7.0.1.1/openupgrade_analysis_work.txt'
2--- purchase/migrations/7.0.1.1/openupgrade_analysis_work.txt 1970-01-01 00:00:00 +0000
3+++ purchase/migrations/7.0.1.1/openupgrade_analysis_work.txt 2013-10-14 23:55:51 +0000
4@@ -0,0 +1,109 @@
5+---Fields in module 'purchase'---
6+
7+# 'dest_address_id' was a 'res.partner.address' object and is now a 'res.partner'. using 'set_partner_id_from_partner_address_id'. OK.
8+purchase / purchase.order / dest_address_id (many2one) : relation is now 'res.partner' ('res.partner.address')
9+
10+# 'partner_address_id' disappear in V7. Possible data loss, but script migration will not use this field to change 'supplier_id', because changing 'supplier_id' of a 'purchase_order' will break a lot of things. (avoicing, etc.) Nothing to do. (The field will just be rename). OK.
11+purchase / purchase.order / partner_address_id (many2one) : DEL relation: res.partner.address, required: required, req_default: function
12+
13+# 'journal_id' is a new field with default value. Nothing to do. OK.
14+purchase / purchase.order / journal_id (many2one) : NEW relation: account.journal
15+
16+# Ignore, no existing data to push as messages
17+purchase / purchase.order / message_ids (one2many) : NEW relation: mail.message
18+
19+### New field based on partner_id's property 'property_supplier_payment_term'.
20+# The migration script will set payment_term_id if the property is defined. OK.
21+purchase / purchase.order / payment_term_id (many2one) : NEW relation: account.payment.term
22+
23+# See 'stock' changes. Nothing to do. OK.
24+purchase / purchase.order / picking_ids (one2many) : relation is now 'stock.picking.in' ('stock.picking')
25+
26+### Change in keys
27+# DEL KEYS : ('wait') : Old unused state deleted. Nothing to do.
28+# NEW KEYS : ('sent') : New key. Nothing to do.
29+purchase / purchase.order / state (selection) : selection_keys is now '['approved', 'cancel', 'confirmed', 'done', 'draft', 'except_invoice', 'except_picking', 'sent']' ('['approved', 'cancel', 'confirmed', 'done', 'draft', 'except_invoice', 'except_picking', 'wait']')
30+
31+# Type change. Nothing to do.
32+purchase / purchase.order.line / name (char) : type is now 'text' ('char')
33+
34+# 'notes' field disappeared in v7. See (user notes #1). Merging 'name' and 'notes' fields. OK.
35+purchase / purchase.order.line / notes (text) : DEL
36+
37+### It's a view, so nothing to do.
38+purchase / purchase.report / dest_address_id (many2one) : DEL relation: res.partner.address
39+purchase / purchase.report / partner_address_id (many2one) : DEL relation: res.partner.address
40+purchase / purchase.report / state (selection) : selection_keys is now '['approved', 'cancel', 'confirmed', 'done', 'draft', 'except_invoice', 'except_picking']' ('['approved', 'cancel', 'confirmed', 'done', 'draft', 'except_invoice', 'except_picking', 'wait']')
41+
42+# New one2many field. target : 'purchase_order.partner_id'. Nothing to do.
43+purchase / res.partner / purchase_order_ids (one2many) : NEW relation: purchase.order
44+
45+# Not a real creation. Cf 'stock' migration. This field still exist in 6.1 in 'stock.picking' model. Nothing to do.
46+purchase / stock.picking.in / purchase_id (many2one) : NEW relation: purchase.order
47+
48+
49+---XML records in module 'purchase'---
50+
51+### Ignore interface and access records
52+NEW ir.actions.act_window: purchase.act_res_partner_2_supplier_invoices
53+NEW ir.actions.act_window: purchase.action_purchase_configuration
54+NEW ir.actions.act_window: purchase.purchase_pricelist_version_action
55+DEL ir.actions.act_window: purchase.act_purchase_order_2_stock_picking
56+DEL ir.actions.act_window: purchase.action_import_create_supplier_installer
57+DEL ir.actions.act_window: purchase.action_purchase_config
58+DEL ir.actions.act_window: purchase.action_supplier_address_form
59+DEL ir.actions.act_window: purchase.purchase_waiting
60+DEL ir.actions.act_window.view: purchase.action_picking_in_form_view
61+DEL ir.actions.act_window.view: purchase.action_picking_in_tree_view
62+DEL ir.actions.act_window.view: purchase.action_supplier_address_form_view1
63+DEL ir.actions.act_window.view: purchase.action_supplier_address_form_view2
64+DEL ir.actions.act_window.view: purchase.open_view_purchase_order_monthly_categ_graph
65+DEL ir.actions.act_window.view: purchase.open_view_purchase_order_monthly_categ_tree
66+NEW ir.actions.client: purchase.action_client_purchase_menu
67+DEL ir.actions.server: purchase.ir_actions_server_edi_purchase
68+NEW ir.actions.todo: base.open_menu
69+DEL ir.actions.todo: purchase.config_wizard_action_import_create_supplier_installer
70+DEL ir.actions.todo: purchase.todo_purchase_config
71+DEL ir.actions.todo.category: purchase.category_purchase_config
72+NEW ir.model.access: purchase.access_stock_warehouse_orderpoint_manager
73+DEL ir.model.access: purchase.access_res_partner_address_purchase_user
74+NEW ir.ui.menu: purchase.menu_product_pricelist_action2_purchase_type
75+NEW ir.ui.menu: purchase.menu_purchase_config
76+NEW ir.ui.menu: purchase.menu_purchase_pricelist_version_action
77+DEL ir.ui.menu: base.menu_procurement_management_supplier
78+DEL ir.ui.menu: purchase.menu_configuration_misc
79+DEL ir.ui.menu: purchase.menu_email_templates
80+DEL ir.ui.menu: purchase.menu_product_pricelist_action_purhase
81+DEL ir.ui.menu: purchase.menu_purchase_deshboard
82+NEW ir.ui.view: purchase.product_product_normal_form_procurement_help_view
83+NEW ir.ui.view: purchase.product_search_form_view_purchase
84+NEW ir.ui.view: purchase.purchase_order_2_stock_picking
85+NEW ir.ui.view: purchase.purchase_partner_kanban_view
86+NEW ir.ui.view: purchase.res_partner_view_purchase_buttons
87+NEW ir.ui.view: purchase.view_account_config
88+NEW ir.ui.view: purchase.view_picking_in_search_picking_inherit
89+NEW ir.ui.view: purchase.view_product_account_purchase_ok_form
90+NEW ir.ui.view: purchase.view_product_supplier_inherit
91+NEW ir.ui.view: purchase.view_purchase_configuration
92+NEW ir.ui.view: purchase.view_template_purchase_ok_form
93+DEL ir.ui.view: purchase.stock_picking_inherit_purchase
94+DEL ir.ui.view: purchase.view_picking_in_search_picking_to_invoice
95+DEL ir.ui.view: purchase.view_purchase_config
96+
97+### Ignore added chatter configuration
98+NEW mail.message: purchase.module_install_notification
99+NEW mail.message.subtype: purchase.mt_rfq_approved
100+NEW mail.message.subtype: purchase.mt_rfq_confirmed
101+
102+### Ignore groups configuration
103+NEW res.groups: purchase.group_analytic_accounting
104+
105+### New activity 'act_sent' and associated transitions. Nothing to do.
106+NEW workflow.activity: purchase.act_sent
107+NEW workflow.transition: purchase.trans_draft_sent
108+NEW workflow.transition: purchase.trans_sent_cancel
109+NEW workflow.transition: purchase.trans_sent_confirmed
110+
111+# Xml_id rename has been done in 'procurement' module. Nothing to do.
112+NEW workflow.transition: purchase.trans_confirm_mto_purchase
113+DEL workflow.transition: procurement.trans_confirm_mto_purchase
114
115=== added file 'purchase/migrations/7.0.1.1/post-migration.py'
116--- purchase/migrations/7.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
117+++ purchase/migrations/7.0.1.1/post-migration.py 2013-10-14 23:55:51 +0000
118@@ -0,0 +1,81 @@
119+# -*- coding: utf-8 -*-
120+##############################################################################
121+#
122+# OpenERP, Open Source Management Solution
123+# This module copyright (C) 2013 Sylvain LE GAL
124+#
125+# This program is free software: you can redistribute it and/or modify
126+# it under the terms of the GNU Affero General Public License as
127+# published by the Free Software Foundation, either version 3 of the
128+# License, or (at your option) any later version.
129+#
130+# This program is distributed in the hope that it will be useful,
131+# but WITHOUT ANY WARRANTY; without even the implied warranty of
132+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
133+# GNU Affero General Public License for more details.
134+#
135+# You should have received a copy of the GNU Affero General Public License
136+# along with this program. If not, see <http://www.gnu.org/licenses/>.
137+#
138+##############################################################################
139+from openerp import pooler, SUPERUSER_ID
140+from openerp.openupgrade import openupgrade, openupgrade_70
141+
142+def migrate_purchase_order_addresses(cr, pool):
143+ # 'dest_address_id' is now a 'partner' object.
144+ openupgrade_70.set_partner_id_from_partner_address_id(
145+ cr, pool, 'purchase.order',
146+ 'dest_address_id', openupgrade.get_legacy_name('dest_address_id'))
147+
148+def migrate_purchase_order_line_names(cr, pool):
149+ """
150+ Join existing char values and obsolete notes values into
151+ new text field name on the purchase order line.
152+ """
153+ purchase_order_line_obj = pool.get('purchase.order.line')
154+ cr.execute("""
155+ SELECT id, {0}, {1}
156+ FROM purchase_order_line
157+ WHERE {1} is not NULL AND {1} != ''
158+ """.format(
159+ 'name',
160+ openupgrade.get_legacy_name('notes')))
161+ for (purchase_order_line_id, name, notes) in cr.fetchall():
162+ name = name + '\n' if name else ''
163+ purchase_order_line_obj.write(
164+ cr, SUPERUSER_ID, [purchase_order_line_id],
165+ {'name': name + notes})
166+
167+def set_purchase_order_payment_term(cr, pool):
168+ """
169+ Set a journal_id for each purchase_order, using the script similar to
170+ the function _get_journal_id, used in V7 when creating a new purchase order.
171+ """
172+ partner_obj = pool.get('res.partner')
173+ purchase_order_obj = pool.get('purchase.order')
174+ res_user_obj = pool.get('res.users')
175+ cr.execute("SELECT id, partner_id, create_uid, write_uid FROM purchase_order")
176+
177+ for (purchase_order_id, partner_id, create_uid, write_uid) in cr.fetchall():
178+ # get the property as viewed by the partner who created / modified the purchase order.
179+ if write_uid :
180+ uid = write_uid
181+ else:
182+ uid =create_uid
183+ my_user = res_user_obj.browse(cr, SUPERUSER_ID, uid)
184+ partner_company_id = partner_obj.browse(cr, SUPERUSER_ID, partner_id).company_id.id
185+ if my_user.company_id.id != partner_company_id:
186+ res_user_obj.write(cr, SUPERUSER_ID, uid, {'company_id' : partner_company_id})
187+ supplier = partner_obj.browse(cr, uid, partner_id)
188+ my_property_supplier_payment_term = supplier.property_supplier_payment_term.id
189+ purchase_order_obj.write(
190+ cr, SUPERUSER_ID, [purchase_order_id],
191+ {'payment_term_id': my_property_supplier_payment_term})
192+
193+@openupgrade.migrate()
194+def migrate(cr, version):
195+ pool = pooler.get_pool(cr.dbname)
196+ migrate_purchase_order_addresses(cr, pool)
197+ set_purchase_order_payment_term(cr, pool)
198+ migrate_purchase_order_line_names(cr, pool)
199+
200
201=== added file 'purchase/migrations/7.0.1.1/pre-migration.py'
202--- purchase/migrations/7.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
203+++ purchase/migrations/7.0.1.1/pre-migration.py 2013-10-14 23:55:51 +0000
204@@ -0,0 +1,36 @@
205+# -*- coding: utf-8 -*-
206+##############################################################################
207+#
208+# OpenERP, Open Source Management Solution
209+# This module copyright (C) 2013 Sylvain LE GAL
210+#
211+# This program is free software: you can redistribute it and/or modify
212+# it under the terms of the GNU Affero General Public License as
213+# published by the Free Software Foundation, either version 3 of the
214+# License, or (at your option) any later version.
215+#
216+# This program is distributed in the hope that it will be useful,
217+# but WITHOUT ANY WARRANTY; without even the implied warranty of
218+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
219+# GNU Affero General Public License for more details.
220+#
221+# You should have received a copy of the GNU Affero General Public License
222+# along with this program. If not, see <http://www.gnu.org/licenses/>.
223+#
224+##############################################################################
225+
226+from openerp.openupgrade import openupgrade
227+
228+column_renames = {
229+ 'purchase_order':[
230+ ('dest_address_id', None),
231+ ('partner_address_id', None),
232+ ],
233+ 'purchase_order_line':[
234+ ('notes', None),
235+ ],
236+}
237+
238+@openupgrade.migrate()
239+def migrate(cr, version):
240+ openupgrade.rename_columns(cr, column_renames)
241
242=== added file 'purchase/migrations/7.0.1.1/user_notes.txt'
243--- purchase/migrations/7.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
244+++ purchase/migrations/7.0.1.1/user_notes.txt 2013-10-14 23:55:51 +0000
245@@ -0,0 +1,4 @@
246+********************************************************************************
247+1/ In 6.1 there is two textual fields in 'purchase.order.line'. (name & notes). In 7.0, 'notes' field disapeared.
248+
249+To avoid loosing data, the script will merge 'name' & 'notes' field.

Subscribers

People subscribed via source and target branches