Merge lp:~therp-nl/openupgrade-addons/6.0-hr-project-stock into lp:openupgrade-addons/6.0

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 4781
Proposed branch: lp:~therp-nl/openupgrade-addons/6.0-hr-project-stock
Merge into: lp:openupgrade-addons/6.0
Diff against target: 2210 lines (+1840/-22)
65 files modified
account/migrations/6.0.1.1/post-migration.py (+24/-13)
account/migrations/6.0.1.1/pre-migration.py (+27/-9)
account_analytic_analysis/migrations/6.0.1.1/user_notes.txt (+1/-0)
account_analytic_default/migrations/6.0.1.0/user_notes.txt (+1/-0)
account_analytic_plans/migrations/6.0.1.0/user_notes.txt (+1/-0)
account_budget/migrations/6.0.1.0/post-migration.py (+41/-0)
account_budget/migrations/6.0.1.0/user_notes.txt (+2/-0)
account_payment/migrations/6.0.1.1/data.xml (+13/-0)
account_payment/migrations/6.0.1.1/post-migration.py (+37/-0)
account_payment/migrations/6.0.1.1/pre-migration.py (+35/-0)
account_payment/migrations/6.0.1.1/user_notes.txt (+3/-0)
analytic_user_function/migrations/6.0.1.0/user_notes.txt (+1/-0)
audittrail/migrations/6.0.1.0/user_notes.txt (+1/-0)
base_iban/migrations/6.0.1.0/user_notes.txt (+1/-0)
base_report_creator/migrations/6.0.1.0/user_notes.txt (+1/-0)
base_report_designer/migrations/6.0.0.1/user_notes.txt (+3/-0)
board/migrations/6.0.1.0/user_notes.txt (+1/-0)
hr/migrations/6.0.1.1/data.xml (+20/-0)
hr/migrations/6.0.1.1/post-migration.py (+187/-0)
hr/migrations/6.0.1.1/pre-migration.py (+67/-0)
hr/migrations/6.0.1.1/user_notes.txt (+6/-0)
hr_attendance/migrations/6.0.1.1/user_notes.txt (+1/-0)
hr_contract/migrations/6.0.1.0/data.xml (+19/-0)
hr_contract/migrations/6.0.1.0/post-migration.py (+83/-0)
hr_contract/migrations/6.0.1.0/pre-migration.py (+35/-0)
hr_contract/migrations/6.0.1.0/user_notes.txt (+3/-0)
hr_expense/migrations/6.0.1.0/post-migration.py (+34/-0)
hr_expense/migrations/6.0.1.0/user_notes.txt (+1/-0)
hr_timesheet/migrations/6.0.1.0/user_notes.txt (+1/-0)
hr_timesheet_invoice/migrations/6.0.1.0/user_notes.txt (+1/-0)
hr_timesheet_sheet/migrations/6.0.1.0/post-migration.py (+55/-0)
hr_timesheet_sheet/migrations/6.0.1.0/pre-migration.py (+34/-0)
hr_timesheet_sheet/migrations/6.0.1.0/user_notes.txt (+1/-0)
mrp/migrations/6.0.1.1/post-migration.py (+64/-0)
mrp/migrations/6.0.1.1/pre-migration.py (+38/-0)
mrp/migrations/6.0.1.1/user_notes.txt (+1/-0)
process/migrations/6.0.1.0/user_notes.txt (+1/-0)
procurement/migrations/6.0.1.0/data.xml (+22/-0)
procurement/migrations/6.0.1.0/post-migration.py (+34/-0)
procurement/migrations/6.0.1.0/pre-migration.py (+84/-0)
procurement/migrations/6.0.1.0/user_notes.txt (+1/-0)
product/migrations/6.0.1.1/data.xml (+66/-0)
product/migrations/6.0.1.1/post-migration.py (+35/-0)
product/migrations/6.0.1.1/pre-migration.py (+46/-0)
product/migrations/6.0.1.1/user_notes.txt (+5/-0)
project/migrations/6.0.1.1/post-migration.py (+168/-0)
project/migrations/6.0.1.1/pre-migration.py (+55/-0)
project/migrations/6.0.1.1/user_notes.txt (+2/-0)
project_timesheet/migrations/6.0.1.0/post-migration.py (+43/-0)
project_timesheet/migrations/6.0.1.0/pre-migration.py (+34/-0)
project_timesheet/migrations/6.0.1.0/user_notes.txt (+1/-0)
purchase/migrations/6.0.1.1/data.xml (+20/-0)
purchase/migrations/6.0.1.1/post-migration.py (+50/-0)
purchase/migrations/6.0.1.1/pre-migration.py (+47/-0)
purchase/migrations/6.0.1.1/user_notes.txt (+2/-0)
purchase_analytic_plans/migrations/6.0.1.0/user_notes.txt (+1/-0)
sale/migrations/6.0.1.0/post-migration.py (+53/-0)
sale/migrations/6.0.1.0/pre-migration.py (+34/-0)
sale/migrations/6.0.1.0/user_notes.txt (+1/-0)
sale_analytic_plans/migrations/6.0.1.0/user_notes.txt (+1/-0)
sale_journal/migrations/6.0.1.0/user_notes.txt (+1/-0)
stock/migrations/6.0.1.1/data.xml (+62/-0)
stock/migrations/6.0.1.1/post-migration.py (+84/-0)
stock/migrations/6.0.1.1/pre-migration.py (+42/-0)
stock/migrations/6.0.1.1/user_notes.txt (+1/-0)
To merge this branch: bzr merge lp:~therp-nl/openupgrade-addons/6.0-hr-project-stock
Reviewer Review Type Date Requested Status
OpenUpgrade Committers Pending
Review via email: mp+109195@code.launchpad.net

Description of the change

This branch adds support for migrating the following modules from OpenERP 5 to OpenERP 6.0:

account_analytic_analysis
account_analytic_default
account_analytic_plans
account_budget
account_payment
analytic_user_function
audittrail
base_iban
base_report_creator
base_report_designer
board
hr
hr_attendance
hr_contract
hr_expense
hr_timesheet
hr_timesheet_invoice
hr_timesheet_sheet
mrp
process
procurement
product
project
project_timesheet
purchase
purchase_analytic_plans
sale
sale_analytic_plans
sale_journal
stock

