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
=== modified file 'account/migrations/6.0.1.1/post-migration.py'
--- account/migrations/6.0.1.1/post-migration.py 2011-11-30 23:09:14 +0000
+++ account/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
@@ -1,12 +1,27 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
221
3from osv import osv22import pooler
4import pooler, logging
5log = logging.getLogger('migrate')
6from openupgrade import openupgrade23from openupgrade import openupgrade
724
8MODULE='account'
9
10defaults = {25defaults = {
11 # False results in column value NULL26 # False results in column value NULL
12 # None value triggers a call to the model's default function 27 # None value triggers a call to the model's default function
@@ -27,12 +42,8 @@
27 ], 42 ],
28 }43 }
2944
45@openupgrade.migrate()
30def migrate(cr, version):46def migrate(cr, version):
31 try:47 pool = pooler.get_pool(cr.dbname)
32 log.info("post-set-defaults.py now called")48 openupgrade.set_defaults(cr, pool, defaults)
33 pool = pooler.get_pool(cr.dbname)49 openupgrade.load_xml(cr, 'account', 'migrations/6.0.1.1/data.xml')
34 openupgrade.set_defaults(cr, pool, defaults)
35 openupgrade.load_xml(cr, MODULE, 'migrations/6.0.1.1/data.xml')
36 except Exception, e:
37 log.error("Migration: error in post.py: %s" % e)
38 raise
3950
=== modified file 'account/migrations/6.0.1.1/pre-migration.py'
--- account/migrations/6.0.1.1/pre-migration.py 2011-11-30 23:09:14 +0000
+++ account/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -1,9 +1,27 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2import logging2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from tools import sql
3from openupgrade import openupgrade23from openupgrade import openupgrade
424
5logger = logging.getLogger('migrate')
6
7column_renames = {25column_renames = {
8 # this is a mapping per table from old column name26 # this is a mapping per table from old column name
9 # to new column name27 # to new column name
@@ -20,11 +38,11 @@
20 cr.execute("UPDATE account_journal SET type = 'sale_refund' " +38 cr.execute("UPDATE account_journal SET type = 'sale_refund' " +
21 "where type = 'sale' and refund_journal = TRUE")39 "where type = 'sale' and refund_journal = TRUE")
2240
41@openupgrade.migrate()
23def migrate(cr, version):42def migrate(cr, version):
24 try:43 openupgrade.rename_columns(cr, column_renames)
25 openupgrade.rename_columns(cr, column_renames)44 # This view, previously in report_account module
26 mgr_refund_journal_type(cr)45 # changes data type of one of the columns
27 except Exception, e:46 sql.drop_view_if_exists(cr, 'report_invoice_created')
28 log.error("Migration: error in pre.py: %s" % e)47 mgr_refund_journal_type(cr)
29 raise
3048
3149
=== added file 'account_analytic_analysis/migrations/6.0.1.1/user_notes.txt'
--- account_analytic_analysis/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
+++ account_analytic_analysis/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module 'account_analytic_analysis'
02
=== added file 'account_analytic_default/migrations/6.0.1.0/user_notes.txt'
--- account_analytic_default/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ account_analytic_default/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module 'account_analytic_default'
02
=== added file 'account_analytic_plans/migrations/6.0.1.0/user_notes.txt'
--- account_analytic_plans/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ account_analytic_plans/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module 'account_analytic_plans'
02
=== added file 'account_budget/migrations/6.0.1.0/post-migration.py'
--- account_budget/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
+++ account_budget/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,41 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25MODULE='account_budget'
26
27defaults_force = {
28 # False results in column value NULL
29 # None value triggers a call to the model's default function
30 'account.budget.post': [
31 ('company_id', None),
32 ],
33 'crossovered.budget': [
34 ('company_id', None),
35 ],
36 }
37
38@openupgrade.migrate()
39def migrate(cr, version):
40 pool = pooler.get_pool(cr.dbname)
41 openupgrade.set_defaults(cr, pool, defaults_force, force=True)
042
=== added file 'account_budget/migrations/6.0.1.0/user_notes.txt'
--- account_budget/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ account_budget/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,2 @@
1This upgrade allows budgets to be reset from state 'Cancel' to state 'Draft'.
2Budgets are by default now managed by accountants.
03
=== added file 'account_payment/migrations/6.0.1.1/data.xml'
--- account_payment/migrations/6.0.1.1/data.xml 1970-01-01 00:00:00 +0000
+++ account_payment/migrations/6.0.1.1/data.xml 2012-06-07 17:48:26 +0000
@@ -0,0 +1,13 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3<data noupdate="1">
4
5 <record id="payment_mode_comp_rule" model="ir.rule">
6 <field name="name">Payment Mode company rule</field>
7 <field model="ir.model" name="model_id" ref="model_payment_mode"/>
8 <field eval="True" name="global"/>
9 <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
10 </record>
11
12</data>
13</openerp>
014
=== added file 'account_payment/migrations/6.0.1.1/post-migration.py'
--- account_payment/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ account_payment/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,37 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25defaults_force = {
26 # False results in column value NULL
27 # None value triggers a call to the model's default function
28 'payment.mode': [
29 ('company_id', None),
30 ],
31 }
32
33@openupgrade.migrate()
34def migrate(cr, version):
35 pool = pooler.get_pool(cr.dbname)
36 openupgrade.set_defaults(cr, pool, defaults_force, force=True)
37 openupgrade.load_data(cr, 'account_payment', 'migrations/6.0.1.1/data.xml')
038
=== added file 'account_payment/migrations/6.0.1.1/pre-migration.py'
--- account_payment/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
+++ account_payment/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,35 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24column_renames = {
25 # this is a mapping per table from old column name
26 # to new column name
27 'payment_order': [
28 ('date_planned', 'date_scheduled'),
29 ],
30 }
31
32
33@openupgrade.migrate()
34def migrate(cr, version):
35 openupgrade.rename_columns(cr, column_renames)
036
=== added file 'account_payment/migrations/6.0.1.1/user_notes.txt'
--- account_payment/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
+++ account_payment/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,3 @@
1This upgrade performs a small amount of adaptations to the database structure related to module account_payment.
2
3
04
=== added file 'analytic_user_function/migrations/6.0.1.0/user_notes.txt'
--- analytic_user_function/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ analytic_user_function/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module 'analytic_user_function'
02
=== added file 'audittrail/migrations/6.0.1.0/user_notes.txt'
--- audittrail/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ audittrail/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module 'audittrail'
02
=== added file 'base_iban/migrations/6.0.1.0/user_notes.txt'
--- base_iban/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ base_iban/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module base_iban
02
=== added file 'base_report_creator/migrations/6.0.1.0/user_notes.txt'
--- base_report_creator/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ base_report_creator/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module base_report_creator
02
=== added file 'base_report_designer/migrations/6.0.0.1/user_notes.txt'
--- base_report_designer/migrations/6.0.0.1/user_notes.txt 1970-01-01 00:00:00 +0000
+++ base_report_designer/migrations/6.0.0.1/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,3 @@
1Nothing to do for module 'base_report_creator'
2
3
04
=== added file 'board/migrations/6.0.1.0/user_notes.txt'
--- board/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ board/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module board
02
=== added file 'hr/migrations/6.0.1.1/data.xml'
--- hr/migrations/6.0.1.1/data.xml 1970-01-01 00:00:00 +0000
+++ hr/migrations/6.0.1.1/data.xml 2012-06-07 17:48:26 +0000
@@ -0,0 +1,20 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="1">
4
5 <!-- Employee Marital Statusses, introduced in OpenERP 6 -->
6 <record id="hr_employee_marital_status_single" model="hr.employee.marital.status">
7 <field name="name">Single</field>
8 </record>
9 <record id="hr_employee_marital_status_married" model="hr.employee.marital.status">
10 <field name="name">Married</field>
11 </record>
12 <record id="hr_employee_marital_status_divorced" model="hr.employee.marital.status">
13 <field name="name">Divorced</field>
14 </record>
15 <record id="hr_employee_marital_status_widower" model="hr.employee.marital.status">
16 <field name="name">Widower</field>
17 </record>
18
19 </data>
20</openerp>
021
=== added file 'hr/migrations/6.0.1.1/post-migration.py'
--- hr/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ hr/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,187 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler, logging
23from openupgrade import openupgrade
24
25logger = logging.getLogger('OpenUpgrade: hr')
26
27defaults = {
28 # False results in column value NULL
29 # None value triggers a call to the model's default function
30 #'account.fiscalyear': [
31 # ('company_id', None),
32 # ],
33 }
34
35def create_employee_resources(cr, pool):
36 employee_pool = pool.get('hr.employee')
37 resource_pool = pool.get('resource.resource')
38 cr.execute("""
39SELECT
40 id,
41 openupgrade_legacy_user_id,
42 openupgrade_legacy_company_id,
43 openupgrade_legacy_name,
44 openupgrade_legacy_active
45FROM hr_employee
46WHERE resource_id is NULL
47""")
48 for row in cr.fetchall():
49 resource_id = resource_pool.create(
50 cr, 1,
51 {'user_id': row[1],
52 'company_id': row[2],
53 'name': row[3],
54 'active': row[4],
55 })
56 employee_pool.write(
57 cr, 1, row[0], {'resource_id': resource_id})
58
59def get_user_employee(cr, pool, user_id):
60 if not user_id:
61 return False
62 employee_pool = pool.get('hr.employee')
63 employee_ids = employee_pool.search(
64 cr, 1, [('user_id', '=', user_id)])
65 if employee_ids:
66 if len(employee_ids) > 1:
67 logger.info(
68 'user %d is associated with multiple active '
69 'employees. Need to select one for department membership or '
70 'manager' % user_id)
71 return employee_ids[0]
72 return False
73
74def set_department_manager(cr, pool):
75 """
76 Migrate department managment by user
77 by management by employee.
78 """
79 department_pool = pool.get('hr.department')
80 cr.execute( 'SELECT id, openupgrade_legacy_manager_user_id from hr_department')
81 for row in cr.fetchall():
82 employee_id = get_user_employee(
83 cr, pool, row[1])
84 if employee_id:
85 department_pool.write(
86 cr, 1, row[0], {'manager_id': employee_id})
87
88def set_user_department(cr, pool):
89 """
90 Migrate department membership by user
91 to membership by employee.
92 In OpenERP 6, an employee can only be in a single
93 department.
94 """
95 employee_pool = pool.get('hr.employee')
96 cr.execute("""
97SELECT
98 user_id,
99 department_id,
100 hr_department.manager_id
101FROM
102 openupgrade_legacy_hr_department_user_rel,
103 hr_department
104WHERE
105 openupgrade_legacy_hr_department_user_rel.department_id = hr_department.id
106""")
107 for row in cr.fetchall():
108 employee_id = get_user_employee(cr, pool, row[0])
109 if employee_id:
110 if employee_id == row[2]:
111 logger.info(
112 'OpenERP does not allow employee with id %s as a '
113 'member of the department that it is the manager of. '
114 % employee_id)
115 else:
116 employee_pool.write(
117 cr, 1, employee_id, {'department_id': row[1]})
118
119def set_marital(cr, pool):
120 """
121 Migrate selection field 'marital' to
122 a many2one field of model hr.employee.marital.status
123 """
124 marital_pool = pool.get('hr.employee.marital.status')
125 employee_pool = pool.get('hr.employee')
126 def get_or_create(marital):
127 marital = {
128 'maried': 'Married',
129 'unmaried': 'Single',
130 'divorced': 'Divorced',
131 'other': 'Other'
132 }.get(marital, marital)
133 ids = marital_pool.search(
134 cr, 1, [('name', '=', marital)])
135 if ids:
136 return ids[0]
137 return marital_pool.create(
138 cr, 1, {'name': marital})
139 # marital might already be filled by the renaming of
140 # hr_contract's marital_status
141 cr.execute('SELECT id, openupgrade_legacy_marital '
142 'FROM hr_employee WHERE marital IS NULL '
143 'AND openupgrade_legacy_marital IS NOT NULL')
144 for row in cr.fetchall():
145 employee_pool.write(
146 cr, 1, row[0], {'marital': get_or_create(row[1])})
147
148def set_department_manager(cr, pool):
149 """
150 Migrate department managment by user
151 by management by employee.
152 """
153 department_pool = pool.get('hr.department')
154 cr.execute( 'SELECT id, openupgrade_legacy_manager_user_id from hr_department')
155 for row in cr.fetchall():
156 employee_id = get_user_employee(
157 cr, pool, row[1])
158 if employee_id:
159 department_pool.write(
160 cr, 1, row[0], {'manager_id': employee_id})
161
162def set_category_ids(cr, pool):
163 """
164 Migrate the many2one category_id field
165 to many2many category_ids
166 """
167 employee_pool = pool.get('hr.employee')
168 cr.execute('SELECT id, openupgrade_legacy_category_id '
169 'FROM hr_employee '
170 'WHERE openupgrade_legacy_category_id IS NOT NULL')
171 for row in cr.fetchall():
172 employee_pool.write(
173 cr, 1, row[0], {'category_ids': [(4, row[1])]})
174
175@openupgrade.migrate()
176def migrate(cr, version):
177 pool = pooler.get_pool(cr.dbname)
178 openupgrade.set_defaults(cr, pool, defaults)
179 create_employee_resources(cr, pool)
180 set_department_manager(cr, pool)
181 set_user_department(cr, pool)
182 set_category_ids(cr, pool)
183 # The following definitions were moved from hr_contract.
184 # In case this module was installed, the reloading of the data
185 # will only overwrite the name if it was altered
186 openupgrade.load_xml(cr, 'hr', 'migrations/6.0.1.1/data.xml')
187 set_marital(cr, pool)
0188
=== added file 'hr/migrations/6.0.1.1/pre-migration.py'
--- hr/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
+++ hr/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,67 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24column_renames = {
25 # this is a mapping per table from old column name
26 # to new column name
27 'hr_department': [
28 ('manager_id', 'openupgrade_legacy_manager_user_id'),
29 ],
30 'hr_employee': [
31 ('user_id', 'openupgrade_legacy_user_id'),
32 ('name', 'openupgrade_legacy_name'),
33 ('active', 'openupgrade_legacy_active'),
34 ('company_id', 'openupgrade_legacy_company_id'),
35 ('category_id', 'openupgrade_legacy_category_id'),
36 ('marital', 'openupgrade_legacy_marital'),
37 ('parent_id', 'openupgrade_legacy_parent_id'),
38 ]
39 }
40
41renamed_xmlids = [
42 ('hr.group_hr_user', 'base.group_hr_user'),
43 ('hr.group_hr_manager', 'base.group_hr_manager'),
44 ('hr_contract.hr_employee_marital_status_divorced',
45 'hr.hr_employee_marital_status_divorced'),
46 ('hr_contract.hr_employee_marital_status_married',
47 'hr.hr_employee_marital_status_married'),
48 ('hr_contract.hr_employee_marital_status_single',
49 'hr.hr_employee_marital_status_single'),
50 ('hr_contract.hr_employee_marital_status_widower',
51 'hr.hr_employee_marital_status_widower'),
52]
53
54@openupgrade.migrate()
55def migrate(cr, version):
56 openupgrade.rename_columns(cr, column_renames)
57 # marital status as provided by hr_contract if installed
58 if openupgrade.column_exists(
59 cr, 'hr_employee', 'marital_status'):
60 openupgrade.rename_columns(
61 cr, { 'hr_employee': [('marital_status', 'marital')]})
62 openupgrade.rename_tables(
63 cr,
64 [('hr_department_user_rel',
65 'openupgrade_legacy_hr_department_user_rel')])
66 openupgrade.rename_xmlids(cr, renamed_xmlids)
67
068
=== added file 'hr/migrations/6.0.1.1/user_notes.txt'
--- hr/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
+++ hr/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,6 @@
1This upgrade consists of the following changes:
2- Marital status is now a choice from a lookup table
3 previously provided by the hr contract module
4- An employee can now have multiple categories
5- The employee model is integrated with the resource model
6- Departments now have employees as their member type, not system users
07
=== added file 'hr_attendance/migrations/6.0.1.1/user_notes.txt'
--- hr_attendance/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
+++ hr_attendance/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module 'hr_attendance'
02
=== added file 'hr_contract/migrations/6.0.1.0/data.xml'
--- hr_contract/migrations/6.0.1.0/data.xml 1970-01-01 00:00:00 +0000
+++ hr_contract/migrations/6.0.1.0/data.xml 2012-06-07 17:48:26 +0000
@@ -0,0 +1,19 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="1">
4
5 <!-- Contract Types -->
6 <record id="hr_contract_type_emp" model="hr.contract.type">
7 <field name="name">Employee</field>
8 </record>
9
10 <record id="hr_contract_type_wrkr" model="hr.contract.type">
11 <field name="name">Worker</field>
12 </record>
13
14 <record id="hr_contract_type_sub" model="hr.contract.type">
15 <field name="name">Subcontractor</field>
16 </record>
17
18 </data>
19</openerp>
020
=== added file 'hr_contract/migrations/6.0.1.0/post-migration.py'
--- hr_contract/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
+++ hr_contract/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,83 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler, logging
23from openupgrade import openupgrade
24
25logger = logging.getLogger('migrate')
26MODULE = 'hr_contract'
27
28def set_contract_job_id(cr, pool):
29 """
30 Migrate function_id (res.partner.function) field on hr.contract
31 to job_id (hr.job).
32 Create jobs if necessary, taking company_id into account.
33 """
34 job_pool = pool.get('hr.job')
35 contract_pool = pool.get('hr.contract')
36 def get_or_create(name, company_id):
37 ids = job_pool.search(
38 cr, 1, [('name', '=', name),
39 ('company_id', '=', company_id)])
40 if ids:
41 return ids[0]
42 return job_pool.create(
43 cr, 1, {'name': name,
44 'company_id': company_id})
45 # marital might already be filled by the renaming of
46 # hr_contract's marital_status
47 cr.execute(
48 'SELECT '
49 ' hr_contract.id, '
50 ' openupgrade_legacy_res_partner_function.name, '
51 ' resource_resource.company_id '
52 'FROM '
53 ' hr_contract, '
54 ' hr_employee, '
55 ' resource_resource, '
56 ' openupgrade_legacy_res_partner_function '
57 'WHERE '
58 ' hr_employee.resource_id = resource_resource.id '
59 ' AND hr_contract.job_id IS NULL '
60 ' AND hr_contract.employee_id = hr_employee.id '
61 ' AND openupgrade_legacy_function = openupgrade_legacy_res_partner_function.id')
62 for row in cr.fetchall():
63 contract_pool.write(
64 cr, 1, row[0],
65 {'job_id': get_or_create(row[1], row[2] or False)})
66
67
68def set_contract_default_type_id(cr, pool):
69 default_type_ref = pool.get('ir.model.data').get_object_reference(
70 cr, 1, 'hr_contract', 'hr_contract_type_emp')
71 if default_type_ref:
72 openupgrade.set_defaults(
73 cr, pool,
74 {'hr.contract': [('type_id', default_type_ref[1])]})
75 else:
76 logger.warn('%s: Default contact type not found' % MODULE)
77
78@openupgrade.migrate()
79def migrate(cr, version):
80 pool = pooler.get_pool(cr.dbname)
81 openupgrade.load_data(cr, MODULE, 'migrations/6.0.1.0/data.xml')
82 set_contract_job_id(cr, pool)
83 set_contract_default_type_id(cr, pool)
084
=== added file 'hr_contract/migrations/6.0.1.0/pre-migration.py'
--- hr_contract/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
+++ hr_contract/migrations/6.0.1.0/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,35 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24column_renames = {
25 # this is a mapping per table from old column name
26 # to new column name
27 'hr_contract': [
28 ('function', 'openupgrade_legacy_function'),
29 ],
30 }
31
32@openupgrade.migrate()
33def migrate(cr, version):
34 openupgrade.rename_columns(cr, column_renames)
35
036
=== added file 'hr_contract/migrations/6.0.1.0/user_notes.txt'
--- hr_contract/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ hr_contract/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,3 @@
1This upgrade migrates functions on contracts to 'jobs' from the hr module.
2It also adds contract types such as 'Employee' or 'Subcontractor'
3
04
=== added file 'hr_expense/migrations/6.0.1.0/post-migration.py'
--- hr_expense/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
+++ hr_expense/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,34 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25defaults_force = {
26 'hr.expense.expense': [
27 ('company_id', None)
28 ]
29 }
30
31@openupgrade.migrate()
32def migrate(cr, version):
33 pool = pooler.get_pool(cr.dbname)
34 openupgrade.set_defaults(cr, pool, defaults_force, force=True)
035
=== added file 'hr_expense/migrations/6.0.1.0/user_notes.txt'
--- hr_expense/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ hr_expense/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1This upgrade adds security rules for access to expenses.
02
=== added file 'hr_timesheet/migrations/6.0.1.0/user_notes.txt'
--- hr_timesheet/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ hr_timesheet/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1This upgrade adds a dedicated timesheet journal
02
=== added file 'hr_timesheet_invoice/migrations/6.0.1.0/user_notes.txt'
--- hr_timesheet_invoice/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ hr_timesheet_invoice/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1This upgrade adds default entries to the invoice factor table.
02
=== added file 'hr_timesheet_sheet/migrations/6.0.1.0/post-migration.py'
--- hr_timesheet_sheet/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
+++ hr_timesheet_sheet/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,55 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25defaults_force = {
26 'hr_timesheet_sheet.sheet':
27 [('company_id', None)],
28 }
29
30def set_timesheet_employee(cr, pool):
31 """
32 Migrate timesheet owner by user to employee.
33 """
34 sheet_pool = pool.get('hr_timesheet_sheet.sheet')
35 cr.execute("""
36 SELECT
37 hr_timesheet_sheet_sheet.id,
38 hr_employee.id
39 FROM
40 hr_timesheet_sheet_sheet,
41 hr_employee
42 WHERE
43 hr_timesheet_sheet_sheet.employee_id IS NULL
44 AND hr_timesheet_sheet_sheet.openupgrade_legacy_user_id IS NOT NULL
45 AND hr_employee.openupgrade_legacy_user_id = hr_timesheet_sheet_sheet.openupgrade_legacy_user_id
46 """)
47 for row in cr.fetchall():
48 sheet_pool.write(
49 cr, 1, [row[0]], {'employee_id': row[1]})
50
51@openupgrade.migrate()
52def migrate(cr, version):
53 pool = pooler.get_pool(cr.dbname)
54 openupgrade.set_defaults(cr, pool, defaults_force, force=True)
55 set_timesheet_employee(cr, pool)
056
=== added file 'hr_timesheet_sheet/migrations/6.0.1.0/pre-migration.py'
--- hr_timesheet_sheet/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
+++ hr_timesheet_sheet/migrations/6.0.1.0/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,34 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24column_renames = {
25 # this is a mapping per table from old column name
26 # to new column name
27 'hr_timesheet_sheet_sheet': [
28 ('user_id', 'openupgrade_legacy_user_id'),
29 ],
30 }
31
32@openupgrade.migrate()
33def migrate(cr, version):
34 openupgrade.rename_columns(cr, column_renames)
035
=== added file 'hr_timesheet_sheet/migrations/6.0.1.0/user_notes.txt'
--- hr_timesheet_sheet/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ hr_timesheet_sheet/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Timesheets are now related to employees, not to users. Existing timesheets will be migrated, if an employee exists for the user.
02
=== added file 'mrp/migrations/6.0.1.1/post-migration.py'
--- mrp/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ mrp/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,64 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25defaults_force = {
26 'mrp.bom': [('company_id', None)],
27 'mrp.production': [('company_id', None)],
28 'mrp.routing': [('company_id', None)],
29 'mrp.workcenter': [('company_id', None)],
30}
31
32def create_workcenter_resources(cr, pool):
33 # note: set default value for company_id
34 # on the workcenter
35 # after running this function
36 workcenter_pool = pool.get('mrp.workcenter')
37 resource_pool = pool.get('resource.resource')
38 cr.execute("""
39SELECT
40 id,
41 openupgrade_legacy_code,
42 openupgrade_legacy_name,
43 openupgrade_legacy_active
44FROM
45 mrp_workcenter
46WHERE
47 resource_id is NULL""")
48
49 for row in cr.fetchall():
50 resource_id = resource_pool.create(
51 cr, 1,
52 {
53 'code': row[1],
54 'name': row[2],
55 'active': row[3],
56 'resource_type': 'material',
57 })
58 workcenter_pool.write(
59 cr, 1, row[0], {'resource_id': resource_id})
60
61@openupgrade.migrate()
62def migrate(cr, version):
63 pool = pooler.get_pool(cr.dbname)
64 create_workcenter_resources(cr, pool)
065
=== added file 'mrp/migrations/6.0.1.1/pre-migration.py'
--- mrp/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
+++ mrp/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,38 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24column_renames = {
25 'mrp_production': [
26 ('date_finnished', 'date_finished'),
27 ],
28 'mrp_workcenter': [
29 ('code', 'openupgrade_legacy_code'),
30 ('name', 'openupgrade_legacy_name'),
31 ('active', 'openupgrade_legacy_active'),
32 ]
33 }
34
35@openupgrade.migrate()
36def migrate(cr, version):
37 openupgrade.rename_columns(cr, column_renames)
38
039
=== added file 'mrp/migrations/6.0.1.1/user_notes.txt'
--- mrp/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
+++ mrp/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Much 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.
02
=== added file 'process/migrations/6.0.1.0/user_notes.txt'
--- process/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ process/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module 'process'
02
=== added file 'procurement/migrations/6.0.1.0/data.xml'
--- procurement/migrations/6.0.1.0/data.xml 1970-01-01 00:00:00 +0000
+++ procurement/migrations/6.0.1.0/data.xml 2012-06-07 17:48:26 +0000
@@ -0,0 +1,22 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="1">
4 <!-- The following changes may already be loaded upon
5 the auto-installation of the procurement module when
6 a v5 database with mrp installed is being upgraded
7 to v6 -->
8
9 <!-- OpenERP 6 changes the code of these resources -->
10 <record id="sequence_mrp_op_type" model="ir.sequence.type">
11 <field name="code">stock.orderpoint</field>
12 </record>
13 <record id="sequence_mrp_op" model="ir.sequence.type">
14 <field name="code">stock.orderpoint</field>
15 </record>
16 <!-- change the model of the scheduled task -->
17 <record id="ir_cron_scheduler_action" model="ir.cron">
18 <field eval="'procurement.order'" name="model"/>
19 </record>
20 </data>
21</openerp>
22
023
=== added file 'procurement/migrations/6.0.1.0/post-migration.py'
--- procurement/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
+++ procurement/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,34 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25defaults_force = {
26 'procurement.order': [('company_id', None)],
27 'stock.warehouse.orderpoint': [('company_id', None)],
28}
29
30@openupgrade.migrate()
31def migrate(cr, version):
32 pool = pooler.get_pool(cr.dbname)
33 openupgrade.set_defaults(cr, pool, defaults_force, force=True)
34 openupgrade.load_data(cr, MODULE, 'migrations/6.0.1.0/data.xml')
035
=== added file 'procurement/migrations/6.0.1.0/pre-migration.py'
--- procurement/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
+++ procurement/migrations/6.0.1.0/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,84 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import logging
23from openupgrade import openupgrade
24
25logger = logging.getLogger('OpenUpgrade: procurement')
26
27renamed_xmlids = [
28 ('mrp.wkf', 'procurement.wkf_procurement'),
29 ('mrp.act_draft', 'procurement.act_draft'),
30 ('mrp.act_cancel', 'procurement.act_cancel'),
31 ('mrp.act_confirm', 'procurement.act_confirm'),
32 ('mrp.act_confirm_wait', 'procurement.act_confirm_wait'),
33 ('mrp.act_confirm_mts', 'procurement.act_confirm_mts'),
34 ('mrp.act_confirm_mto', 'procurement.act_confirm_mto'),
35 ('mrp.act_make_to_stock', 'procurement.act_make_to_stock'),
36 ('mrp.act_produce_check', 'procurement.act_produce_check'),
37 ('mrp.act_produce_service', 'procurement.act_produce_service'),
38 ('mrp.act_make_done', 'procurement.act_make_done'),
39 ('mrp.act_wait_done', 'procurement.act_wait_done'),
40 ('mrp.act_done', 'procurement.act_done'),
41 ('mrp.trans_draft_confirm', 'procurement.trans_draft_confirm'),
42 ('mrp.trans_confirm_cancel2', 'procurement.trans_confirm_cancel2'),
43 ('mrp.trans_confirm_wait_done', 'procurement.trans_confirm_wait_done'),
44 ('mrp.trans_confirm_cancel', 'procurement.trans_confirm_cancel'),
45 ('mrp.trans_confirm_confirm_wait', 'procurement.trans_confirm_confirm_wait'),
46 ('mrp.trans_confirm_wait_confirm_mto', 'procurement.trans_confirm_wait_confirm_mto'),
47 ('mrp.trans_confirm_wait_confirm_mts', 'procurement.trans_confirm_wait_confirm_mts'),
48 ('mrp.trans_confirm_mts_cancel', 'procurement.trans_confirm_mts_cancel'),
49 ('mrp.trans_confirm_waiting_cancel', 'procurement.trans_confirm_waiting_cancel'),
50 ('mrp.trans_confirm_mts_confirm', 'procurement.trans_confirm_mts_confirm'),
51 ('mrp.trans_confirm_mto_cancel', 'procurement.trans_confirm_mto_cancel'),
52 ('mrp.trans_confirm_mto_confirm', 'procurement.trans_confirm_mto_confirm'),
53 ('mrp.trans_draft_cancel', 'procurement.trans_draft_cancel'),
54 ('mrp.trans_confirm_mts_make_to_stock', 'procurement.trans_confirm_mts_make_to_stock'),
55 ('mrp.trans_confirm_mto_produce_check', 'procurement.trans_confirm_mto_produce_check'),
56 ('mrp.trans_product_check_produce_service', 'procurement.trans_product_check_produce_service'),
57 ('mrp.trans_confirm_mto_buy', 'procurement.trans_confirm_mto_purchase'),
58 ('mrp.trans_make_to_stock_make_done', 'procurement.trans_make_to_stock_make_done'),
59 ('mrp.trans_produce_service_cancel', 'procurement.trans_produce_service_cancel'),
60 ('mrp.trans_produce_service_make_done', 'procurement.trans_produce_service_make_done'),
61 ('mrp.trans_make_done_done', 'procurement.trans_make_done_done'),
62 ('mrp.trans_make_done_confirm', 'procurement.trans_make_done_confirm'),
63 ('mrp.sequence_mrp_op_type', 'procurement.sequence_mrp_op_type'),
64 ('mrp.sequence_mrp_op', 'procurement.sequence_mrp_op'),
65 ('mrp.ir_cron_scheduler_action', 'procurement.ir_cron_scheduler_action'),
66]
67
68# Cannot use the OpenUpgrade decorator
69# as in this case, do not return immediately when
70# version is False. We need to facilitate the
71# functionality move from the mrp module
72
73def migrate(cr, version):
74 logger.info("pre-migration.py called with version %s" % version)
75 try:
76 if openupgrade.table_exists(cr, 'mrp_procurement'):
77 logger.info("moving functionality from the OpenERP 5 MRP module")
78 openupgrade.rename_tables(cr, [('mrp_procurement', 'procurement_order')])
79 openupgrade.rename_models(cr, [('mrp.procurement', 'procurement.order')])
80 openupgrade.rename_xmlids(cr, renamed_xmlids)
81 except Exception, e:
82 logger.error("error in pre-migration.py: %s" % e)
83 raise
84
085
=== added file 'procurement/migrations/6.0.1.0/user_notes.txt'
--- procurement/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ procurement/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1This 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.
02
=== added file 'product/migrations/6.0.1.1/data.xml'
--- product/migrations/6.0.1.1/data.xml 1970-01-01 00:00:00 +0000
+++ product/migrations/6.0.1.1/data.xml 2012-06-07 17:48:26 +0000
@@ -0,0 +1,66 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="1">
4 <!-- OpenUpgrade: add new product and UOM categories -->
5 <record id="cat0" model="product.category">
6 <field name="name">All products</field>
7 </record>
8 <record id="uom_categ_wtime" model="product.uom.categ">
9 <field name="name">Working Time</field>
10 </record>
11 <record id="uom_categ_length" model="product.uom.categ">
12 <field name="name">Length / Distance</field>
13 </record>
14 <!-- OpenUpgrade: add factor and/or rounding properties -->
15 <record id="product_uom_unit" model="product.uom">
16 <field name="factor" eval="1.0"/>
17 <field name="rounding" eval="1.0"/>
18 </record>
19 <record id="product_uom_kgm" model="product.uom">
20 <field name="factor" eval="1"/>
21 </record>
22 <!-- OpenUpgrade: add new UOMs -->
23 <record id="product_uom_gram" model="product.uom">
24 <field name="category_id" ref="product_uom_categ_kgm"/>
25 <field name="name">g</field>
26 <field name="factor" eval="1000"/>
27 <field name="uom_type">smaller</field>
28 </record>
29 <record id="uom_hour" model="product.uom">
30 <field name="name">Hour</field>
31 <field eval="uom_categ_wtime" name="category_id"/>
32 <field name="factor" eval="8.0"/>
33 <field name="uom_type">smaller</field>
34 </record>
35 <record id="uom_day" model="product.uom">
36 <field name="name">Day</field>
37 <field eval="uom_categ_wtime" name="category_id"/>
38 <field name="factor" eval="1.0"/>
39 </record>
40 <record id="product_uom_ton" model="product.uom">
41 <field name="category_id" ref="product_uom_categ_kgm"/>
42 <!-- 'tonne' is the most common spelling in english-speaking countries,
43 the alternative is 'metric ton' in the US, abbreviated as 'mt' -->
44 <field name="name">tonne</field>
45 <field name="factor" eval="0.001"/>
46 <field name="uom_type">bigger</field>
47 </record>
48 <record id="product_uom_meter" model="product.uom">
49 <field name="category_id" ref="uom_categ_length"/>
50 <field name="name">m</field>
51 <field name="factor" eval="1.0"/>
52 </record>
53 <record id="product_uom_km" model="product.uom">
54 <field name="category_id" ref="uom_categ_length"/>
55 <field name="name">km</field>
56 <field name="factor" eval="0.001"/>
57 <field name="uom_type">bigger</field>
58 </record>
59 <record id="product_uom_cm" model="product.uom">
60 <field name="category_id" ref="uom_categ_length"/>
61 <field name="name">cm</field>
62 <field name="factor" eval="100"/>
63 <field name="uom_type">smaller</field>
64 </record>
65 </data>
66</openerp>
067
=== added file 'product/migrations/6.0.1.1/post-migration.py'
--- product/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ product/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,35 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25defaults_force = {
26 'product.category': [('type', 'normal')],
27 #'product.pricelist': [('company_id', None)], # no default function present
28 'product.supplierinfo': [('company_id', None)],
29}
30
31@openupgrade.migrate()
32def migrate(cr, version):
33 pool = pooler.get_pool(cr.dbname)
34 openupgrade.set_defaults(cr, pool, defaults_force, force=True)
35 openupgrade.load_data(cr, 'product', 'migrations/6.0.1.1/data.xml')
036
=== added file 'product/migrations/6.0.1.1/pre-migration.py'
--- product/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
+++ product/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,46 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24logger = logging.getLogger('OpenUpgrade: product')
25
26renamed_columns = {
27 'product_supplierinfo': [
28 ('qty', 'min_qty')]
29 }
30
31def update_packaging_type(cr):
32 """ A spelling error has been fixed
33 in the selection list """
34 cr.execute("""
35 UPDATE product_ul
36 SET type = %s
37 WHERE type = %s""", ('pallet', 'palet'))
38
39@openupgrade.migrate()
40def migrate(cr, version):
41 openupgrade.rename_columns(cr, renamed_columns)
42 update_packaging_type(cr)
43 logger.warn(
44 "TODO: check whether product_packaging.name "
45 "preserves content when migrating from type char "
46 "to type text")
047
=== added file 'product/migrations/6.0.1.1/user_notes.txt'
--- product/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
+++ product/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,5 @@
1This 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.
2A 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.
3Modified access permissions and security rules are reloaded.
4
5
06
=== added file 'project/migrations/6.0.1.1/post-migration.py'
--- project/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ project/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,168 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25defaults = {
26 'project.project': [('sequence', 10)],
27 'project.task.type': [('sequence', 1)],
28 }
29
30defaults_force = {
31 'project.task': [('company_id', None)],
32 }
33
34def migrate_analytic(cr, pool):
35 """
36 Transfer obsolete values from projects to their analytic accounts.
37 Create analytic account if necessary. Take care not to overwrite
38 existing values on analytic accounts
39 """
40 project_pool = pool.get('project.project')
41 analytic_pool = pool.get('account.analytic.account')
42 project_ids = project_pool.search(
43 cr, 1,
44 [('analytic_account_id', '!=', False)],
45 context={'active_test': False})
46 analytics = dict([(x.id, x.analytic_account_id) for x in project_pool.browse(
47 cr, 1, project_ids)])
48 cr.execute("""
49 SELECT
50 id,
51 analytic_account_id,
52 openupgrade_legacy_contact_id,
53 openupgrade_legacy_date_start,
54 openupgrade_legacy_date_end,
55 openupgrade_legacy_manager,
56 openupgrade_legacy_name,
57 openupgrade_legacy_notes,
58 openupgrade_legacy_partner_id,
59 openupgrade_legacy_state
60 FROM
61 project_project
62 """)
63 for row in cr.fetchall():
64 if not row[1]:
65 analytic_id = analytic_pool.create(
66 cr, 1,
67 { 'contact_id': row[2] or False,
68 'date_start': row[3] or False,
69 'date': row[4] or False,
70 'user_id' : row[5] or False,
71 'name': row[6] or False,
72 'description': row[7] or False,
73 'partner_id': row[8] or False,
74 'state': row[9] or False,
75 })
76 project_pool.write(
77 cr, 1, row[0],
78 {'analytic_account_id': analytic_id})
79 else:
80 vals = {}
81 for num, field in [
82 (2, 'contact_id'),
83 (3, 'date_start'),
84 (4, 'date'),
85 (5, 'user_id'),
86 (6, 'name'),
87 (7, 'description'),
88 (8, 'partner_id'),
89 (9, 'state')]:
90 if row[num] and not analytics[row[0]][field]:
91 vals[field] = row[num]
92 analytic_pool.write(
93 cr, 1, row[1], vals)
94
95 # second pass: transfer project hierarchy
96 # to analytic hierarchy
97 cr.execute("""
98 SELECT
99 child.analytic_account_id,
100 parent.analytic_account_id
101 FROM
102 project_project as child,
103 project_project as parent,
104 account_analytic_account as a
105 WHERE
106 child.openupgrade_legacy_parent_id = parent.id
107 AND child.analytic_account_id = a.id
108 AND a.parent_id IS NULL
109 """)
110 for row in cr.fetchall():
111 analytic_pool.write(
112 cr, 1, row[0],
113 {'parent_id': row[1]})
114
115def migrate_task_parent_ids(cr, pool):
116 task_pool = pool.get('project.task')
117 cr.execute("""
118 SELECT
119 id,
120 openupgrade_legacy_parent_id
121 FROM
122 project_task
123 WHERE
124 openupgrade_legacy_parent_id IS NOT NULL
125 """)
126 for row in cr.fetchall():
127 task_pool.write(
128 cr, 1, row[0],
129 {'parent_ids': [(4, row[1])]})
130
131def migrate_company_time_mode(cr, pool):
132 """
133 Migrate a char selection to a many2one
134 of model product.uom
135 No standard resources available
136 for less likely options 'week' and 'month'.
137 Mention this in the user notes
138 """
139 data_pool = pool.get('ir.model.data')
140 company_pool = pool.get('res.company')
141 uom_map = {
142 'day': data_pool.get_object_reference(
143 cr, 1, 'product', 'uom_day')[1],
144 'hours': data_pool.get_object_reference(
145 cr, 1, 'product', 'uom_hour')[1],
146 }
147 cr.execute("""
148 SELECT
149 id,
150 openupgrade_legacy_project_time_mode
151 FROM
152 res_company
153 WHERE
154 openupgrade_legacy_project_time_mode IS NOT NULL
155 """)
156 for row in cr.fetchall():
157 if uom_map.get(row[1]):
158 company_pool.write(
159 cr, 1, row[0],
160 {'project_time_mode_id': uom_map(row[1])})
161
162@openupgrade.migrate()
163def migrate(cr, version):
164 pool = pooler.get_pool(cr.dbname)
165 migrate_analytic(cr, pool)
166 openupgrade.set_defaults(cr, pool, defaults)
167 openupgrade.set_defaults(cr, pool, defaults_force, force=True)
168 migrate_task_parent_ids(cr, pool)
0169
=== added file 'project/migrations/6.0.1.1/pre-migration.py'
--- project/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
+++ project/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,55 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import logging
23from openupgrade import openupgrade
24
25logger = logging.getLogger('OpenUpgrade: project')
26
27renamed_columns = {
28 'project_project': [
29 ('category_id', 'analytic_account_id'),
30 ('contact_id', 'openupgrade_legacy_contact_id'), # > aaa.contact_id
31 ('date_start', 'openupgrade_legacy_date_start'), # > aaa.date_start
32 ('date_end', 'openupgrade_legacy_date_end'), # > aaa.date
33 ('manager', 'openupgrade_legacy_manager'), # > aaa.user_id
34 ('name', 'openupgrade_legacy_name'), # > aaa.name
35 ('notes', 'openupgrade_legacy_notes'), # > aaa.description
36 ('parent_id', 'openupgrade_legacy_parent_id'), # aaa.parent_id of parent project's analytic account
37 ('partner_id', 'openupgrade_legacy_partner_id'), # > aaa.partner_id
38 ('state', 'openupgrade_legacy_state'), # > aaa.state (keys are equal)
39 ],
40 'project_task': [
41 ('date_close', 'date_end'), # simple change of name
42 ('type', 'type_id'), # name change
43 ('parent_id', 'openupgrade_legacy_parent_id'), # m2o -> m2m parent_ids
44 ],
45 'res_company': [
46 ('project_time_mode', 'openupgrade_legacy_project_time_mode'), # char selection -> m2o
47 ],
48 }
49
50@openupgrade.migrate()
51def migrate(cr, version):
52 openupgrade.rename_columns(cr, renamed_columns)
53 logger.warn(
54 "TODO: check whether project_task.date_deadline "
55 "preserves content when type changes from datetime to date")
056
=== added file 'project/migrations/6.0.1.1/user_notes.txt'
--- project/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
+++ project/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,2 @@
1This 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.
2The 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.
03
=== added file 'project_timesheet/migrations/6.0.1.0/post-migration.py'
--- project_timesheet/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
+++ project_timesheet/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,43 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24def set_timesheet_id(cr):
25 """
26 Migrate an integer field that represents a
27 stock.incoterms' id field to a proper many2one
28 (i.e. weed out obsolete ids)
29 """
30 cr.execute("""
31 UPDATE
32 project_task_work
33 SET
34 hr_analytic_timesheet_id = hr_analytic_timesheet.id
35 FROM
36 hr_analytic_timesheet
37 WHERE
38 openupgrade_legacy_hr_analytic_timesheet_id = hr_analytic_timesheet.id
39 """)
40
41@openupgrade.migrate()
42def migrate(cr, version):
43 set_timesheet_id(cr)
044
=== added file 'project_timesheet/migrations/6.0.1.0/pre-migration.py'
--- project_timesheet/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
+++ project_timesheet/migrations/6.0.1.0/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,34 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24column_renames = {
25 'project_task_work': [
26 ('hr_analytic_timesheet_id', 'openupgrade_legacy_hr_analytic_timesheet_id'),
27 ],
28 }
29
30
31@openupgrade.migrate()
32def migrate(cr, version):
33 openupgrade.rename_columns(cr, column_renames)
34
035
=== added file 'project_timesheet/migrations/6.0.1.0/user_notes.txt'
--- project_timesheet/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ project_timesheet/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1This upgrade migrates timesheet entries on task work to a proper database relation.
02
=== added file 'purchase/migrations/6.0.1.1/data.xml'
--- purchase/migrations/6.0.1.1/data.xml 1970-01-01 00:00:00 +0000
+++ purchase/migrations/6.0.1.1/data.xml 2012-06-07 17:48:26 +0000
@@ -0,0 +1,20 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3<data noupdate="1">
4
5 <record model="ir.rule" id="purchase_order_comp_rule">
6 <field name="name">Purchase Order multi-company</field>
7 <field name="model_id" ref="model_purchase_order"/>
8 <field name="global" eval="True"/>
9 <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
10 </record>
11
12 <record model="ir.rule" id="purchase_order_line_comp_rule">
13 <field name="name">Purchase Order Line multi-company</field>
14 <field name="model_id" ref="model_purchase_order_line"/>
15 <field name="global" eval="True"/>
16 <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
17 </record>
18
19</data>
20</openerp>
021
=== added file 'purchase/migrations/6.0.1.1/post-migration.py'
--- purchase/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ purchase/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,50 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25defaults_force = {
26 # False results in column value NULL
27 # None value triggers a call to the model's default function
28 'purchase.order': [
29 ('company_id', None),
30 ],
31 }
32
33def set_order_invoice_ids(cr, pool):
34 """
35 Migrate many2one to many2many
36 """
37 order_pool = pool.get('purchase.order')
38 cr.execute('SELECT id, openupgrade_legacy_invoice_id '
39 'FROM purchase_order '
40 'WHERE openupgrade_legacy_invoice_id IS NOT NULL')
41 for row in cr.fetchall():
42 order_pool.write(
43 cr, 1, row[0], {'invoice_ids': [(4, row[1])]})
44
45@openupgrade.migrate()
46def migrate(cr, version):
47 pool = pooler.get_pool(cr.dbname)
48 openupgrade.set_defaults(cr, pool, defaults_force, force=True)
49 set_order_invoice_ids(cr, pool)
50 openupgrade.load_xml(cr, 'purchase', 'migrations/6.0.1.1/data.xml')
051
=== added file 'purchase/migrations/6.0.1.1/pre-migration.py'
--- purchase/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
+++ purchase/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,47 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24logger = logging.getLogger('OpenUpgrade: purchase')
25
26column_renames = {
27 # this is a mapping per table from old column name
28 # to new column name
29 'purchase_order': [
30 ('invoice_id', 'openupgrade_legacy_invoice_id')
31 ],
32 }
33
34renamed_xmlids = [
35 ('mrp.act_buy', 'purchase.act_buy'),
36 ('mrp.trans_buy_make_done', 'purchase.trans_buy_make_done'),
37 ('mrp.trans_buy_cancel', 'purchase.trans_buy_cancel'),
38]
39
40@openupgrade.migrate()
41def migrate(cr, version):
42 openupgrade.rename_columns(cr, column_renames)
43 openupgrade.rename_xmlids(cr, renamed_xmlids)
44 logger.warn(
45 'TODO: check whether datetime field preserves '
46 'content when migrated to date field '
47 '(purchase_order.minimum_planned_date and po_line.date_planned)')
048
=== added file 'purchase/migrations/6.0.1.1/user_notes.txt'
--- purchase/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
+++ purchase/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,2 @@
1This upgrade allows multiple purchase orders to be related to multiple invoices instead of only one.
2
03
=== added file 'purchase_analytic_plans/migrations/6.0.1.0/user_notes.txt'
--- purchase_analytic_plans/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ purchase_analytic_plans/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module 'purchase_analytic_plans'
02
=== added file 'sale/migrations/6.0.1.0/post-migration.py'
--- sale/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
+++ sale/migrations/6.0.1.0/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,53 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25defaults_force = {
26 # False results in column value NULL
27 # None value triggers a call to the model's default function
28 'sale.shop': [('company_id', None)],
29 }
30
31
32def set_incoterm(cr):
33 """
34 Migrate selection field that represents a
35 stock.incoterms' code field to a proper many2one
36 """
37 cr.execute("""
38 UPDATE
39 sale_order
40 SET
41 incoterm = stock_incoterms.id
42 FROM
43 stock_incoterms
44 WHERE
45 openupgrade_legacy_incoterm IS NOT NULL
46 AND openupgrade_legacy_incoterm = stock_incoterms.code
47 """)
48
49@openupgrade.migrate()
50def migrate(cr, version):
51 pool = pooler.get_pool(cr.dbname)
52 openupgrade.set_defaults(cr, pool, defaults_force, force=True)
53 set_incoterm(cr)
054
=== added file 'sale/migrations/6.0.1.0/pre-migration.py'
--- sale/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
+++ sale/migrations/6.0.1.0/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,34 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24column_renames = {
25 'sale_order': [
26 ('incoterm', 'openupgrade_legacy_incoterm'),
27 ],
28 }
29
30
31@openupgrade.migrate()
32def migrate(cr, version):
33 openupgrade.rename_columns(cr, column_renames)
34
035
=== added file 'sale/migrations/6.0.1.0/user_notes.txt'
--- sale/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ sale/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1This upgrade stores a sale order's incoterm as a proper database relation. It also reloads the modified access permissions and security rules.
02
=== added file 'sale_analytic_plans/migrations/6.0.1.0/user_notes.txt'
--- sale_analytic_plans/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ sale_analytic_plans/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module 'sale_analytic_plans'
02
=== added file 'sale_journal/migrations/6.0.1.0/user_notes.txt'
--- sale_journal/migrations/6.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ sale_journal/migrations/6.0.1.0/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1Nothing to do for module 'sale_journal'
02
=== added file 'stock/migrations/6.0.1.1/data.xml'
--- stock/migrations/6.0.1.1/data.xml 1970-01-01 00:00:00 +0000
+++ stock/migrations/6.0.1.1/data.xml 2012-06-07 17:48:26 +0000
@@ -0,0 +1,62 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="1">
4 <!-- Add a standard scrap location -->
5 <record id="stock_location_scrapped" model="stock.location">
6 <field name="name">Scrapped</field>
7 <field name="location_id" ref="stock_location_locations_virtual"/>
8 <field name="scrap_location">True</field>
9 <field name="usage">inventory</field>
10 <field name="company_id"></field>
11 </record>
12 <!-- The new stock journal -->
13 <record id="journal_delivery" model="stock.journal">
14 <field name="name">Delivery Orders</field>
15 </record>
16 <!-- update the output location with the new fields -->
17 <record id="stock_location_output" model="stock.location">
18 <field name="chained_auto_packing">transparent</field>
19 <field name="chained_picking_type">out</field>
20 <field name="chained_journal_id" ref="journal_delivery"/>
21 </record>
22 <!-- new sequences -->
23 <!-- We copied the old single sequence and sequence type
24 to these 'in' resources, but we still want to update the
25 name and code -->
26 <record id="seq_type_picking_in" model="ir.sequence.type">
27 <field name="name">Picking IN</field>
28 <field name="code">stock.picking.in</field>
29 </record>
30
31 <record id="seq_type_picking_out" model="ir.sequence.type">
32 <field name="name">Picking OUT</field>
33 <field name="code">stock.picking.out</field>
34 </record>
35
36 <record id="seq_type_picking_internal" model="ir.sequence.type">
37 <field name="name">Picking INT</field>
38 <field name="code">stock.picking.internal</field>
39 </record>
40
41 <record id="seq_picking_in" model="ir.sequence">
42 <field name="name">Picking IN</field>
43 <field name="code">stock.picking.in</field>
44 <field name="prefix">IN/</field>
45 <field name="padding">5</field>
46 </record>
47
48 <record id="seq_picking_out" model="ir.sequence">
49 <field name="name">Picking OUT</field>
50 <field name="code">stock.picking.out</field>
51 <field name="prefix">OUT/</field>
52 <field name="padding">5</field>
53 </record>
54
55 <record id="seq_picking_internal" model="ir.sequence">
56 <field name="name">Picking INT</field>
57 <field name="code">stock.picking.internal</field>
58 <field name="prefix">INT/</field>
59 <field name="padding">5</field>
60 </record>
61 </data>
62</openerp>
063
=== added file 'stock/migrations/6.0.1.1/post-migration.py'
--- stock/migrations/6.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ stock/migrations/6.0.1.1/post-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,84 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler
23from openupgrade import openupgrade
24
25defaults_force = {
26 'stock.inventory': [('company_id', None)],
27 'stock.location': [('company_id', None)],
28 'stock.move': [('company_id', None)],
29 'stock.picking': [('company_id', None)],
30 'stock.production.lot': [('company_id', None)],
31 'stock.warehouse': [('company_id', None)],
32 }
33
34def update_picking_type(cr):
35 """
36 Picking type 'out' is now applied instead
37 of type 'delivery'
38 """
39 openupgrade.logged_query(
40 cr,
41 """
42 UPDATE stock_picking
43 SET type = 'out'
44 WHERE type = 'delivery'
45 """)
46
47def set_valuation_accounts(cr):
48 """
49 The obsolete account_id field is now split up
50 in an incoming and outoing account
51 """
52 if openupgrade.column_exists(
53 cr, 'stock_location', 'openupgrade_legacy_account_id'):
54 openupgrade.logged_query(
55 cr,
56 """
57 UPDATE stock_location
58 SET valuation_in_account_id = openupgrade_legacy_account_id,
59 valuation_out_account_id = openupgrade_legacy_account_id
60 """)
61
62def set_move_date(cr):
63 """ Move date records the date expected
64 or picking date when done. The latter is not available
65 at upgrade time, so we set it to date expected
66 Note that 'date' field is the old date of creation,
67 which is now replaced by displaying the history field
68 'create_date' (which assumingly already contains
69 appropriate values)
70 """
71 openupgrade.logged_query(
72 cr, """
73 UPDATE stock_move
74 SET date = date_expected
75 """)
76
77@openupgrade.migrate()
78def migrate(cr, version):
79 pool = pooler.get_pool(cr.dbname)
80 openupgrade.set_defaults(cr, pool, defaults)
81 openupgrade.set_defaults(cr, pool, defaults_force, force=True)
82 set_valuation_accounts(cr)
83 set_move_date(cr)
84 update_picking_type(cr)
085
=== added file 'stock/migrations/6.0.1.1/pre-migration.py'
--- stock/migrations/6.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
+++ stock/migrations/6.0.1.1/pre-migration.py 2012-06-07 17:48:26 +0000
@@ -0,0 +1,42 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24renamed_columns = {
25 'stock_move': [
26 ('date_planned', 'date_expected'),
27 ],
28 'stock_location': [
29 ('account_id', 'openupgrade_legacy_account_id'),
30 ],
31 }
32
33renamed_xmlids = [
34 ('stock.seq_type_picking', 'stock.seq_type_picking_in'),
35 ('stock.seq_picking', 'stock.seq_picking_in'),
36 ]
37
38@openupgrade.migrate()
39def migrate(cr, version):
40 openupgrade.rename_columns(cr, renamed_columns)
41 openupgrade.rename_xmlids(cr, renamed_xmlids)
42
043
=== added file 'stock/migrations/6.0.1.1/user_notes.txt'
--- stock/migrations/6.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000
+++ stock/migrations/6.0.1.1/user_notes.txt 2012-06-07 17:48:26 +0000
@@ -0,0 +1,1 @@
1This 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