The scripts in this branch use some new API additions from https://code.launchpad.net/~therp-nl/openupgrade-server/6.0-API_and_loading_improvements

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/migrations/6.0.1.1/post-migration.py'
2--- account/migrations/6.0.1.1/post-migration.py 2011-11-30 23:09:14 +0000
3+++ account/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
4@@ -1,12 +1,27 @@
5 # -*- coding: utf-8 -*-
6+##############################################################################
7+#
8+# OpenERP, Open Source Management Solution
9+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
10+#
11+# This program is free software: you can redistribute it and/or modify
12+# it under the terms of the GNU Affero General Public License as
13+# published by the Free Software Foundation, either version 3 of the
14+# License, or (at your option) any later version.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU Affero General Public License for more details.
20+#
21+# You should have received a copy of the GNU Affero General Public License
22+# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+#
24+##############################################################################
25
26-from osv import osv
27-import pooler, logging
28-log = logging.getLogger('migrate')
29+import pooler
30 from openupgrade import openupgrade
31
32-MODULE='account'
33-
34 defaults = {
35 # False results in column value NULL
36 # None value triggers a call to the model's default function
37@@ -27,12 +42,8 @@
38 ],
39 }
40
41+@openupgrade.migrate()
42 def migrate(cr, version):
43- try:
44- log.info("post-set-defaults.py now called")
45- pool = pooler.get_pool(cr.dbname)
46- openupgrade.set_defaults(cr, pool, defaults)
47- openupgrade.load_xml(cr, MODULE, 'migrations/6.0.1.1/data.xml')
48- except Exception, e:
49- log.error("Migration: error in post.py: %s" % e)
50- raise
51+ pool = pooler.get_pool(cr.dbname)
52+ openupgrade.set_defaults(cr, pool, defaults)
53+ openupgrade.load_xml(cr, 'account', 'migrations/6.0.1.1/data.xml')
54
55=== modified file 'account/migrations/6.0.1.1/pre-migration.py'
56--- account/migrations/6.0.1.1/pre-migration.py 2011-11-30 23:09:14 +0000
57+++ account/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
58@@ -1,9 +1,27 @@
59 # -*- coding: utf-8 -*-
60-import logging
61+##############################################################################
62+#
63+# OpenERP, Open Source Management Solution
64+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
65+#
66+# This program is free software: you can redistribute it and/or modify
67+# it under the terms of the GNU Affero General Public License as
68+# published by the Free Software Foundation, either version 3 of the
69+# License, or (at your option) any later version.
70+#
71+# This program is distributed in the hope that it will be useful,
72+# but WITHOUT ANY WARRANTY; without even the implied warranty of
73+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74+# GNU Affero General Public License for more details.
75+#
76+# You should have received a copy of the GNU Affero General Public License
77+# along with this program. If not, see <http://www.gnu.org/licenses/>.
78+#
79+##############################################################################
80+
81+from tools import sql
82 from openupgrade import openupgrade
83
84-logger = logging.getLogger('migrate')
85-
86 column_renames = {
87 # this is a mapping per table from old column name
88 # to new column name
89@@ -20,11 +38,11 @@
90 cr.execute("UPDATE account_journal SET type = 'sale_refund' " +
91 "where type = 'sale' and refund_journal = TRUE")
92
93+@openupgrade.migrate()
94 def migrate(cr, version):
95- try:
96- openupgrade.rename_columns(cr, column_renames)
97- mgr_refund_journal_type(cr)
98- except Exception, e:
99- log.error("Migration: error in pre.py: %s" % e)
100- raise
101+ openupgrade.rename_columns(cr, column_renames)
102+ # This view, previously in report_account module
103+ # changes data type of one of the columns
104+ sql.drop_view_if_exists(cr, 'report_invoice_created')
105+ mgr_refund_journal_type(cr)
106
107
108=== added file 'account_analytic_analysis/migrations/6.0.1.1/user_notes.txt'
109--- account_analytic_analysis/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
110+++ account_analytic_analysis/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
111@@ -0,0 +1,1 @@
112+Nothing to do for module 'account_analytic_analysis'
113
114=== added file 'account_analytic_default/migrations/6.0.1.0/user_notes.txt'
115--- account_analytic_default/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
116+++ account_analytic_default/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
117@@ -0,0 +1,1 @@
118+Nothing to do for module 'account_analytic_default'
119
120=== added file 'account_analytic_plans/migrations/6.0.1.0/user_notes.txt'
121--- account_analytic_plans/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
122+++ account_analytic_plans/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
123@@ -0,0 +1,1 @@
124+Nothing to do for module 'account_analytic_plans'
125
126=== added file 'account_budget/migrations/6.0.1.0/post-migration.py'
127--- account_budget/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
128+++ account_budget/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
129@@ -0,0 +1,41 @@
130+# -*- coding: utf-8 -*-
131+##############################################################################
132+#
133+# OpenERP, Open Source Management Solution
134+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
135+#
136+# This program is free software: you can redistribute it and/or modify
137+# it under the terms of the GNU Affero General Public License as
138+# published by the Free Software Foundation, either version 3 of the
139+# License, or (at your option) any later version.
140+#
141+# This program is distributed in the hope that it will be useful,
142+# but WITHOUT ANY WARRANTY; without even the implied warranty of
143+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144+# GNU Affero General Public License for more details.
145+#
146+# You should have received a copy of the GNU Affero General Public License
147+# along with this program. If not, see <http://www.gnu.org/licenses/>.
148+#
149+##############################################################################
150+
151+import pooler
152+from openupgrade import openupgrade
153+
154+MODULE='account_budget'
155+
156+defaults_force = {
157+ # False results in column value NULL
158+ # None value triggers a call to the model's default function
159+ 'account.budget.post': [
160+ ('company_id', None),
161+ ],
162+ 'crossovered.budget': [
163+ ('company_id', None),
164+ ],
165+ }
166+
167+@openupgrade.migrate()
168+def migrate(cr, version):
169+ pool = pooler.get_pool(cr.dbname)
170+ openupgrade.set_defaults(cr, pool, defaults_force, force=True)
171
172=== added file 'account_budget/migrations/6.0.1.0/user_notes.txt'
173--- account_budget/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
174+++ account_budget/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
175@@ -0,0 +1,2 @@
176+This upgrade allows budgets to be reset from state 'Cancel' to state 'Draft'.
177+Budgets are by default now managed by accountants.
178
179=== added file 'account_payment/migrations/6.0.1.1/data.xml'
180--- account_payment/migrations/6.0.1.1/data.xml 1970-01-01 00:00:00 +0000
181+++ account_payment/migrations/6.0.1.1/data.xml 2012-06-07 17:48:26 +0000
182@@ -0,0 +1,13 @@
183+<?xml version="1.0" encoding="utf-8"?>
184+<openerp>
185+<data noupdate="1">
186+
187+ <record id="payment_mode_comp_rule" model="ir.rule">
188+ <field name="name">Payment Mode company rule</field>
189+ <field model="ir.model" name="model_id" ref="model_payment_mode"/>
190+ <field eval="True" name="global"/>
191+ <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
192+ </record>
193+
194+</data>
195+</openerp>
196
197=== added file 'account_payment/migrations/6.0.1.1/post-migration.py'
198--- account_payment/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
199+++ account_payment/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
200@@ -0,0 +1,37 @@
201+# -*- coding: utf-8 -*-
202+##############################################################################
203+#
204+# OpenERP, Open Source Management Solution
205+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
206+#
207+# This program is free software: you can redistribute it and/or modify
208+# it under the terms of the GNU Affero General Public License as
209+# published by the Free Software Foundation, either version 3 of the
210+# License, or (at your option) any later version.
211+#
212+# This program is distributed in the hope that it will be useful,
213+# but WITHOUT ANY WARRANTY; without even the implied warranty of
214+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
215+# GNU Affero General Public License for more details.
216+#
217+# You should have received a copy of the GNU Affero General Public License
218+# along with this program. If not, see <http://www.gnu.org/licenses/>.
219+#
220+##############################################################################
221+
222+import pooler
223+from openupgrade import openupgrade
224+
225+defaults_force = {
226+ # False results in column value NULL
227+ # None value triggers a call to the model's default function
228+ 'payment.mode': [
229+ ('company_id', None),
230+ ],
231+ }
232+
233+@openupgrade.migrate()
234+def migrate(cr, version):
235+ pool = pooler.get_pool(cr.dbname)
236+ openupgrade.set_defaults(cr, pool, defaults_force, force=True)
237+ openupgrade.load_data(cr, 'account_payment', 'migrations/6.0.1.1/data.xml')
238
239=== added file 'account_payment/migrations/6.0.1.1/pre-migration.py'
240--- account_payment/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
241+++ account_payment/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
242@@ -0,0 +1,35 @@
243+# -*- coding: utf-8 -*-
244+##############################################################################
245+#
246+# OpenERP, Open Source Management Solution
247+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
248+#
249+# This program is free software: you can redistribute it and/or modify
250+# it under the terms of the GNU Affero General Public License as
251+# published by the Free Software Foundation, either version 3 of the
252+# License, or (at your option) any later version.
253+#
254+# This program is distributed in the hope that it will be useful,
255+# but WITHOUT ANY WARRANTY; without even the implied warranty of
256+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
257+# GNU Affero General Public License for more details.
258+#
259+# You should have received a copy of the GNU Affero General Public License
260+# along with this program. If not, see <http://www.gnu.org/licenses/>.
261+#
262+##############################################################################
263+
264+from openupgrade import openupgrade
265+
266+column_renames = {
267+ # this is a mapping per table from old column name
268+ # to new column name
269+ 'payment_order': [
270+ ('date_planned', 'date_scheduled'),
271+ ],
272+ }
273+
274+
275+@openupgrade.migrate()
276+def migrate(cr, version):
277+ openupgrade.rename_columns(cr, column_renames)
278
279=== added file 'account_payment/migrations/6.0.1.1/user_notes.txt'
280--- account_payment/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
281+++ account_payment/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
282@@ -0,0 +1,3 @@
283+This upgrade performs a small amount of adaptations to the database structure related to module account_payment.
284+
285+
286
287=== added file 'analytic_user_function/migrations/6.0.1.0/user_notes.txt'
288--- analytic_user_function/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
289+++ analytic_user_function/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
290@@ -0,0 +1,1 @@
291+Nothing to do for module 'analytic_user_function'
292
293=== added file 'audittrail/migrations/6.0.1.0/user_notes.txt'
294--- audittrail/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
295+++ audittrail/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
296@@ -0,0 +1,1 @@
297+Nothing to do for module 'audittrail'
298
299=== added file 'base_iban/migrations/6.0.1.0/user_notes.txt'
300--- base_iban/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
301+++ base_iban/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
302@@ -0,0 +1,1 @@
303+Nothing to do for module base_iban
304
305=== added file 'base_report_creator/migrations/6.0.1.0/user_notes.txt'
306--- base_report_creator/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
307+++ base_report_creator/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
308@@ -0,0 +1,1 @@
309+Nothing to do for module base_report_creator
310
311=== added file 'base_report_designer/migrations/6.0.0.1/user_notes.txt'
312--- base_report_designer/migrations/6.0.0.1/user_notes.txt 1970-01-01 00:00:00 +0000
313+++ base_report_designer/migrations/6.0.0.1/user_notes.txt 2012-06-07 17:48:26 +0000
314@@ -0,0 +1,3 @@
315+Nothing to do for module 'base_report_creator'
316+
317+
318
319=== added file 'board/migrations/6.0.1.0/user_notes.txt'
320--- board/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
321+++ board/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
322@@ -0,0 +1,1 @@
323+Nothing to do for module board
324
325=== added file 'hr/migrations/6.0.1.1/data.xml'
326--- hr/migrations/6.0.1.1/data.xml 1970-01-01 00:00:00 +0000
327+++ hr/migrations/6.0.1.1/data.xml 2012-06-07 17:48:26 +0000
328@@ -0,0 +1,20 @@
329+<?xml version="1.0" encoding="utf-8"?>
330+<openerp>
331+ <data noupdate="1">
332+
333+ <!-- Employee Marital Statusses, introduced in OpenERP 6 -->
334+ <record id="hr_employee_marital_status_single" model="hr.employee.marital.status">
335+ <field name="name">Single</field>
336+ </record>
337+ <record id="hr_employee_marital_status_married" model="hr.employee.marital.status">
338+ <field name="name">Married</field>
339+ </record>
340+ <record id="hr_employee_marital_status_divorced" model="hr.employee.marital.status">
341+ <field name="name">Divorced</field>
342+ </record>
343+ <record id="hr_employee_marital_status_widower" model="hr.employee.marital.status">
344+ <field name="name">Widower</field>
345+ </record>
346+
347+ </data>
348+</openerp>
349
350=== added file 'hr/migrations/6.0.1.1/post-migration.py'
351--- hr/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
352+++ hr/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
353@@ -0,0 +1,187 @@
354+# -*- coding: utf-8 -*-
355+##############################################################################
356+#
357+# OpenERP, Open Source Management Solution
358+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
359+#
360+# This program is free software: you can redistribute it and/or modify
361+# it under the terms of the GNU Affero General Public License as
362+# published by the Free Software Foundation, either version 3 of the
363+# License, or (at your option) any later version.
364+#
365+# This program is distributed in the hope that it will be useful,
366+# but WITHOUT ANY WARRANTY; without even the implied warranty of
367+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
368+# GNU Affero General Public License for more details.
369+#
370+# You should have received a copy of the GNU Affero General Public License
371+# along with this program. If not, see <http://www.gnu.org/licenses/>.
372+#
373+##############################################################################
374+
375+import pooler, logging
376+from openupgrade import openupgrade
377+
378+logger = logging.getLogger('OpenUpgrade: hr')
379+
380+defaults = {
381+ # False results in column value NULL
382+ # None value triggers a call to the model's default function
383+ #'account.fiscalyear': [
384+ # ('company_id', None),
385+ # ],
386+ }
387+
388+def create_employee_resources(cr, pool):
389+ employee_pool = pool.get('hr.employee')
390+ resource_pool = pool.get('resource.resource')
391+ cr.execute("""
392+SELECT
393+ id,
394+ openupgrade_legacy_user_id,
395+ openupgrade_legacy_company_id,
396+ openupgrade_legacy_name,
397+ openupgrade_legacy_active
398+FROM hr_employee
399+WHERE resource_id is NULL
400+""")
401+ for row in cr.fetchall():
402+ resource_id = resource_pool.create(
403+ cr, 1,
404+ {'user_id': row[1],
405+ 'company_id': row[2],
406+ 'name': row[3],
407+ 'active': row[4],
408+ })
409+ employee_pool.write(
410+ cr, 1, row[0], {'resource_id': resource_id})
411+
412+def get_user_employee(cr, pool, user_id):
413+ if not user_id:
414+ return False
415+ employee_pool = pool.get('hr.employee')
416+ employee_ids = employee_pool.search(
417+ cr, 1, [('user_id', '=', user_id)])
418+ if employee_ids:
419+ if len(employee_ids) > 1:
420+ logger.info(
421+ 'user %d is associated with multiple active '
422+ 'employees. Need to select one for department membership or '
423+ 'manager' % user_id)
424+ return employee_ids[0]
425+ return False
426+
427+def set_department_manager(cr, pool):
428+ """
429+ Migrate department managment by user
430+ by management by employee.
431+ """
432+ department_pool = pool.get('hr.department')
433+ cr.execute( 'SELECT id, openupgrade_legacy_manager_user_id from hr_department')
434+ for row in cr.fetchall():
435+ employee_id = get_user_employee(
436+ cr, pool, row[1])
437+ if employee_id:
438+ department_pool.write(
439+ cr, 1, row[0], {'manager_id': employee_id})
440+
441+def set_user_department(cr, pool):
442+ """
443+ Migrate department membership by user
444+ to membership by employee.
445+ In OpenERP 6, an employee can only be in a single
446+ department.
447+ """
448+ employee_pool = pool.get('hr.employee')
449+ cr.execute("""
450+SELECT
451+ user_id,
452+ department_id,
453+ hr_department.manager_id
454+FROM
455+ openupgrade_legacy_hr_department_user_rel,
456+ hr_department
457+WHERE
458+ openupgrade_legacy_hr_department_user_rel.department_id = hr_department.id
459+""")
460+ for row in cr.fetchall():
461+ employee_id = get_user_employee(cr, pool, row[0])
462+ if employee_id:
463+ if employee_id == row[2]:
464+ logger.info(
465+ 'OpenERP does not allow employee with id %s as a '
466+ 'member of the department that it is the manager of. '
467+ % employee_id)
468+ else:
469+ employee_pool.write(
470+ cr, 1, employee_id, {'department_id': row[1]})
471+
472+def set_marital(cr, pool):
473+ """
474+ Migrate selection field 'marital' to
475+ a many2one field of model hr.employee.marital.status
476+ """
477+ marital_pool = pool.get('hr.employee.marital.status')
478+ employee_pool = pool.get('hr.employee')
479+ def get_or_create(marital):
480+ marital = {
481+ 'maried': 'Married',
482+ 'unmaried': 'Single',
483+ 'divorced': 'Divorced',
484+ 'other': 'Other'
485+ }.get(marital, marital)
486+ ids = marital_pool.search(
487+ cr, 1, [('name', '=', marital)])
488+ if ids:
489+ return ids[0]
490+ return marital_pool.create(
491+ cr, 1, {'name': marital})
492+ # marital might already be filled by the renaming of
493+ # hr_contract's marital_status
494+ cr.execute('SELECT id, openupgrade_legacy_marital '
495+ 'FROM hr_employee WHERE marital IS NULL '
496+ 'AND openupgrade_legacy_marital IS NOT NULL')
497+ for row in cr.fetchall():
498+ employee_pool.write(
499+ cr, 1, row[0], {'marital': get_or_create(row[1])})
500+
501+def set_department_manager(cr, pool):
502+ """
503+ Migrate department managment by user
504+ by management by employee.
505+ """
506+ department_pool = pool.get('hr.department')
507+ cr.execute( 'SELECT id, openupgrade_legacy_manager_user_id from hr_department')
508+ for row in cr.fetchall():
509+ employee_id = get_user_employee(
510+ cr, pool, row[1])
511+ if employee_id:
512+ department_pool.write(
513+ cr, 1, row[0], {'manager_id': employee_id})
514+
515+def set_category_ids(cr, pool):
516+ """
517+ Migrate the many2one category_id field
518+ to many2many category_ids
519+ """
520+ employee_pool = pool.get('hr.employee')
521+ cr.execute('SELECT id, openupgrade_legacy_category_id '
522+ 'FROM hr_employee '
523+ 'WHERE openupgrade_legacy_category_id IS NOT NULL')
524+ for row in cr.fetchall():
525+ employee_pool.write(
526+ cr, 1, row[0], {'category_ids': [(4, row[1])]})
527+
528+@openupgrade.migrate()
529+def migrate(cr, version):
530+ pool = pooler.get_pool(cr.dbname)
531+ openupgrade.set_defaults(cr, pool, defaults)
532+ create_employee_resources(cr, pool)
533+ set_department_manager(cr, pool)
534+ set_user_department(cr, pool)
535+ set_category_ids(cr, pool)
536+ # The following definitions were moved from hr_contract.
537+ # In case this module was installed, the reloading of the data
538+ # will only overwrite the name if it was altered
539+ openupgrade.load_xml(cr, 'hr', 'migrations/6.0.1.1/data.xml')
540+ set_marital(cr, pool)
541
542=== added file 'hr/migrations/6.0.1.1/pre-migration.py'
543--- hr/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
544+++ hr/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
545@@ -0,0 +1,67 @@
546+# -*- coding: utf-8 -*-
547+##############################################################################
548+#
549+# OpenERP, Open Source Management Solution
550+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
551+#
552+# This program is free software: you can redistribute it and/or modify
553+# it under the terms of the GNU Affero General Public License as
554+# published by the Free Software Foundation, either version 3 of the
555+# License, or (at your option) any later version.
556+#
557+# This program is distributed in the hope that it will be useful,
558+# but WITHOUT ANY WARRANTY; without even the implied warranty of
559+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
560+# GNU Affero General Public License for more details.
561+#
562+# You should have received a copy of the GNU Affero General Public License
563+# along with this program. If not, see <http://www.gnu.org/licenses/>.
564+#
565+##############################################################################
566+
567+from openupgrade import openupgrade
568+
569+column_renames = {
570+ # this is a mapping per table from old column name
571+ # to new column name
572+ 'hr_department': [
573+ ('manager_id', 'openupgrade_legacy_manager_user_id'),
574+ ],
575+ 'hr_employee': [
576+ ('user_id', 'openupgrade_legacy_user_id'),
577+ ('name', 'openupgrade_legacy_name'),
578+ ('active', 'openupgrade_legacy_active'),
579+ ('company_id', 'openupgrade_legacy_company_id'),
580+ ('category_id', 'openupgrade_legacy_category_id'),
581+ ('marital', 'openupgrade_legacy_marital'),
582+ ('parent_id', 'openupgrade_legacy_parent_id'),
583+ ]
584+ }
585+
586+renamed_xmlids = [
587+ ('hr.group_hr_user', 'base.group_hr_user'),
588+ ('hr.group_hr_manager', 'base.group_hr_manager'),
589+ ('hr_contract.hr_employee_marital_status_divorced',
590+ 'hr.hr_employee_marital_status_divorced'),
591+ ('hr_contract.hr_employee_marital_status_married',
592+ 'hr.hr_employee_marital_status_married'),
593+ ('hr_contract.hr_employee_marital_status_single',
594+ 'hr.hr_employee_marital_status_single'),
595+ ('hr_contract.hr_employee_marital_status_widower',
596+ 'hr.hr_employee_marital_status_widower'),
597+]
598+
599+@openupgrade.migrate()
600+def migrate(cr, version):
601+ openupgrade.rename_columns(cr, column_renames)
602+ # marital status as provided by hr_contract if installed
603+ if openupgrade.column_exists(
604+ cr, 'hr_employee', 'marital_status'):
605+ openupgrade.rename_columns(
606+ cr, { 'hr_employee': [('marital_status', 'marital')]})
607+ openupgrade.rename_tables(
608+ cr,
609+ [('hr_department_user_rel',
610+ 'openupgrade_legacy_hr_department_user_rel')])
611+ openupgrade.rename_xmlids(cr, renamed_xmlids)
612+
613
614=== added file 'hr/migrations/6.0.1.1/user_notes.txt'
615--- hr/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
616+++ hr/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
617@@ -0,0 +1,6 @@
618+This upgrade consists of the following changes:
619+- Marital status is now a choice from a lookup table
620+ previously provided by the hr contract module
621+- An employee can now have multiple categories
622+- The employee model is integrated with the resource model
623+- Departments now have employees as their member type, not system users
624
625=== added file 'hr_attendance/migrations/6.0.1.1/user_notes.txt'
626--- hr_attendance/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
627+++ hr_attendance/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
628@@ -0,0 +1,1 @@
629+Nothing to do for module 'hr_attendance'
630
631=== added file 'hr_contract/migrations/6.0.1.0/data.xml'
632--- hr_contract/migrations/6.0.1.0/data.xml 1970-01-01 00:00:00 +0000
633+++ hr_contract/migrations/6.0.1.0/data.xml 2012-06-07 17:48:26 +0000
634@@ -0,0 +1,19 @@
635+<?xml version="1.0" encoding="utf-8"?>
636+<openerp>
637+ <data noupdate="1">
638+
639+ <!-- Contract Types -->
640+ <record id="hr_contract_type_emp" model="hr.contract.type">
641+ <field name="name">Employee</field>
642+ </record>
643+
644+ <record id="hr_contract_type_wrkr" model="hr.contract.type">
645+ <field name="name">Worker</field>
646+ </record>
647+
648+ <record id="hr_contract_type_sub" model="hr.contract.type">
649+ <field name="name">Subcontractor</field>
650+ </record>
651+
652+ </data>
653+</openerp>
654
655=== added file 'hr_contract/migrations/6.0.1.0/post-migration.py'
656--- hr_contract/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
657+++ hr_contract/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
658@@ -0,0 +1,83 @@
659+# -*- coding: utf-8 -*-
660+##############################################################################
661+#
662+# OpenERP, Open Source Management Solution
663+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
664+#
665+# This program is free software: you can redistribute it and/or modify
666+# it under the terms of the GNU Affero General Public License as
667+# published by the Free Software Foundation, either version 3 of the
668+# License, or (at your option) any later version.
669+#
670+# This program is distributed in the hope that it will be useful,
671+# but WITHOUT ANY WARRANTY; without even the implied warranty of
672+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
673+# GNU Affero General Public License for more details.
674+#
675+# You should have received a copy of the GNU Affero General Public License
676+# along with this program. If not, see <http://www.gnu.org/licenses/>.
677+#
678+##############################################################################
679+
680+import pooler, logging
681+from openupgrade import openupgrade
682+
683+logger = logging.getLogger('migrate')
684+MODULE = 'hr_contract'
685+
686+def set_contract_job_id(cr, pool):
687+ """
688+ Migrate function_id (res.partner.function) field on hr.contract
689+ to job_id (hr.job).
690+ Create jobs if necessary, taking company_id into account.
691+ """
692+ job_pool = pool.get('hr.job')
693+ contract_pool = pool.get('hr.contract')
694+ def get_or_create(name, company_id):
695+ ids = job_pool.search(
696+ cr, 1, [('name', '=', name),
697+ ('company_id', '=', company_id)])
698+ if ids:
699+ return ids[0]
700+ return job_pool.create(
701+ cr, 1, {'name': name,
702+ 'company_id': company_id})
703+ # marital might already be filled by the renaming of
704+ # hr_contract's marital_status
705+ cr.execute(
706+ 'SELECT '
707+ ' hr_contract.id, '
708+ ' openupgrade_legacy_res_partner_function.name, '
709+ ' resource_resource.company_id '
710+ 'FROM '
711+ ' hr_contract, '
712+ ' hr_employee, '
713+ ' resource_resource, '
714+ ' openupgrade_legacy_res_partner_function '
715+ 'WHERE '
716+ ' hr_employee.resource_id = resource_resource.id '
717+ ' AND hr_contract.job_id IS NULL '
718+ ' AND hr_contract.employee_id = hr_employee.id '
719+ ' AND openupgrade_legacy_function = openupgrade_legacy_res_partner_function.id')
720+ for row in cr.fetchall():
721+ contract_pool.write(
722+ cr, 1, row[0],
723+ {'job_id': get_or_create(row[1], row[2] or False)})
724+
725+
726+def set_contract_default_type_id(cr, pool):
727+ default_type_ref = pool.get('ir.model.data').get_object_reference(
728+ cr, 1, 'hr_contract', 'hr_contract_type_emp')
729+ if default_type_ref:
730+ openupgrade.set_defaults(
731+ cr, pool,
732+ {'hr.contract': [('type_id', default_type_ref[1])]})
733+ else:
734+ logger.warn('%s: Default contact type not found' % MODULE)
735+
736+@openupgrade.migrate()
737+def migrate(cr, version):
738+ pool = pooler.get_pool(cr.dbname)
739+ openupgrade.load_data(cr, MODULE, 'migrations/6.0.1.0/data.xml')
740+ set_contract_job_id(cr, pool)
741+ set_contract_default_type_id(cr, pool)
742
743=== added file 'hr_contract/migrations/6.0.1.0/pre-migration.py'
744--- hr_contract/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
745+++ hr_contract/migrations/6.0.1.0/pre-migration.py 2012-06-07 17:48:26 +0000
746@@ -0,0 +1,35 @@
747+# -*- coding: utf-8 -*-
748+##############################################################################
749+#
750+# OpenERP, Open Source Management Solution
751+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
752+#
753+# This program is free software: you can redistribute it and/or modify
754+# it under the terms of the GNU Affero General Public License as
755+# published by the Free Software Foundation, either version 3 of the
756+# License, or (at your option) any later version.
757+#
758+# This program is distributed in the hope that it will be useful,
759+# but WITHOUT ANY WARRANTY; without even the implied warranty of
760+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
761+# GNU Affero General Public License for more details.
762+#
763+# You should have received a copy of the GNU Affero General Public License
764+# along with this program. If not, see <http://www.gnu.org/licenses/>.
765+#
766+##############################################################################
767+
768+from openupgrade import openupgrade
769+
770+column_renames = {
771+ # this is a mapping per table from old column name
772+ # to new column name
773+ 'hr_contract': [
774+ ('function', 'openupgrade_legacy_function'),
775+ ],
776+ }
777+
778+@openupgrade.migrate()
779+def migrate(cr, version):
780+ openupgrade.rename_columns(cr, column_renames)
781+
782
783=== added file 'hr_contract/migrations/6.0.1.0/user_notes.txt'
784--- hr_contract/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
785+++ hr_contract/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
786@@ -0,0 +1,3 @@
787+This upgrade migrates functions on contracts to 'jobs' from the hr module.
788+It also adds contract types such as 'Employee' or 'Subcontractor'
789+
790
791=== added file 'hr_expense/migrations/6.0.1.0/post-migration.py'
792--- hr_expense/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
793+++ hr_expense/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
794@@ -0,0 +1,34 @@
795+# -*- coding: utf-8 -*-
796+##############################################################################
797+#
798+# OpenERP, Open Source Management Solution
799+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
800+#
801+# This program is free software: you can redistribute it and/or modify
802+# it under the terms of the GNU Affero General Public License as
803+# published by the Free Software Foundation, either version 3 of the
804+# License, or (at your option) any later version.
805+#
806+# This program is distributed in the hope that it will be useful,
807+# but WITHOUT ANY WARRANTY; without even the implied warranty of
808+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
809+# GNU Affero General Public License for more details.
810+#
811+# You should have received a copy of the GNU Affero General Public License
812+# along with this program. If not, see <http://www.gnu.org/licenses/>.
813+#
814+##############################################################################
815+
816+import pooler
817+from openupgrade import openupgrade
818+
819+defaults_force = {
820+ 'hr.expense.expense': [
821+ ('company_id', None)
822+ ]
823+ }
824+
825+@openupgrade.migrate()
826+def migrate(cr, version):
827+ pool = pooler.get_pool(cr.dbname)
828+ openupgrade.set_defaults(cr, pool, defaults_force, force=True)
829
830=== added file 'hr_expense/migrations/6.0.1.0/user_notes.txt'
831--- hr_expense/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
832+++ hr_expense/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
833@@ -0,0 +1,1 @@
834+This upgrade adds security rules for access to expenses.
835
836=== added file 'hr_timesheet/migrations/6.0.1.0/user_notes.txt'
837--- hr_timesheet/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
838+++ hr_timesheet/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
839@@ -0,0 +1,1 @@
840+This upgrade adds a dedicated timesheet journal
841
842=== added file 'hr_timesheet_invoice/migrations/6.0.1.0/user_notes.txt'
843--- hr_timesheet_invoice/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
844+++ hr_timesheet_invoice/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
845@@ -0,0 +1,1 @@
846+This upgrade adds default entries to the invoice factor table.
847
848=== added file 'hr_timesheet_sheet/migrations/6.0.1.0/post-migration.py'
849--- hr_timesheet_sheet/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
850+++ hr_timesheet_sheet/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
851@@ -0,0 +1,55 @@
852+# -*- coding: utf-8 -*-
853+##############################################################################
854+#
855+# OpenERP, Open Source Management Solution
856+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
857+#
858+# This program is free software: you can redistribute it and/or modify
859+# it under the terms of the GNU Affero General Public License as
860+# published by the Free Software Foundation, either version 3 of the
861+# License, or (at your option) any later version.
862+#
863+# This program is distributed in the hope that it will be useful,
864+# but WITHOUT ANY WARRANTY; without even the implied warranty of
865+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
866+# GNU Affero General Public License for more details.
867+#
868+# You should have received a copy of the GNU Affero General Public License
869+# along with this program. If not, see <http://www.gnu.org/licenses/>.
870+#
871+##############################################################################
872+
873+import pooler
874+from openupgrade import openupgrade
875+
876+defaults_force = {
877+ 'hr_timesheet_sheet.sheet':
878+ [('company_id', None)],
879+ }
880+
881+def set_timesheet_employee(cr, pool):
882+ """
883+ Migrate timesheet owner by user to employee.
884+ """
885+ sheet_pool = pool.get('hr_timesheet_sheet.sheet')
886+ cr.execute("""
887+ SELECT
888+ hr_timesheet_sheet_sheet.id,
889+ hr_employee.id
890+ FROM
891+ hr_timesheet_sheet_sheet,
892+ hr_employee
893+ WHERE
894+ hr_timesheet_sheet_sheet.employee_id IS NULL
895+ AND hr_timesheet_sheet_sheet.openupgrade_legacy_user_id IS NOT NULL
896+ AND hr_employee.openupgrade_legacy_user_id = hr_timesheet_sheet_sheet.openupgrade_legacy_user_id
897+ """)
898+ for row in cr.fetchall():
899+ sheet_pool.write(
900+ cr, 1, [row[0]], {'employee_id': row[1]})
901+
902+@openupgrade.migrate()
903+def migrate(cr, version):
904+ pool = pooler.get_pool(cr.dbname)
905+ openupgrade.set_defaults(cr, pool, defaults_force, force=True)
906+ set_timesheet_employee(cr, pool)
907
908=== added file 'hr_timesheet_sheet/migrations/6.0.1.0/pre-migration.py'
909--- hr_timesheet_sheet/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
910+++ hr_timesheet_sheet/migrations/6.0.1.0/pre-migration.py 2012-06-07 17:48:26 +0000
911@@ -0,0 +1,34 @@
912+# -*- coding: utf-8 -*-
913+##############################################################################
914+#
915+# OpenERP, Open Source Management Solution
916+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
917+#
918+# This program is free software: you can redistribute it and/or modify
919+# it under the terms of the GNU Affero General Public License as
920+# published by the Free Software Foundation, either version 3 of the
921+# License, or (at your option) any later version.
922+#
923+# This program is distributed in the hope that it will be useful,
924+# but WITHOUT ANY WARRANTY; without even the implied warranty of
925+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
926+# GNU Affero General Public License for more details.
927+#
928+# You should have received a copy of the GNU Affero General Public License
929+# along with this program. If not, see <http://www.gnu.org/licenses/>.
930+#
931+##############################################################################
932+
933+from openupgrade import openupgrade
934+
935+column_renames = {
936+ # this is a mapping per table from old column name
937+ # to new column name
938+ 'hr_timesheet_sheet_sheet': [
939+ ('user_id', 'openupgrade_legacy_user_id'),
940+ ],
941+ }
942+
943+@openupgrade.migrate()
944+def migrate(cr, version):
945+ openupgrade.rename_columns(cr, column_renames)
946
947=== added file 'hr_timesheet_sheet/migrations/6.0.1.0/user_notes.txt'
948--- hr_timesheet_sheet/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
949+++ hr_timesheet_sheet/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
950@@ -0,0 +1,1 @@
951+Timesheets are now related to employees, not to users. Existing timesheets will be migrated, if an employee exists for the user.
952
953=== added file 'mrp/migrations/6.0.1.1/post-migration.py'
954--- mrp/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
955+++ mrp/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
956@@ -0,0 +1,64 @@
957+# -*- coding: utf-8 -*-
958+##############################################################################
959+#
960+# OpenERP, Open Source Management Solution
961+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
962+#
963+# This program is free software: you can redistribute it and/or modify
964+# it under the terms of the GNU Affero General Public License as
965+# published by the Free Software Foundation, either version 3 of the
966+# License, or (at your option) any later version.
967+#
968+# This program is distributed in the hope that it will be useful,
969+# but WITHOUT ANY WARRANTY; without even the implied warranty of
970+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
971+# GNU Affero General Public License for more details.
972+#
973+# You should have received a copy of the GNU Affero General Public License
974+# along with this program. If not, see <http://www.gnu.org/licenses/>.
975+#
976+##############################################################################
977+
978+import pooler
979+from openupgrade import openupgrade
980+
981+defaults_force = {
982+ 'mrp.bom': [('company_id', None)],
983+ 'mrp.production': [('company_id', None)],
984+ 'mrp.routing': [('company_id', None)],
985+ 'mrp.workcenter': [('company_id', None)],
986+}
987+
988+def create_workcenter_resources(cr, pool):
989+ # note: set default value for company_id
990+ # on the workcenter
991+ # after running this function
992+ workcenter_pool = pool.get('mrp.workcenter')
993+ resource_pool = pool.get('resource.resource')
994+ cr.execute("""
995+SELECT
996+ id,
997+ openupgrade_legacy_code,
998+ openupgrade_legacy_name,
999+ openupgrade_legacy_active
1000+FROM
1001+ mrp_workcenter
1002+WHERE
1003+ resource_id is NULL""")
1004+
1005+ for row in cr.fetchall():
1006+ resource_id = resource_pool.create(
1007+ cr, 1,
1008+ {
1009+ 'code': row[1],
1010+ 'name': row[2],
1011+ 'active': row[3],
1012+ 'resource_type': 'material',
1013+ })
1014+ workcenter_pool.write(
1015+ cr, 1, row[0], {'resource_id': resource_id})
1016+
1017+@openupgrade.migrate()
1018+def migrate(cr, version):
1019+ pool = pooler.get_pool(cr.dbname)
1020+ create_workcenter_resources(cr, pool)
1021
1022=== added file 'mrp/migrations/6.0.1.1/pre-migration.py'
1023--- mrp/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
1024+++ mrp/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
1025@@ -0,0 +1,38 @@
1026+# -*- coding: utf-8 -*-
1027+##############################################################################
1028+#
1029+# OpenERP, Open Source Management Solution
1030+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1031+#
1032+# This program is free software: you can redistribute it and/or modify
1033+# it under the terms of the GNU Affero General Public License as
1034+# published by the Free Software Foundation, either version 3 of the
1035+# License, or (at your option) any later version.
1036+#
1037+# This program is distributed in the hope that it will be useful,
1038+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1039+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1040+# GNU Affero General Public License for more details.
1041+#
1042+# You should have received a copy of the GNU Affero General Public License
1043+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1044+#
1045+##############################################################################
1046+
1047+from openupgrade import openupgrade
1048+
1049+column_renames = {
1050+ 'mrp_production': [
1051+ ('date_finnished', 'date_finished'),
1052+ ],
1053+ 'mrp_workcenter': [
1054+ ('code', 'openupgrade_legacy_code'),
1055+ ('name', 'openupgrade_legacy_name'),
1056+ ('active', 'openupgrade_legacy_active'),
1057+ ]
1058+ }
1059+
1060+@openupgrade.migrate()
1061+def migrate(cr, version):
1062+ openupgrade.rename_columns(cr, column_renames)
1063+
1064
1065=== added file 'mrp/migrations/6.0.1.1/user_notes.txt'
1066--- mrp/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
1067+++ mrp/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
1068@@ -0,0 +1,1 @@
1069+Much of the functionality of the mrp module in OpenERP 5 has been split off to the new procurement module, as well as to the purchase module. See there. This upgrade integrates the mrp workcenter model with the new resource model, and it provides default values for company fields and reloads the modified access permissions.
1070
1071=== added file 'process/migrations/6.0.1.0/user_notes.txt'
1072--- process/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
1073+++ process/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
1074@@ -0,0 +1,1 @@
1075+Nothing to do for module 'process'
1076
1077=== added file 'procurement/migrations/6.0.1.0/data.xml'
1078--- procurement/migrations/6.0.1.0/data.xml 1970-01-01 00:00:00 +0000
1079+++ procurement/migrations/6.0.1.0/data.xml 2012-06-07 17:48:26 +0000
1080@@ -0,0 +1,22 @@
1081+<?xml version="1.0" encoding="utf-8"?>
1082+<openerp>
1083+ <data noupdate="1">
1084+ <!-- The following changes may already be loaded upon
1085+ the auto-installation of the procurement module when
1086+ a v5 database with mrp installed is being upgraded
1087+ to v6 -->
1088+
1089+ <!-- OpenERP 6 changes the code of these resources -->
1090+ <record id="sequence_mrp_op_type" model="ir.sequence.type">
1091+ <field name="code">stock.orderpoint</field>
1092+ </record>
1093+ <record id="sequence_mrp_op" model="ir.sequence.type">
1094+ <field name="code">stock.orderpoint</field>
1095+ </record>
1096+ <!-- change the model of the scheduled task -->
1097+ <record id="ir_cron_scheduler_action" model="ir.cron">
1098+ <field eval="'procurement.order'" name="model"/>
1099+ </record>
1100+ </data>
1101+</openerp>
1102+
1103
1104=== added file 'procurement/migrations/6.0.1.0/post-migration.py'
1105--- procurement/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
1106+++ procurement/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
1107@@ -0,0 +1,34 @@
1108+# -*- coding: utf-8 -*-
1109+##############################################################################
1110+#
1111+# OpenERP, Open Source Management Solution
1112+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1113+#
1114+# This program is free software: you can redistribute it and/or modify
1115+# it under the terms of the GNU Affero General Public License as
1116+# published by the Free Software Foundation, either version 3 of the
1117+# License, or (at your option) any later version.
1118+#
1119+# This program is distributed in the hope that it will be useful,
1120+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1121+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1122+# GNU Affero General Public License for more details.
1123+#
1124+# You should have received a copy of the GNU Affero General Public License
1125+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1126+#
1127+##############################################################################
1128+
1129+import pooler
1130+from openupgrade import openupgrade
1131+
1132+defaults_force = {
1133+ 'procurement.order': [('company_id', None)],
1134+ 'stock.warehouse.orderpoint': [('company_id', None)],
1135+}
1136+
1137+@openupgrade.migrate()
1138+def migrate(cr, version):
1139+ pool = pooler.get_pool(cr.dbname)
1140+ openupgrade.set_defaults(cr, pool, defaults_force, force=True)
1141+ openupgrade.load_data(cr, MODULE, 'migrations/6.0.1.0/data.xml')
1142
1143=== added file 'procurement/migrations/6.0.1.0/pre-migration.py'
1144--- procurement/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
1145+++ procurement/migrations/6.0.1.0/pre-migration.py 2012-06-07 17:48:26 +0000
1146@@ -0,0 +1,84 @@
1147+# -*- coding: utf-8 -*-
1148+##############################################################################
1149+#
1150+# OpenERP, Open Source Management Solution
1151+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1152+#
1153+# This program is free software: you can redistribute it and/or modify
1154+# it under the terms of the GNU Affero General Public License as
1155+# published by the Free Software Foundation, either version 3 of the
1156+# License, or (at your option) any later version.
1157+#
1158+# This program is distributed in the hope that it will be useful,
1159+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1160+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1161+# GNU Affero General Public License for more details.
1162+#
1163+# You should have received a copy of the GNU Affero General Public License
1164+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1165+#
1166+##############################################################################
1167+
1168+import logging
1169+from openupgrade import openupgrade
1170+
1171+logger = logging.getLogger('OpenUpgrade: procurement')
1172+
1173+renamed_xmlids = [
1174+ ('mrp.wkf', 'procurement.wkf_procurement'),
1175+ ('mrp.act_draft', 'procurement.act_draft'),
1176+ ('mrp.act_cancel', 'procurement.act_cancel'),
1177+ ('mrp.act_confirm', 'procurement.act_confirm'),
1178+ ('mrp.act_confirm_wait', 'procurement.act_confirm_wait'),
1179+ ('mrp.act_confirm_mts', 'procurement.act_confirm_mts'),
1180+ ('mrp.act_confirm_mto', 'procurement.act_confirm_mto'),
1181+ ('mrp.act_make_to_stock', 'procurement.act_make_to_stock'),
1182+ ('mrp.act_produce_check', 'procurement.act_produce_check'),
1183+ ('mrp.act_produce_service', 'procurement.act_produce_service'),
1184+ ('mrp.act_make_done', 'procurement.act_make_done'),
1185+ ('mrp.act_wait_done', 'procurement.act_wait_done'),
1186+ ('mrp.act_done', 'procurement.act_done'),
1187+ ('mrp.trans_draft_confirm', 'procurement.trans_draft_confirm'),
1188+ ('mrp.trans_confirm_cancel2', 'procurement.trans_confirm_cancel2'),
1189+ ('mrp.trans_confirm_wait_done', 'procurement.trans_confirm_wait_done'),
1190+ ('mrp.trans_confirm_cancel', 'procurement.trans_confirm_cancel'),
1191+ ('mrp.trans_confirm_confirm_wait', 'procurement.trans_confirm_confirm_wait'),
1192+ ('mrp.trans_confirm_wait_confirm_mto', 'procurement.trans_confirm_wait_confirm_mto'),
1193+ ('mrp.trans_confirm_wait_confirm_mts', 'procurement.trans_confirm_wait_confirm_mts'),
1194+ ('mrp.trans_confirm_mts_cancel', 'procurement.trans_confirm_mts_cancel'),
1195+ ('mrp.trans_confirm_waiting_cancel', 'procurement.trans_confirm_waiting_cancel'),
1196+ ('mrp.trans_confirm_mts_confirm', 'procurement.trans_confirm_mts_confirm'),
1197+ ('mrp.trans_confirm_mto_cancel', 'procurement.trans_confirm_mto_cancel'),
1198+ ('mrp.trans_confirm_mto_confirm', 'procurement.trans_confirm_mto_confirm'),
1199+ ('mrp.trans_draft_cancel', 'procurement.trans_draft_cancel'),
1200+ ('mrp.trans_confirm_mts_make_to_stock', 'procurement.trans_confirm_mts_make_to_stock'),
1201+ ('mrp.trans_confirm_mto_produce_check', 'procurement.trans_confirm_mto_produce_check'),
1202+ ('mrp.trans_product_check_produce_service', 'procurement.trans_product_check_produce_service'),
1203+ ('mrp.trans_confirm_mto_buy', 'procurement.trans_confirm_mto_purchase'),
1204+ ('mrp.trans_make_to_stock_make_done', 'procurement.trans_make_to_stock_make_done'),
1205+ ('mrp.trans_produce_service_cancel', 'procurement.trans_produce_service_cancel'),
1206+ ('mrp.trans_produce_service_make_done', 'procurement.trans_produce_service_make_done'),
1207+ ('mrp.trans_make_done_done', 'procurement.trans_make_done_done'),
1208+ ('mrp.trans_make_done_confirm', 'procurement.trans_make_done_confirm'),
1209+ ('mrp.sequence_mrp_op_type', 'procurement.sequence_mrp_op_type'),
1210+ ('mrp.sequence_mrp_op', 'procurement.sequence_mrp_op'),
1211+ ('mrp.ir_cron_scheduler_action', 'procurement.ir_cron_scheduler_action'),
1212+]
1213+
1214+# Cannot use the OpenUpgrade decorator
1215+# as in this case, do not return immediately when
1216+# version is False. We need to facilitate the
1217+# functionality move from the mrp module
1218+
1219+def migrate(cr, version):
1220+ logger.info("pre-migration.py called with version %s" % version)
1221+ try:
1222+ if openupgrade.table_exists(cr, 'mrp_procurement'):
1223+ logger.info("moving functionality from the OpenERP 5 MRP module")
1224+ openupgrade.rename_tables(cr, [('mrp_procurement', 'procurement_order')])
1225+ openupgrade.rename_models(cr, [('mrp.procurement', 'procurement.order')])
1226+ openupgrade.rename_xmlids(cr, renamed_xmlids)
1227+ except Exception, e:
1228+ logger.error("error in pre-migration.py: %s" % e)
1229+ raise
1230+
1231
1232=== added file 'procurement/migrations/6.0.1.0/user_notes.txt'
1233--- procurement/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
1234+++ procurement/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
1235@@ -0,0 +1,1 @@
1236+This upgrade facilitates the transferred procurement model and workflow from the mrp module in OpenERP 5, as well as the transferral of the mrp scheduler and the procurement sequence. It also loads modified access permissions and rules, and sets default values for several company fields.
1237
1238=== added file 'product/migrations/6.0.1.1/data.xml'
1239--- product/migrations/6.0.1.1/data.xml 1970-01-01 00:00:00 +0000
1240+++ product/migrations/6.0.1.1/data.xml 2012-06-07 17:48:26 +0000
1241@@ -0,0 +1,66 @@
1242+<?xml version="1.0" encoding="utf-8"?>
1243+<openerp>
1244+ <data noupdate="1">
1245+ <!-- OpenUpgrade: add new product and UOM categories -->
1246+ <record id="cat0" model="product.category">
1247+ <field name="name">All products</field>
1248+ </record>
1249+ <record id="uom_categ_wtime" model="product.uom.categ">
1250+ <field name="name">Working Time</field>
1251+ </record>
1252+ <record id="uom_categ_length" model="product.uom.categ">
1253+ <field name="name">Length / Distance</field>
1254+ </record>
1255+ <!-- OpenUpgrade: add factor and/or rounding properties -->
1256+ <record id="product_uom_unit" model="product.uom">
1257+ <field name="factor" eval="1.0"/>
1258+ <field name="rounding" eval="1.0"/>
1259+ </record>
1260+ <record id="product_uom_kgm" model="product.uom">
1261+ <field name="factor" eval="1"/>
1262+ </record>
1263+ <!-- OpenUpgrade: add new UOMs -->
1264+ <record id="product_uom_gram" model="product.uom">
1265+ <field name="category_id" ref="product_uom_categ_kgm"/>
1266+ <field name="name">g</field>
1267+ <field name="factor" eval="1000"/>
1268+ <field name="uom_type">smaller</field>
1269+ </record>
1270+ <record id="uom_hour" model="product.uom">
1271+ <field name="name">Hour</field>
1272+ <field eval="uom_categ_wtime" name="category_id"/>
1273+ <field name="factor" eval="8.0"/>
1274+ <field name="uom_type">smaller</field>
1275+ </record>
1276+ <record id="uom_day" model="product.uom">
1277+ <field name="name">Day</field>
1278+ <field eval="uom_categ_wtime" name="category_id"/>
1279+ <field name="factor" eval="1.0"/>
1280+ </record>
1281+ <record id="product_uom_ton" model="product.uom">
1282+ <field name="category_id" ref="product_uom_categ_kgm"/>
1283+ <!-- 'tonne' is the most common spelling in english-speaking countries,
1284+ the alternative is 'metric ton' in the US, abbreviated as 'mt' -->
1285+ <field name="name">tonne</field>
1286+ <field name="factor" eval="0.001"/>
1287+ <field name="uom_type">bigger</field>
1288+ </record>
1289+ <record id="product_uom_meter" model="product.uom">
1290+ <field name="category_id" ref="uom_categ_length"/>
1291+ <field name="name">m</field>
1292+ <field name="factor" eval="1.0"/>
1293+ </record>
1294+ <record id="product_uom_km" model="product.uom">
1295+ <field name="category_id" ref="uom_categ_length"/>
1296+ <field name="name">km</field>
1297+ <field name="factor" eval="0.001"/>
1298+ <field name="uom_type">bigger</field>
1299+ </record>
1300+ <record id="product_uom_cm" model="product.uom">
1301+ <field name="category_id" ref="uom_categ_length"/>
1302+ <field name="name">cm</field>
1303+ <field name="factor" eval="100"/>
1304+ <field name="uom_type">smaller</field>
1305+ </record>
1306+ </data>
1307+</openerp>
1308
1309=== added file 'product/migrations/6.0.1.1/post-migration.py'
1310--- product/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
1311+++ product/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
1312@@ -0,0 +1,35 @@
1313+# -*- coding: utf-8 -*-
1314+##############################################################################
1315+#
1316+# OpenERP, Open Source Management Solution
1317+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1318+#
1319+# This program is free software: you can redistribute it and/or modify
1320+# it under the terms of the GNU Affero General Public License as
1321+# published by the Free Software Foundation, either version 3 of the
1322+# License, or (at your option) any later version.
1323+#
1324+# This program is distributed in the hope that it will be useful,
1325+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1326+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1327+# GNU Affero General Public License for more details.
1328+#
1329+# You should have received a copy of the GNU Affero General Public License
1330+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1331+#
1332+##############################################################################
1333+
1334+import pooler
1335+from openupgrade import openupgrade
1336+
1337+defaults_force = {
1338+ 'product.category': [('type', 'normal')],
1339+ #'product.pricelist': [('company_id', None)], # no default function present
1340+ 'product.supplierinfo': [('company_id', None)],
1341+}
1342+
1343+@openupgrade.migrate()
1344+def migrate(cr, version):
1345+ pool = pooler.get_pool(cr.dbname)
1346+ openupgrade.set_defaults(cr, pool, defaults_force, force=True)
1347+ openupgrade.load_data(cr, 'product', 'migrations/6.0.1.1/data.xml')
1348
1349=== added file 'product/migrations/6.0.1.1/pre-migration.py'
1350--- product/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
1351+++ product/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
1352@@ -0,0 +1,46 @@
1353+# -*- coding: utf-8 -*-
1354+##############################################################################
1355+#
1356+# OpenERP, Open Source Management Solution
1357+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1358+#
1359+# This program is free software: you can redistribute it and/or modify
1360+# it under the terms of the GNU Affero General Public License as
1361+# published by the Free Software Foundation, either version 3 of the
1362+# License, or (at your option) any later version.
1363+#
1364+# This program is distributed in the hope that it will be useful,
1365+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1366+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1367+# GNU Affero General Public License for more details.
1368+#
1369+# You should have received a copy of the GNU Affero General Public License
1370+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1371+#
1372+##############################################################################
1373+
1374+from openupgrade import openupgrade
1375+
1376+logger = logging.getLogger('OpenUpgrade: product')
1377+
1378+renamed_columns = {
1379+ 'product_supplierinfo': [
1380+ ('qty', 'min_qty')]
1381+ }
1382+
1383+def update_packaging_type(cr):
1384+ """ A spelling error has been fixed
1385+ in the selection list """
1386+ cr.execute("""
1387+ UPDATE product_ul
1388+ SET type = %s
1389+ WHERE type = %s""", ('pallet', 'palet'))
1390+
1391+@openupgrade.migrate()
1392+def migrate(cr, version):
1393+ openupgrade.rename_columns(cr, renamed_columns)
1394+ update_packaging_type(cr)
1395+ logger.warn(
1396+ "TODO: check whether product_packaging.name "
1397+ "preserves content when migrating from type char "
1398+ "to type text")
1399
1400=== added file 'product/migrations/6.0.1.1/user_notes.txt'
1401--- product/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
1402+++ product/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
1403@@ -0,0 +1,5 @@
1404+This upgrade adds an indication of uom ratio's (bigger, reference or smaller). The default value is 'reference'. You might want to review this setting on your UOMs.
1405+A number of standard product categories and UOM categories are added as well. Group Product Manager is now obsolete. Product management is delegated to Sale and Purchase managers. Membership is not transferred automatically. You may want to review the membership of these two groups.
1406+Modified access permissions and security rules are reloaded.
1407+
1408+
1409
1410=== added file 'project/migrations/6.0.1.1/post-migration.py'
1411--- project/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
1412+++ project/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
1413@@ -0,0 +1,168 @@
1414+# -*- coding: utf-8 -*-
1415+##############################################################################
1416+#
1417+# OpenERP, Open Source Management Solution
1418+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1419+#
1420+# This program is free software: you can redistribute it and/or modify
1421+# it under the terms of the GNU Affero General Public License as
1422+# published by the Free Software Foundation, either version 3 of the
1423+# License, or (at your option) any later version.
1424+#
1425+# This program is distributed in the hope that it will be useful,
1426+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1427+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1428+# GNU Affero General Public License for more details.
1429+#
1430+# You should have received a copy of the GNU Affero General Public License
1431+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1432+#
1433+##############################################################################
1434+
1435+import pooler
1436+from openupgrade import openupgrade
1437+
1438+defaults = {
1439+ 'project.project': [('sequence', 10)],
1440+ 'project.task.type': [('sequence', 1)],
1441+ }
1442+
1443+defaults_force = {
1444+ 'project.task': [('company_id', None)],
1445+ }
1446+
1447+def migrate_analytic(cr, pool):
1448+ """
1449+ Transfer obsolete values from projects to their analytic accounts.
1450+ Create analytic account if necessary. Take care not to overwrite
1451+ existing values on analytic accounts
1452+ """
1453+ project_pool = pool.get('project.project')
1454+ analytic_pool = pool.get('account.analytic.account')
1455+ project_ids = project_pool.search(
1456+ cr, 1,
1457+ [('analytic_account_id', '!=', False)],
1458+ context={'active_test': False})
1459+ analytics = dict([(x.id, x.analytic_account_id) for x in project_pool.browse(
1460+ cr, 1, project_ids)])
1461+ cr.execute("""
1462+ SELECT
1463+ id,
1464+ analytic_account_id,
1465+ openupgrade_legacy_contact_id,
1466+ openupgrade_legacy_date_start,
1467+ openupgrade_legacy_date_end,
1468+ openupgrade_legacy_manager,
1469+ openupgrade_legacy_name,
1470+ openupgrade_legacy_notes,
1471+ openupgrade_legacy_partner_id,
1472+ openupgrade_legacy_state
1473+ FROM
1474+ project_project
1475+ """)
1476+ for row in cr.fetchall():
1477+ if not row[1]:
1478+ analytic_id = analytic_pool.create(
1479+ cr, 1,
1480+ { 'contact_id': row[2] or False,
1481+ 'date_start': row[3] or False,
1482+ 'date': row[4] or False,
1483+ 'user_id' : row[5] or False,
1484+ 'name': row[6] or False,
1485+ 'description': row[7] or False,
1486+ 'partner_id': row[8] or False,
1487+ 'state': row[9] or False,
1488+ })
1489+ project_pool.write(
1490+ cr, 1, row[0],
1491+ {'analytic_account_id': analytic_id})
1492+ else:
1493+ vals = {}
1494+ for num, field in [
1495+ (2, 'contact_id'),
1496+ (3, 'date_start'),
1497+ (4, 'date'),
1498+ (5, 'user_id'),
1499+ (6, 'name'),
1500+ (7, 'description'),
1501+ (8, 'partner_id'),
1502+ (9, 'state')]:
1503+ if row[num] and not analytics[row[0]][field]:
1504+ vals[field] = row[num]
1505+ analytic_pool.write(
1506+ cr, 1, row[1], vals)
1507+
1508+ # second pass: transfer project hierarchy
1509+ # to analytic hierarchy
1510+ cr.execute("""
1511+ SELECT
1512+ child.analytic_account_id,
1513+ parent.analytic_account_id
1514+ FROM
1515+ project_project as child,
1516+ project_project as parent,
1517+ account_analytic_account as a
1518+ WHERE
1519+ child.openupgrade_legacy_parent_id = parent.id
1520+ AND child.analytic_account_id = a.id
1521+ AND a.parent_id IS NULL
1522+ """)
1523+ for row in cr.fetchall():
1524+ analytic_pool.write(
1525+ cr, 1, row[0],
1526+ {'parent_id': row[1]})
1527+
1528+def migrate_task_parent_ids(cr, pool):
1529+ task_pool = pool.get('project.task')
1530+ cr.execute("""
1531+ SELECT
1532+ id,
1533+ openupgrade_legacy_parent_id
1534+ FROM
1535+ project_task
1536+ WHERE
1537+ openupgrade_legacy_parent_id IS NOT NULL
1538+ """)
1539+ for row in cr.fetchall():
1540+ task_pool.write(
1541+ cr, 1, row[0],
1542+ {'parent_ids': [(4, row[1])]})
1543+
1544+def migrate_company_time_mode(cr, pool):
1545+ """
1546+ Migrate a char selection to a many2one
1547+ of model product.uom
1548+ No standard resources available
1549+ for less likely options 'week' and 'month'.
1550+ Mention this in the user notes
1551+ """
1552+ data_pool = pool.get('ir.model.data')
1553+ company_pool = pool.get('res.company')
1554+ uom_map = {
1555+ 'day': data_pool.get_object_reference(
1556+ cr, 1, 'product', 'uom_day')[1],
1557+ 'hours': data_pool.get_object_reference(
1558+ cr, 1, 'product', 'uom_hour')[1],
1559+ }
1560+ cr.execute("""
1561+ SELECT
1562+ id,
1563+ openupgrade_legacy_project_time_mode
1564+ FROM
1565+ res_company
1566+ WHERE
1567+ openupgrade_legacy_project_time_mode IS NOT NULL
1568+ """)
1569+ for row in cr.fetchall():
1570+ if uom_map.get(row[1]):
1571+ company_pool.write(
1572+ cr, 1, row[0],
1573+ {'project_time_mode_id': uom_map(row[1])})
1574+
1575+@openupgrade.migrate()
1576+def migrate(cr, version):
1577+ pool = pooler.get_pool(cr.dbname)
1578+ migrate_analytic(cr, pool)
1579+ openupgrade.set_defaults(cr, pool, defaults)
1580+ openupgrade.set_defaults(cr, pool, defaults_force, force=True)
1581+ migrate_task_parent_ids(cr, pool)
1582
1583=== added file 'project/migrations/6.0.1.1/pre-migration.py'
1584--- project/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
1585+++ project/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
1586@@ -0,0 +1,55 @@
1587+# -*- coding: utf-8 -*-
1588+##############################################################################
1589+#
1590+# OpenERP, Open Source Management Solution
1591+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1592+#
1593+# This program is free software: you can redistribute it and/or modify
1594+# it under the terms of the GNU Affero General Public License as
1595+# published by the Free Software Foundation, either version 3 of the
1596+# License, or (at your option) any later version.
1597+#
1598+# This program is distributed in the hope that it will be useful,
1599+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1600+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1601+# GNU Affero General Public License for more details.
1602+#
1603+# You should have received a copy of the GNU Affero General Public License
1604+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1605+#
1606+##############################################################################
1607+
1608+import logging
1609+from openupgrade import openupgrade
1610+
1611+logger = logging.getLogger('OpenUpgrade: project')
1612+
1613+renamed_columns = {
1614+ 'project_project': [
1615+ ('category_id', 'analytic_account_id'),
1616+ ('contact_id', 'openupgrade_legacy_contact_id'), # > aaa.contact_id
1617+ ('date_start', 'openupgrade_legacy_date_start'), # > aaa.date_start
1618+ ('date_end', 'openupgrade_legacy_date_end'), # > aaa.date
1619+ ('manager', 'openupgrade_legacy_manager'), # > aaa.user_id
1620+ ('name', 'openupgrade_legacy_name'), # > aaa.name
1621+ ('notes', 'openupgrade_legacy_notes'), # > aaa.description
1622+ ('parent_id', 'openupgrade_legacy_parent_id'), # aaa.parent_id of parent project's analytic account
1623+ ('partner_id', 'openupgrade_legacy_partner_id'), # > aaa.partner_id
1624+ ('state', 'openupgrade_legacy_state'), # > aaa.state (keys are equal)
1625+ ],
1626+ 'project_task': [
1627+ ('date_close', 'date_end'), # simple change of name
1628+ ('type', 'type_id'), # name change
1629+ ('parent_id', 'openupgrade_legacy_parent_id'), # m2o -> m2m parent_ids
1630+ ],
1631+ 'res_company': [
1632+ ('project_time_mode', 'openupgrade_legacy_project_time_mode'), # char selection -> m2o
1633+ ],
1634+ }
1635+
1636+@openupgrade.migrate()
1637+def migrate(cr, version):
1638+ openupgrade.rename_columns(cr, renamed_columns)
1639+ logger.warn(
1640+ "TODO: check whether project_task.date_deadline "
1641+ "preserves content when type changes from datetime to date")
1642
1643=== added file 'project/migrations/6.0.1.1/user_notes.txt'
1644--- project/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
1645+++ project/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
1646@@ -0,0 +1,2 @@
1647+This upgrade closely integrates projects with analytic accounts. Project parent relations will be preserved in the analytic account structure. Projects without a parent will be gathered under a new 'Projects' analytic account. Beware also of projects that point to the same analytic account.
1648+The company project time mode is now a relation to a UOM. The 'day' and 'hour' values are mapped automatically, but if your company time mode was set to 'week' or 'month', you should create a UOM in the system and select it under this setting.
1649
1650=== added file 'project_timesheet/migrations/6.0.1.0/post-migration.py'
1651--- project_timesheet/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
1652+++ project_timesheet/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
1653@@ -0,0 +1,43 @@
1654+# -*- coding: utf-8 -*-
1655+##############################################################################
1656+#
1657+# OpenERP, Open Source Management Solution
1658+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1659+#
1660+# This program is free software: you can redistribute it and/or modify
1661+# it under the terms of the GNU Affero General Public License as
1662+# published by the Free Software Foundation, either version 3 of the
1663+# License, or (at your option) any later version.
1664+#
1665+# This program is distributed in the hope that it will be useful,
1666+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1667+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1668+# GNU Affero General Public License for more details.
1669+#
1670+# You should have received a copy of the GNU Affero General Public License
1671+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1672+#
1673+##############################################################################
1674+
1675+from openupgrade import openupgrade
1676+
1677+def set_timesheet_id(cr):
1678+ """
1679+ Migrate an integer field that represents a
1680+ stock.incoterms' id field to a proper many2one
1681+ (i.e. weed out obsolete ids)
1682+ """
1683+ cr.execute("""
1684+ UPDATE
1685+ project_task_work
1686+ SET
1687+ hr_analytic_timesheet_id = hr_analytic_timesheet.id
1688+ FROM
1689+ hr_analytic_timesheet
1690+ WHERE
1691+ openupgrade_legacy_hr_analytic_timesheet_id = hr_analytic_timesheet.id
1692+ """)
1693+
1694+@openupgrade.migrate()
1695+def migrate(cr, version):
1696+ set_timesheet_id(cr)
1697
1698=== added file 'project_timesheet/migrations/6.0.1.0/pre-migration.py'
1699--- project_timesheet/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
1700+++ project_timesheet/migrations/6.0.1.0/pre-migration.py 2012-06-07 17:48:26 +0000
1701@@ -0,0 +1,34 @@
1702+# -*- coding: utf-8 -*-
1703+##############################################################################
1704+#
1705+# OpenERP, Open Source Management Solution
1706+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1707+#
1708+# This program is free software: you can redistribute it and/or modify
1709+# it under the terms of the GNU Affero General Public License as
1710+# published by the Free Software Foundation, either version 3 of the
1711+# License, or (at your option) any later version.
1712+#
1713+# This program is distributed in the hope that it will be useful,
1714+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1715+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1716+# GNU Affero General Public License for more details.
1717+#
1718+# You should have received a copy of the GNU Affero General Public License
1719+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1720+#
1721+##############################################################################
1722+
1723+from openupgrade import openupgrade
1724+
1725+column_renames = {
1726+ 'project_task_work': [
1727+ ('hr_analytic_timesheet_id', 'openupgrade_legacy_hr_analytic_timesheet_id'),
1728+ ],
1729+ }
1730+
1731+
1732+@openupgrade.migrate()
1733+def migrate(cr, version):
1734+ openupgrade.rename_columns(cr, column_renames)
1735+
1736
1737=== added file 'project_timesheet/migrations/6.0.1.0/user_notes.txt'
1738--- project_timesheet/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
1739+++ project_timesheet/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
1740@@ -0,0 +1,1 @@
1741+This upgrade migrates timesheet entries on task work to a proper database relation.
1742
1743=== added file 'purchase/migrations/6.0.1.1/data.xml'
1744--- purchase/migrations/6.0.1.1/data.xml 1970-01-01 00:00:00 +0000
1745+++ purchase/migrations/6.0.1.1/data.xml 2012-06-07 17:48:26 +0000
1746@@ -0,0 +1,20 @@
1747+<?xml version="1.0" encoding="utf-8"?>
1748+<openerp>
1749+<data noupdate="1">
1750+
1751+ <record model="ir.rule" id="purchase_order_comp_rule">
1752+ <field name="name">Purchase Order multi-company</field>
1753+ <field name="model_id" ref="model_purchase_order"/>
1754+ <field name="global" eval="True"/>
1755+ <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
1756+ </record>
1757+
1758+ <record model="ir.rule" id="purchase_order_line_comp_rule">
1759+ <field name="name">Purchase Order Line multi-company</field>
1760+ <field name="model_id" ref="model_purchase_order_line"/>
1761+ <field name="global" eval="True"/>
1762+ <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
1763+ </record>
1764+
1765+</data>
1766+</openerp>
1767
1768=== added file 'purchase/migrations/6.0.1.1/post-migration.py'
1769--- purchase/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
1770+++ purchase/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
1771@@ -0,0 +1,50 @@
1772+# -*- coding: utf-8 -*-
1773+##############################################################################
1774+#
1775+# OpenERP, Open Source Management Solution
1776+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1777+#
1778+# This program is free software: you can redistribute it and/or modify
1779+# it under the terms of the GNU Affero General Public License as
1780+# published by the Free Software Foundation, either version 3 of the
1781+# License, or (at your option) any later version.
1782+#
1783+# This program is distributed in the hope that it will be useful,
1784+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1785+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1786+# GNU Affero General Public License for more details.
1787+#
1788+# You should have received a copy of the GNU Affero General Public License
1789+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1790+#
1791+##############################################################################
1792+
1793+import pooler
1794+from openupgrade import openupgrade
1795+
1796+defaults_force = {
1797+ # False results in column value NULL
1798+ # None value triggers a call to the model's default function
1799+ 'purchase.order': [
1800+ ('company_id', None),
1801+ ],
1802+ }
1803+
1804+def set_order_invoice_ids(cr, pool):
1805+ """
1806+ Migrate many2one to many2many
1807+ """
1808+ order_pool = pool.get('purchase.order')
1809+ cr.execute('SELECT id, openupgrade_legacy_invoice_id '
1810+ 'FROM purchase_order '
1811+ 'WHERE openupgrade_legacy_invoice_id IS NOT NULL')
1812+ for row in cr.fetchall():
1813+ order_pool.write(
1814+ cr, 1, row[0], {'invoice_ids': [(4, row[1])]})
1815+
1816+@openupgrade.migrate()
1817+def migrate(cr, version):
1818+ pool = pooler.get_pool(cr.dbname)
1819+ openupgrade.set_defaults(cr, pool, defaults_force, force=True)
1820+ set_order_invoice_ids(cr, pool)
1821+ openupgrade.load_xml(cr, 'purchase', 'migrations/6.0.1.1/data.xml')
1822
1823=== added file 'purchase/migrations/6.0.1.1/pre-migration.py'
1824--- purchase/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
1825+++ purchase/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
1826@@ -0,0 +1,47 @@
1827+# -*- coding: utf-8 -*-
1828+##############################################################################
1829+#
1830+# OpenERP, Open Source Management Solution
1831+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1832+#
1833+# This program is free software: you can redistribute it and/or modify
1834+# it under the terms of the GNU Affero General Public License as
1835+# published by the Free Software Foundation, either version 3 of the
1836+# License, or (at your option) any later version.
1837+#
1838+# This program is distributed in the hope that it will be useful,
1839+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1840+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1841+# GNU Affero General Public License for more details.
1842+#
1843+# You should have received a copy of the GNU Affero General Public License
1844+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1845+#
1846+##############################################################################
1847+
1848+from openupgrade import openupgrade
1849+
1850+logger = logging.getLogger('OpenUpgrade: purchase')
1851+
1852+column_renames = {
1853+ # this is a mapping per table from old column name
1854+ # to new column name
1855+ 'purchase_order': [
1856+ ('invoice_id', 'openupgrade_legacy_invoice_id')
1857+ ],
1858+ }
1859+
1860+renamed_xmlids = [
1861+ ('mrp.act_buy', 'purchase.act_buy'),
1862+ ('mrp.trans_buy_make_done', 'purchase.trans_buy_make_done'),
1863+ ('mrp.trans_buy_cancel', 'purchase.trans_buy_cancel'),
1864+]
1865+
1866+@openupgrade.migrate()
1867+def migrate(cr, version):
1868+ openupgrade.rename_columns(cr, column_renames)
1869+ openupgrade.rename_xmlids(cr, renamed_xmlids)
1870+ logger.warn(
1871+ 'TODO: check whether datetime field preserves '
1872+ 'content when migrated to date field '
1873+ '(purchase_order.minimum_planned_date and po_line.date_planned)')
1874
1875=== added file 'purchase/migrations/6.0.1.1/user_notes.txt'
1876--- purchase/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
1877+++ purchase/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
1878@@ -0,0 +1,2 @@
1879+This upgrade allows multiple purchase orders to be related to multiple invoices instead of only one.
1880+
1881
1882=== added file 'purchase_analytic_plans/migrations/6.0.1.0/user_notes.txt'
1883--- purchase_analytic_plans/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
1884+++ purchase_analytic_plans/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
1885@@ -0,0 +1,1 @@
1886+Nothing to do for module 'purchase_analytic_plans'
1887
1888=== added file 'sale/migrations/6.0.1.0/post-migration.py'
1889--- sale/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
1890+++ sale/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
1891@@ -0,0 +1,53 @@
1892+# -*- coding: utf-8 -*-
1893+##############################################################################
1894+#
1895+# OpenERP, Open Source Management Solution
1896+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1897+#
1898+# This program is free software: you can redistribute it and/or modify
1899+# it under the terms of the GNU Affero General Public License as
1900+# published by the Free Software Foundation, either version 3 of the
1901+# License, or (at your option) any later version.
1902+#
1903+# This program is distributed in the hope that it will be useful,
1904+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1905+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1906+# GNU Affero General Public License for more details.
1907+#
1908+# You should have received a copy of the GNU Affero General Public License
1909+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1910+#
1911+##############################################################################
1912+
1913+import pooler
1914+from openupgrade import openupgrade
1915+
1916+defaults_force = {
1917+ # False results in column value NULL
1918+ # None value triggers a call to the model's default function
1919+ 'sale.shop': [('company_id', None)],
1920+ }
1921+
1922+
1923+def set_incoterm(cr):
1924+ """
1925+ Migrate selection field that represents a
1926+ stock.incoterms' code field to a proper many2one
1927+ """
1928+ cr.execute("""
1929+ UPDATE
1930+ sale_order
1931+ SET
1932+ incoterm = stock_incoterms.id
1933+ FROM
1934+ stock_incoterms
1935+ WHERE
1936+ openupgrade_legacy_incoterm IS NOT NULL
1937+ AND openupgrade_legacy_incoterm = stock_incoterms.code
1938+ """)
1939+
1940+@openupgrade.migrate()
1941+def migrate(cr, version):
1942+ pool = pooler.get_pool(cr.dbname)
1943+ openupgrade.set_defaults(cr, pool, defaults_force, force=True)
1944+ set_incoterm(cr)
1945
1946=== added file 'sale/migrations/6.0.1.0/pre-migration.py'
1947--- sale/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
1948+++ sale/migrations/6.0.1.0/pre-migration.py 2012-06-07 17:48:26 +0000
1949@@ -0,0 +1,34 @@
1950+# -*- coding: utf-8 -*-
1951+##############################################################################
1952+#
1953+# OpenERP, Open Source Management Solution
1954+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
1955+#
1956+# This program is free software: you can redistribute it and/or modify
1957+# it under the terms of the GNU Affero General Public License as
1958+# published by the Free Software Foundation, either version 3 of the
1959+# License, or (at your option) any later version.
1960+#
1961+# This program is distributed in the hope that it will be useful,
1962+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1963+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1964+# GNU Affero General Public License for more details.
1965+#
1966+# You should have received a copy of the GNU Affero General Public License
1967+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1968+#
1969+##############################################################################
1970+
1971+from openupgrade import openupgrade
1972+
1973+column_renames = {
1974+ 'sale_order': [
1975+ ('incoterm', 'openupgrade_legacy_incoterm'),
1976+ ],
1977+ }
1978+
1979+
1980+@openupgrade.migrate()
1981+def migrate(cr, version):
1982+ openupgrade.rename_columns(cr, column_renames)
1983+
1984
1985=== added file 'sale/migrations/6.0.1.0/user_notes.txt'
1986--- sale/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
1987+++ sale/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
1988@@ -0,0 +1,1 @@
1989+This upgrade stores a sale order's incoterm as a proper database relation. It also reloads the modified access permissions and security rules.
1990
1991=== added file 'sale_analytic_plans/migrations/6.0.1.0/user_notes.txt'
1992--- sale_analytic_plans/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
1993+++ sale_analytic_plans/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
1994@@ -0,0 +1,1 @@
1995+Nothing to do for module 'sale_analytic_plans'
1996
1997=== added file 'sale_journal/migrations/6.0.1.0/user_notes.txt'
1998--- sale_journal/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
1999+++ sale_journal/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
2000@@ -0,0 +1,1 @@
2001+Nothing to do for module 'sale_journal'
2002
2003=== added file 'stock/migrations/6.0.1.1/data.xml'
2004--- stock/migrations/6.0.1.1/data.xml 1970-01-01 00:00:00 +0000
2005+++ stock/migrations/6.0.1.1/data.xml 2012-06-07 17:48:26 +0000
2006@@ -0,0 +1,62 @@
2007+<?xml version="1.0" encoding="utf-8"?>
2008+<openerp>
2009+ <data noupdate="1">
2010+ <!-- Add a standard scrap location -->
2011+ <record id="stock_location_scrapped" model="stock.location">
2012+ <field name="name">Scrapped</field>
2013+ <field name="location_id" ref="stock_location_locations_virtual"/>
2014+ <field name="scrap_location">True</field>
2015+ <field name="usage">inventory</field>
2016+ <field name="company_id"></field>
2017+ </record>
2018+ <!-- The new stock journal -->
2019+ <record id="journal_delivery" model="stock.journal">
2020+ <field name="name">Delivery Orders</field>
2021+ </record>
2022+ <!-- update the output location with the new fields -->
2023+ <record id="stock_location_output" model="stock.location">
2024+ <field name="chained_auto_packing">transparent</field>
2025+ <field name="chained_picking_type">out</field>
2026+ <field name="chained_journal_id" ref="journal_delivery"/>
2027+ </record>
2028+ <!-- new sequences -->
2029+ <!-- We copied the old single sequence and sequence type
2030+ to these 'in' resources, but we still want to update the
2031+ name and code -->
2032+ <record id="seq_type_picking_in" model="ir.sequence.type">
2033+ <field name="name">Picking IN</field>
2034+ <field name="code">stock.picking.in</field>
2035+ </record>
2036+
2037+ <record id="seq_type_picking_out" model="ir.sequence.type">
2038+ <field name="name">Picking OUT</field>
2039+ <field name="code">stock.picking.out</field>
2040+ </record>
2041+
2042+ <record id="seq_type_picking_internal" model="ir.sequence.type">
2043+ <field name="name">Picking INT</field>
2044+ <field name="code">stock.picking.internal</field>
2045+ </record>
2046+
2047+ <record id="seq_picking_in" model="ir.sequence">
2048+ <field name="name">Picking IN</field>
2049+ <field name="code">stock.picking.in</field>
2050+ <field name="prefix">IN/</field>
2051+ <field name="padding">5</field>
2052+ </record>
2053+
2054+ <record id="seq_picking_out" model="ir.sequence">
2055+ <field name="name">Picking OUT</field>
2056+ <field name="code">stock.picking.out</field>
2057+ <field name="prefix">OUT/</field>
2058+ <field name="padding">5</field>
2059+ </record>
2060+
2061+ <record id="seq_picking_internal" model="ir.sequence">
2062+ <field name="name">Picking INT</field>
2063+ <field name="code">stock.picking.internal</field>
2064+ <field name="prefix">INT/</field>
2065+ <field name="padding">5</field>
2066+ </record>
2067+ </data>
2068+</openerp>
2069
2070=== added file 'stock/migrations/6.0.1.1/post-migration.py'
2071--- stock/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
2072+++ stock/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
2073@@ -0,0 +1,84 @@
2074+# -*- coding: utf-8 -*-
2075+##############################################################################
2076+#
2077+# OpenERP, Open Source Management Solution
2078+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
2079+#
2080+# This program is free software: you can redistribute it and/or modify
2081+# it under the terms of the GNU Affero General Public License as
2082+# published by the Free Software Foundation, either version 3 of the
2083+# License, or (at your option) any later version.
2084+#
2085+# This program is distributed in the hope that it will be useful,
2086+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2087+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2088+# GNU Affero General Public License for more details.
2089+#
2090+# You should have received a copy of the GNU Affero General Public License
2091+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2092+#
2093+##############################################################################
2094+
2095+import pooler
2096+from openupgrade import openupgrade
2097+
2098+defaults_force = {
2099+ 'stock.inventory': [('company_id', None)],
2100+ 'stock.location': [('company_id', None)],
2101+ 'stock.move': [('company_id', None)],
2102+ 'stock.picking': [('company_id', None)],
2103+ 'stock.production.lot': [('company_id', None)],
2104+ 'stock.warehouse': [('company_id', None)],
2105+ }
2106+
2107+def update_picking_type(cr):
2108+ """
2109+ Picking type 'out' is now applied instead
2110+ of type 'delivery'
2111+ """
2112+ openupgrade.logged_query(
2113+ cr,
2114+ """
2115+ UPDATE stock_picking
2116+ SET type = 'out'
2117+ WHERE type = 'delivery'
2118+ """)
2119+
2120+def set_valuation_accounts(cr):
2121+ """
2122+ The obsolete account_id field is now split up
2123+ in an incoming and outoing account
2124+ """
2125+ if openupgrade.column_exists(
2126+ cr, 'stock_location', 'openupgrade_legacy_account_id'):
2127+ openupgrade.logged_query(
2128+ cr,
2129+ """
2130+ UPDATE stock_location
2131+ SET valuation_in_account_id = openupgrade_legacy_account_id,
2132+ valuation_out_account_id = openupgrade_legacy_account_id
2133+ """)
2134+
2135+def set_move_date(cr):
2136+ """ Move date records the date expected
2137+ or picking date when done. The latter is not available
2138+ at upgrade time, so we set it to date expected
2139+ Note that 'date' field is the old date of creation,
2140+ which is now replaced by displaying the history field
2141+ 'create_date' (which assumingly already contains
2142+ appropriate values)
2143+ """
2144+ openupgrade.logged_query(
2145+ cr, """
2146+ UPDATE stock_move
2147+ SET date = date_expected
2148+ """)
2149+
2150+@openupgrade.migrate()
2151+def migrate(cr, version):
2152+ pool = pooler.get_pool(cr.dbname)
2153+ openupgrade.set_defaults(cr, pool, defaults)
2154+ openupgrade.set_defaults(cr, pool, defaults_force, force=True)
2155+ set_valuation_accounts(cr)
2156+ set_move_date(cr)
2157+ update_picking_type(cr)
2158
2159=== added file 'stock/migrations/6.0.1.1/pre-migration.py'
2160--- stock/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
2161+++ stock/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
2162@@ -0,0 +1,42 @@
2163+# -*- coding: utf-8 -*-
2164+##############################################################################
2165+#
2166+# OpenERP, Open Source Management Solution
2167+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
2168+#
2169+# This program is free software: you can redistribute it and/or modify
2170+# it under the terms of the GNU Affero General Public License as
2171+# published by the Free Software Foundation, either version 3 of the
2172+# License, or (at your option) any later version.
2173+#
2174+# This program is distributed in the hope that it will be useful,
2175+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2176+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2177+# GNU Affero General Public License for more details.
2178+#
2179+# You should have received a copy of the GNU Affero General Public License
2180+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2181+#
2182+##############################################################################
2183+
2184+from openupgrade import openupgrade
2185+
2186+renamed_columns = {
2187+ 'stock_move': [
2188+ ('date_planned', 'date_expected'),
2189+ ],
2190+ 'stock_location': [
2191+ ('account_id', 'openupgrade_legacy_account_id'),
2192+ ],
2193+ }
2194+
2195+renamed_xmlids = [
2196+ ('stock.seq_type_picking', 'stock.seq_type_picking_in'),
2197+ ('stock.seq_picking', 'stock.seq_picking_in'),
2198+ ]
2199+
2200+@openupgrade.migrate()
2201+def migrate(cr, version):
2202+ openupgrade.rename_columns(cr, renamed_columns)
2203+ openupgrade.rename_xmlids(cr, renamed_xmlids)
2204+
2205
2206=== added file 'stock/migrations/6.0.1.1/user_notes.txt'
2207--- stock/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
2208+++ stock/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
2209@@ -0,0 +1,1 @@
2210+This upgrade introduces three new sequences for stock pickings, separating ingoing, outgoing and internal pickings. By default however, your configuration will keep on using the previous single sequence for stock picking.

Subscribers

People subscribed via source and target branches