← Back to team overview

credativ team mailing list archive

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

 

Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/openupgrade-addons/6.0-hr-project-stock into lp:openupgrade-addons/6.0.

Requested reviews:
  OpenUpgrade Committers (openupgrade-committers)

For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-addons/6.0-hr-project-stock/+merge/109195

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
-- 
https://code.launchpad.net/~therp-nl/openupgrade-addons/6.0-hr-project-stock/+merge/109195
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-addons/6.0-hr-project-stock into lp:openupgrade-addons/6.0.
=== 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 @@
 # -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
 
-from osv import osv
-import pooler, logging
-log = logging.getLogger('migrate')
+import pooler
 from openupgrade import openupgrade
 
-MODULE='account'
-
 defaults = {
     # False results in column value NULL
     # None value triggers a call to the model's default function 
@@ -27,12 +42,8 @@
         ],    
     }
 
+@openupgrade.migrate()
 def migrate(cr, version):
-    try:
-        log.info("post-set-defaults.py now called")
-        pool = pooler.get_pool(cr.dbname)
-        openupgrade.set_defaults(cr, pool, defaults)
-        openupgrade.load_xml(cr, MODULE, 'migrations/6.0.1.1/data.xml')
-    except Exception, e:
-        log.error("Migration: error in post.py: %s" % e)
-        raise
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults)
+    openupgrade.load_xml(cr, 'account', 'migrations/6.0.1.1/data.xml')

=== 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 @@
 # -*- coding: utf-8 -*-
-import logging
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from tools import sql
 from openupgrade import openupgrade
 
-logger = logging.getLogger('migrate')
-
 column_renames = {
     # this is a mapping per table from old column name
     # to new column name
@@ -20,11 +38,11 @@
     cr.execute("UPDATE account_journal SET type = 'sale_refund' " +
                "where type = 'sale' and refund_journal = TRUE")
 
+@openupgrade.migrate()
 def migrate(cr, version):
-    try:
-        openupgrade.rename_columns(cr, column_renames)
-        mgr_refund_journal_type(cr)
-    except Exception, e:
-        log.error("Migration: error in pre.py: %s" % e)
-        raise
+    openupgrade.rename_columns(cr, column_renames)
+    # This view, previously in report_account module
+    # changes data type of one of the columns
+    sql.drop_view_if_exists(cr, 'report_invoice_created')
+    mgr_refund_journal_type(cr)
 

=== 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 @@
+Nothing to do for module 'account_analytic_analysis'

=== 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 @@
+Nothing to do for module 'account_analytic_default'

=== 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 @@
+Nothing to do for module 'account_analytic_plans'

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+MODULE='account_budget'
+
+defaults_force = {
+    # False results in column value NULL
+    # None value triggers a call to the model's default function 
+    'account.budget.post': [
+        ('company_id', None),
+        ],    
+    'crossovered.budget': [
+        ('company_id', None),
+        ],    
+    }
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults_force, force=True)

=== 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 @@
+This upgrade allows budgets to be reset from state 'Cancel' to state 'Draft'.
+Budgets are by default now managed by accountants.

=== 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data noupdate="1">
+
+    <record id="payment_mode_comp_rule" model="ir.rule">
+        <field name="name">Payment Mode company rule</field>
+        <field model="ir.model" name="model_id" ref="model_payment_mode"/>
+        <field eval="True" name="global"/>
+        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
+    </record>
+
+</data>
+</openerp>

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+defaults_force = {
+    # False results in column value NULL
+    # None value triggers a call to the model's default function 
+    'payment.mode': [
+        ('company_id', None),
+        ],    
+    }
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults_force, force=True)
+    openupgrade.load_data(cr, 'account_payment', 'migrations/6.0.1.1/data.xml')

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+column_renames = {
+    # this is a mapping per table from old column name
+    # to new column name
+    'payment_order': [
+        ('date_planned', 'date_scheduled'),
+        ],
+    }
+
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, column_renames)

=== 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 @@
+This upgrade performs a small amount of adaptations to the database structure related to module account_payment.
+
+

=== 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 @@
+Nothing to do for module 'analytic_user_function'

=== 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 @@
+Nothing to do for module 'audittrail'

=== 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 @@
+Nothing to do for module base_iban

=== 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 @@
+Nothing to do for module base_report_creator

=== 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 @@
+Nothing to do for module 'base_report_creator'
+
+

=== 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 @@
+Nothing to do for module board

=== 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data noupdate="1">
+
+        <!-- Employee Marital Statusses, introduced in OpenERP 6 -->
+        <record id="hr_employee_marital_status_single" model="hr.employee.marital.status">
+            <field name="name">Single</field>
+        </record>
+        <record id="hr_employee_marital_status_married" model="hr.employee.marital.status">
+            <field name="name">Married</field>
+        </record>
+        <record id="hr_employee_marital_status_divorced" model="hr.employee.marital.status">
+            <field name="name">Divorced</field>
+        </record>
+        <record id="hr_employee_marital_status_widower" model="hr.employee.marital.status">
+            <field name="name">Widower</field>
+        </record>
+
+    </data>
+</openerp>

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler, logging
+from openupgrade import openupgrade
+
+logger = logging.getLogger('OpenUpgrade: hr')
+
+defaults = {
+    # False results in column value NULL
+    # None value triggers a call to the model's default function 
+    #'account.fiscalyear': [
+    #    ('company_id', None),
+    #    ],    
+    }
+
+def create_employee_resources(cr, pool):
+    employee_pool = pool.get('hr.employee')
+    resource_pool = pool.get('resource.resource')
+    cr.execute("""
+SELECT 
+    id,
+    openupgrade_legacy_user_id,
+    openupgrade_legacy_company_id,
+    openupgrade_legacy_name,
+    openupgrade_legacy_active
+FROM hr_employee
+WHERE resource_id is NULL
+""")
+    for row in cr.fetchall():
+        resource_id = resource_pool.create(
+            cr, 1, 
+            {'user_id': row[1],
+             'company_id': row[2],
+             'name': row[3],
+             'active': row[4],
+             })
+        employee_pool.write(
+            cr, 1, row[0], {'resource_id': resource_id})
+    
+def get_user_employee(cr, pool, user_id):
+    if not user_id:
+        return False
+    employee_pool = pool.get('hr.employee')
+    employee_ids = employee_pool.search(
+        cr, 1, [('user_id', '=', user_id)])
+    if employee_ids:
+        if len(employee_ids) > 1:
+            logger.info(
+                'user %d is associated with multiple active '
+                'employees. Need to select one for department membership or '
+                'manager' %  user_id)
+        return employee_ids[0]
+    return False
+
+def set_department_manager(cr, pool):
+    """
+    Migrate department managment by user
+    by management by employee.
+    """
+    department_pool = pool.get('hr.department')
+    cr.execute( 'SELECT id, openupgrade_legacy_manager_user_id from hr_department')
+    for row in cr.fetchall():
+        employee_id = get_user_employee(
+            cr, pool, row[1])
+        if employee_id:
+            department_pool.write(
+                cr, 1, row[0], {'manager_id': employee_id})
+
+def set_user_department(cr, pool):
+    """
+    Migrate department membership by user
+    to membership by employee. 
+    In OpenERP 6, an employee can only be in a single
+    department.
+    """
+    employee_pool = pool.get('hr.employee')
+    cr.execute("""
+SELECT
+    user_id,
+    department_id,
+    hr_department.manager_id
+FROM
+    openupgrade_legacy_hr_department_user_rel,
+    hr_department
+WHERE
+    openupgrade_legacy_hr_department_user_rel.department_id = hr_department.id
+""")
+    for row in cr.fetchall():
+        employee_id = get_user_employee(cr, pool, row[0])
+        if employee_id:
+            if employee_id == row[2]:
+                logger.info(
+                    'OpenERP does not allow employee with id %s as a '
+                    'member of the department that it is the manager of. '
+                    % employee_id)
+            else:
+                employee_pool.write(
+                    cr, 1, employee_id, {'department_id': row[1]})
+
+def set_marital(cr, pool):
+    """
+    Migrate selection field 'marital' to
+    a many2one field of model hr.employee.marital.status
+    """
+    marital_pool = pool.get('hr.employee.marital.status')
+    employee_pool = pool.get('hr.employee')
+    def get_or_create(marital):
+        marital = {
+            'maried': 'Married',
+            'unmaried': 'Single',
+            'divorced': 'Divorced',
+            'other': 'Other'
+            }.get(marital, marital)
+        ids = marital_pool.search(
+            cr, 1, [('name', '=', marital)])
+        if ids:
+            return ids[0]
+        return marital_pool.create(
+            cr, 1, {'name': marital})
+    # marital might already be filled by the renaming of
+    # hr_contract's marital_status
+    cr.execute('SELECT id, openupgrade_legacy_marital '
+               'FROM hr_employee WHERE marital IS NULL '
+               'AND openupgrade_legacy_marital IS NOT NULL')
+    for row in cr.fetchall():
+        employee_pool.write(
+            cr, 1, row[0], {'marital': get_or_create(row[1])})
+
+def set_department_manager(cr, pool):
+    """
+    Migrate department managment by user
+    by management by employee.
+    """
+    department_pool = pool.get('hr.department')
+    cr.execute( 'SELECT id, openupgrade_legacy_manager_user_id from hr_department')
+    for row in cr.fetchall():
+        employee_id = get_user_employee(
+            cr, pool, row[1])
+        if employee_id:
+            department_pool.write(
+                cr, 1, row[0], {'manager_id': employee_id})
+
+def set_category_ids(cr, pool):
+    """
+    Migrate the many2one category_id field
+    to many2many category_ids
+    """
+    employee_pool = pool.get('hr.employee')
+    cr.execute('SELECT id, openupgrade_legacy_category_id '
+               'FROM hr_employee '
+               'WHERE openupgrade_legacy_category_id IS NOT NULL')
+    for row in cr.fetchall():
+        employee_pool.write(
+            cr, 1, row[0], {'category_ids': [(4, row[1])]})
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults)
+    create_employee_resources(cr, pool)
+    set_department_manager(cr, pool)
+    set_user_department(cr, pool)
+    set_category_ids(cr, pool)
+    # The following definitions were moved from hr_contract.
+    # In case this module was installed, the reloading of the data
+    # will only overwrite the name if it was altered
+    openupgrade.load_xml(cr, 'hr', 'migrations/6.0.1.1/data.xml')
+    set_marital(cr, pool)

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+column_renames = {
+    # this is a mapping per table from old column name
+    # to new column name
+    'hr_department': [
+        ('manager_id', 'openupgrade_legacy_manager_user_id'),
+        ],
+    'hr_employee': [
+        ('user_id', 'openupgrade_legacy_user_id'),
+        ('name', 'openupgrade_legacy_name'),
+        ('active', 'openupgrade_legacy_active'),
+        ('company_id', 'openupgrade_legacy_company_id'),
+        ('category_id', 'openupgrade_legacy_category_id'),
+        ('marital', 'openupgrade_legacy_marital'),
+        ('parent_id', 'openupgrade_legacy_parent_id'),
+        ]
+    }
+
+renamed_xmlids = [
+    ('hr.group_hr_user', 'base.group_hr_user'),
+    ('hr.group_hr_manager', 'base.group_hr_manager'),
+    ('hr_contract.hr_employee_marital_status_divorced',
+     'hr.hr_employee_marital_status_divorced'),
+    ('hr_contract.hr_employee_marital_status_married',
+     'hr.hr_employee_marital_status_married'),
+    ('hr_contract.hr_employee_marital_status_single',
+     'hr.hr_employee_marital_status_single'),
+    ('hr_contract.hr_employee_marital_status_widower',
+     'hr.hr_employee_marital_status_widower'),
+]     
+   
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, column_renames)
+    # marital status as provided by hr_contract if installed
+    if openupgrade.column_exists(
+        cr, 'hr_employee', 'marital_status'):
+        openupgrade.rename_columns(
+            cr, { 'hr_employee': [('marital_status', 'marital')]})
+    openupgrade.rename_tables(
+        cr, 
+        [('hr_department_user_rel',
+          'openupgrade_legacy_hr_department_user_rel')])
+    openupgrade.rename_xmlids(cr, renamed_xmlids)
+

=== 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 @@
+This upgrade consists of the following changes:
+- Marital status is now a choice from a lookup table
+  previously provided by the hr contract module
+- An employee can now have multiple categories
+- The employee model is integrated with the resource model
+- Departments now have employees as their member type, not system users

=== 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 @@
+Nothing to do for module 'hr_attendance'

=== 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data noupdate="1">
+        
+        <!-- Contract Types -->               
+        <record id="hr_contract_type_emp" model="hr.contract.type">
+            <field name="name">Employee</field>
+        </record> 
+                 
+        <record id="hr_contract_type_wrkr" model="hr.contract.type">
+            <field name="name">Worker</field>
+        </record> 
+         
+        <record id="hr_contract_type_sub" model="hr.contract.type">
+            <field name="name">Subcontractor</field>
+        </record>                        
+        
+    </data>
+</openerp>

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler, logging
+from openupgrade import openupgrade
+
+logger = logging.getLogger('migrate')
+MODULE = 'hr_contract'
+
+def set_contract_job_id(cr, pool):
+    """
+    Migrate function_id (res.partner.function) field on hr.contract
+    to job_id (hr.job).
+    Create jobs if necessary, taking company_id into account.
+    """
+    job_pool = pool.get('hr.job')
+    contract_pool = pool.get('hr.contract')
+    def get_or_create(name, company_id):
+        ids = job_pool.search(
+            cr, 1, [('name', '=', name),
+                    ('company_id', '=', company_id)])
+        if ids:
+            return ids[0]
+        return job_pool.create(
+            cr, 1, {'name': name,
+                    'company_id': company_id})
+    # marital might already be filled by the renaming of
+    # hr_contract's marital_status
+    cr.execute(
+        'SELECT '
+        '    hr_contract.id, '
+        '    openupgrade_legacy_res_partner_function.name, '
+        '    resource_resource.company_id '
+        'FROM '
+        '    hr_contract, '
+        '    hr_employee, '
+        '    resource_resource, '
+        '    openupgrade_legacy_res_partner_function '
+        'WHERE '
+        '    hr_employee.resource_id = resource_resource.id '
+        '    AND hr_contract.job_id IS NULL '
+        '    AND hr_contract.employee_id = hr_employee.id '
+        '    AND openupgrade_legacy_function = openupgrade_legacy_res_partner_function.id')
+    for row in cr.fetchall():
+        contract_pool.write(
+            cr, 1, row[0], 
+            {'job_id': get_or_create(row[1], row[2] or False)})
+
+
+def set_contract_default_type_id(cr, pool):
+    default_type_ref = pool.get('ir.model.data').get_object_reference(
+        cr, 1, 'hr_contract', 'hr_contract_type_emp')
+    if default_type_ref:
+        openupgrade.set_defaults(
+            cr, pool, 
+            {'hr.contract': [('type_id', default_type_ref[1])]})
+    else:
+        logger.warn('%s: Default contact type not found' % MODULE)
+        
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.load_data(cr, MODULE, 'migrations/6.0.1.0/data.xml')
+    set_contract_job_id(cr, pool)
+    set_contract_default_type_id(cr, pool)

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+column_renames = {
+    # this is a mapping per table from old column name
+    # to new column name
+    'hr_contract': [
+        ('function', 'openupgrade_legacy_function'),
+        ],
+    }
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, column_renames)
+

=== 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 @@
+This upgrade migrates functions on contracts to 'jobs' from the hr module.
+It also adds contract types such as 'Employee' or 'Subcontractor'
+

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+defaults_force = {
+    'hr.expense.expense': [
+        ('company_id', None)
+        ]
+    }
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults_force, force=True)

=== 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 @@
+This upgrade adds security rules for access to expenses.

=== 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 @@
+This upgrade adds a dedicated timesheet journal

=== 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 @@
+This upgrade adds default entries to the invoice factor table.

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+defaults_force = {
+    'hr_timesheet_sheet.sheet':
+        [('company_id', None)],
+    }
+   
+def set_timesheet_employee(cr, pool):
+    """
+    Migrate timesheet owner by user to employee. 
+    """
+    sheet_pool = pool.get('hr_timesheet_sheet.sheet')
+    cr.execute("""
+        SELECT
+            hr_timesheet_sheet_sheet.id,
+            hr_employee.id
+        FROM
+            hr_timesheet_sheet_sheet,
+            hr_employee
+        WHERE
+            hr_timesheet_sheet_sheet.employee_id IS NULL
+            AND hr_timesheet_sheet_sheet.openupgrade_legacy_user_id IS NOT NULL
+            AND hr_employee.openupgrade_legacy_user_id = hr_timesheet_sheet_sheet.openupgrade_legacy_user_id
+        """)
+    for row in cr.fetchall():
+        sheet_pool.write(
+            cr, 1, [row[0]], {'employee_id': row[1]})
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults_force, force=True)
+    set_timesheet_employee(cr, pool)

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+column_renames = {
+    # this is a mapping per table from old column name
+    # to new column name
+    'hr_timesheet_sheet_sheet': [
+        ('user_id', 'openupgrade_legacy_user_id'),
+        ],
+    }
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, column_renames)

=== 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 @@
+Timesheets are now related to employees, not to users. Existing timesheets will be migrated, if an employee exists for the user.

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+defaults_force = {
+    'mrp.bom': [('company_id', None)],
+    'mrp.production': [('company_id', None)],
+    'mrp.routing': [('company_id', None)],
+    'mrp.workcenter': [('company_id', None)],
+}
+
+def create_workcenter_resources(cr, pool):
+    # note: set default value for company_id 
+    # on the workcenter 
+    # after running this function
+    workcenter_pool = pool.get('mrp.workcenter')
+    resource_pool = pool.get('resource.resource')
+    cr.execute("""
+SELECT
+    id,
+    openupgrade_legacy_code,
+    openupgrade_legacy_name,
+    openupgrade_legacy_active
+FROM
+    mrp_workcenter
+WHERE
+    resource_id is NULL""")
+
+    for row in cr.fetchall():
+        resource_id = resource_pool.create(
+            cr, 1, 
+            {
+             'code': row[1],
+             'name': row[2],
+             'active': row[3],
+             'resource_type': 'material',
+             })
+        workcenter_pool.write(
+            cr, 1, row[0], {'resource_id': resource_id})
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    create_workcenter_resources(cr, pool)

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+column_renames = {
+    'mrp_production': [
+        ('date_finnished', 'date_finished'),
+        ],
+    'mrp_workcenter': [
+        ('code', 'openupgrade_legacy_code'),
+        ('name', 'openupgrade_legacy_name'),
+        ('active', 'openupgrade_legacy_active'),
+        ]        
+    }
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, column_renames)
+

=== 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 @@
+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.

=== 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 @@
+Nothing to do for module 'process'

=== 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data noupdate="1">
+        <!-- The following changes may already be loaded upon
+	the auto-installation of the procurement module when
+	a v5 database with mrp installed is being upgraded
+	to v6 -->
+
+        <!-- OpenERP 6 changes the code of these resources -->
+        <record id="sequence_mrp_op_type" model="ir.sequence.type">
+	    <field name="code">stock.orderpoint</field>
+        </record>
+        <record id="sequence_mrp_op" model="ir.sequence.type">
+	    <field name="code">stock.orderpoint</field>
+        </record>
+	<!-- change the model of the scheduled task -->
+        <record id="ir_cron_scheduler_action" model="ir.cron">
+            <field eval="'procurement.order'" name="model"/>
+        </record>
+    </data>
+</openerp>
+        

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+defaults_force = {
+    'procurement.order': [('company_id', None)],
+    'stock.warehouse.orderpoint': [('company_id', None)],
+}
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults_force, force=True)
+    openupgrade.load_data(cr, MODULE, 'migrations/6.0.1.0/data.xml')

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import logging
+from openupgrade import openupgrade
+
+logger = logging.getLogger('OpenUpgrade: procurement')
+
+renamed_xmlids = [
+    ('mrp.wkf', 'procurement.wkf_procurement'),
+    ('mrp.act_draft', 'procurement.act_draft'),
+    ('mrp.act_cancel', 'procurement.act_cancel'),
+    ('mrp.act_confirm', 'procurement.act_confirm'),
+    ('mrp.act_confirm_wait', 'procurement.act_confirm_wait'),
+    ('mrp.act_confirm_mts', 'procurement.act_confirm_mts'),
+    ('mrp.act_confirm_mto', 'procurement.act_confirm_mto'),
+    ('mrp.act_make_to_stock', 'procurement.act_make_to_stock'),
+    ('mrp.act_produce_check', 'procurement.act_produce_check'),
+    ('mrp.act_produce_service', 'procurement.act_produce_service'),
+    ('mrp.act_make_done', 'procurement.act_make_done'),
+    ('mrp.act_wait_done', 'procurement.act_wait_done'),
+    ('mrp.act_done', 'procurement.act_done'),
+    ('mrp.trans_draft_confirm', 'procurement.trans_draft_confirm'),
+    ('mrp.trans_confirm_cancel2', 'procurement.trans_confirm_cancel2'),
+    ('mrp.trans_confirm_wait_done', 'procurement.trans_confirm_wait_done'),
+    ('mrp.trans_confirm_cancel', 'procurement.trans_confirm_cancel'),
+    ('mrp.trans_confirm_confirm_wait', 'procurement.trans_confirm_confirm_wait'),
+    ('mrp.trans_confirm_wait_confirm_mto', 'procurement.trans_confirm_wait_confirm_mto'),
+    ('mrp.trans_confirm_wait_confirm_mts', 'procurement.trans_confirm_wait_confirm_mts'),
+    ('mrp.trans_confirm_mts_cancel', 'procurement.trans_confirm_mts_cancel'),
+    ('mrp.trans_confirm_waiting_cancel', 'procurement.trans_confirm_waiting_cancel'), 
+    ('mrp.trans_confirm_mts_confirm', 'procurement.trans_confirm_mts_confirm'),
+    ('mrp.trans_confirm_mto_cancel', 'procurement.trans_confirm_mto_cancel'),
+    ('mrp.trans_confirm_mto_confirm', 'procurement.trans_confirm_mto_confirm'),
+    ('mrp.trans_draft_cancel', 'procurement.trans_draft_cancel'),
+    ('mrp.trans_confirm_mts_make_to_stock', 'procurement.trans_confirm_mts_make_to_stock'),
+    ('mrp.trans_confirm_mto_produce_check', 'procurement.trans_confirm_mto_produce_check'),
+    ('mrp.trans_product_check_produce_service', 'procurement.trans_product_check_produce_service'),
+    ('mrp.trans_confirm_mto_buy', 'procurement.trans_confirm_mto_purchase'),
+    ('mrp.trans_make_to_stock_make_done', 'procurement.trans_make_to_stock_make_done'),
+    ('mrp.trans_produce_service_cancel', 'procurement.trans_produce_service_cancel'),
+    ('mrp.trans_produce_service_make_done', 'procurement.trans_produce_service_make_done'),
+    ('mrp.trans_make_done_done', 'procurement.trans_make_done_done'),
+    ('mrp.trans_make_done_confirm', 'procurement.trans_make_done_confirm'),
+    ('mrp.sequence_mrp_op_type', 'procurement.sequence_mrp_op_type'),
+    ('mrp.sequence_mrp_op', 'procurement.sequence_mrp_op'),
+    ('mrp.ir_cron_scheduler_action', 'procurement.ir_cron_scheduler_action'),
+]     
+   
+# Cannot use the OpenUpgrade decorator
+# as in this case, do not return immediately when 
+# version is False. We need to facilitate the
+# functionality move from the mrp module
+
+def migrate(cr, version):
+    logger.info("pre-migration.py called with version %s" % version)
+    try:
+        if openupgrade.table_exists(cr, 'mrp_procurement'):
+            logger.info("moving functionality from the OpenERP 5 MRP module")
+            openupgrade.rename_tables(cr, [('mrp_procurement', 'procurement_order')])
+            openupgrade.rename_models(cr, [('mrp.procurement', 'procurement.order')]) 
+            openupgrade.rename_xmlids(cr, renamed_xmlids)
+    except Exception, e:
+        logger.error("error in pre-migration.py: %s" % e)
+        raise
+

=== 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 @@
+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.

=== 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data noupdate="1">
+	<!-- OpenUpgrade: add new product and UOM categories -->
+        <record id="cat0" model="product.category">
+            <field name="name">All products</field>
+        </record>
+        <record id="uom_categ_wtime" model="product.uom.categ">
+            <field name="name">Working Time</field>
+        </record>
+        <record id="uom_categ_length" model="product.uom.categ">
+            <field name="name">Length / Distance</field>
+        </record>
+	<!-- OpenUpgrade: add factor and/or rounding properties -->
+        <record id="product_uom_unit" model="product.uom">
+            <field name="factor" eval="1.0"/>
+            <field name="rounding" eval="1.0"/>
+        </record>
+        <record id="product_uom_kgm" model="product.uom">
+            <field name="factor" eval="1"/>
+        </record>
+	<!-- OpenUpgrade: add new UOMs -->
+        <record id="product_uom_gram" model="product.uom">
+            <field name="category_id" ref="product_uom_categ_kgm"/>
+            <field name="name">g</field>
+            <field name="factor" eval="1000"/>
+            <field name="uom_type">smaller</field>
+        </record>
+        <record id="uom_hour" model="product.uom">
+            <field name="name">Hour</field>
+            <field eval="uom_categ_wtime" name="category_id"/>
+            <field name="factor" eval="8.0"/>
+            <field name="uom_type">smaller</field>
+        </record>
+        <record id="uom_day" model="product.uom">
+            <field name="name">Day</field>
+            <field eval="uom_categ_wtime" name="category_id"/>
+            <field name="factor" eval="1.0"/>
+        </record>
+        <record id="product_uom_ton" model="product.uom">
+            <field name="category_id" ref="product_uom_categ_kgm"/>
+            <!-- 'tonne' is the most common spelling in english-speaking countries,
+                 the alternative is 'metric ton' in the US, abbreviated as 'mt' -->
+            <field name="name">tonne</field>
+            <field name="factor" eval="0.001"/>
+            <field name="uom_type">bigger</field>
+        </record>
+        <record id="product_uom_meter" model="product.uom">
+            <field name="category_id" ref="uom_categ_length"/>
+            <field name="name">m</field>
+            <field name="factor" eval="1.0"/>
+        </record>
+        <record id="product_uom_km" model="product.uom">
+            <field name="category_id" ref="uom_categ_length"/>
+            <field name="name">km</field>
+            <field name="factor" eval="0.001"/>
+            <field name="uom_type">bigger</field>
+        </record>
+        <record id="product_uom_cm" model="product.uom">
+            <field name="category_id" ref="uom_categ_length"/>
+            <field name="name">cm</field>
+            <field name="factor" eval="100"/>
+            <field name="uom_type">smaller</field>
+        </record>
+    </data>
+</openerp>

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+defaults_force = {
+    'product.category': [('type', 'normal')],
+    #'product.pricelist': [('company_id', None)], # no default function present
+    'product.supplierinfo': [('company_id', None)],
+}
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults_force, force=True)
+    openupgrade.load_data(cr, 'product', 'migrations/6.0.1.1/data.xml')

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+logger = logging.getLogger('OpenUpgrade: product')
+
+renamed_columns = {
+    'product_supplierinfo': [
+        ('qty', 'min_qty')]
+    }
+
+def update_packaging_type(cr):
+    """ A spelling error has been fixed
+    in the selection list """
+    cr.execute("""
+        UPDATE product_ul
+        SET type = %s
+        WHERE type = %s""", ('pallet', 'palet'))
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, renamed_columns)
+    update_packaging_type(cr)
+    logger.warn(
+        "TODO: check whether product_packaging.name "
+        "preserves content when migrating from type char "
+        "to type text")

=== 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 @@
+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.
+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.
+Modified access permissions and security rules are reloaded.
+
+ 

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+defaults = {
+    'project.project': [('sequence', 10)],
+    'project.task.type': [('sequence', 1)],
+    }
+
+defaults_force = {
+    'project.task': [('company_id', None)],
+    }
+
+def migrate_analytic(cr, pool):
+    """
+    Transfer obsolete values from projects to their analytic accounts.
+    Create analytic account if necessary. Take care not to overwrite 
+    existing values on analytic accounts
+    """
+    project_pool = pool.get('project.project')
+    analytic_pool = pool.get('account.analytic.account')
+    project_ids = project_pool.search(
+        cr, 1, 
+        [('analytic_account_id', '!=', False)],
+        context={'active_test': False})
+    analytics = dict([(x.id, x.analytic_account_id) for x in project_pool.browse(
+        cr, 1, project_ids)])
+    cr.execute("""
+        SELECT
+            id,
+            analytic_account_id,
+            openupgrade_legacy_contact_id,
+            openupgrade_legacy_date_start,
+            openupgrade_legacy_date_end,
+            openupgrade_legacy_manager,
+            openupgrade_legacy_name,
+            openupgrade_legacy_notes,
+            openupgrade_legacy_partner_id,
+            openupgrade_legacy_state
+        FROM
+            project_project
+        """)
+    for row in cr.fetchall():
+        if not row[1]:
+            analytic_id = analytic_pool.create(
+                cr, 1, 
+                { 'contact_id': row[2] or False,
+                  'date_start': row[3] or False,
+                  'date': row[4] or False,
+                  'user_id' : row[5] or False,
+                  'name': row[6] or False,
+                  'description': row[7] or False,
+                  'partner_id': row[8] or False,
+                  'state': row[9] or False,
+                  })
+            project_pool.write(
+                cr, 1, row[0],
+                {'analytic_account_id': analytic_id})
+        else:
+            vals = {}
+            for num, field in [
+                (2, 'contact_id'),
+                (3, 'date_start'),
+                (4, 'date'),
+                (5, 'user_id'),
+                (6, 'name'),
+                (7, 'description'),
+                (8, 'partner_id'),
+                (9, 'state')]:
+                if row[num] and not analytics[row[0]][field]:
+                    vals[field] = row[num]
+            analytic_pool.write(
+                cr, 1, row[1], vals)
+
+    # second pass: transfer project hierarchy
+    # to analytic hierarchy
+    cr.execute("""
+        SELECT
+            child.analytic_account_id,
+            parent.analytic_account_id
+        FROM
+            project_project as child,
+            project_project as parent,
+            account_analytic_account as a
+        WHERE 
+            child.openupgrade_legacy_parent_id = parent.id
+            AND child.analytic_account_id = a.id
+            AND a.parent_id IS NULL
+        """)
+    for row in cr.fetchall():
+        analytic_pool.write(
+            cr, 1, row[0],
+            {'parent_id': row[1]})
+
+def migrate_task_parent_ids(cr, pool):
+    task_pool = pool.get('project.task')
+    cr.execute("""
+        SELECT
+            id,
+            openupgrade_legacy_parent_id
+        FROM
+            project_task
+        WHERE
+            openupgrade_legacy_parent_id IS NOT NULL
+        """)
+    for row in cr.fetchall():
+        task_pool.write(
+            cr, 1, row[0],
+            {'parent_ids': [(4, row[1])]})
+
+def migrate_company_time_mode(cr, pool):
+    """
+    Migrate a char selection to a many2one
+    of model product.uom
+    No standard resources available
+    for less likely options 'week' and 'month'.
+    Mention this in the user notes
+    """
+    data_pool = pool.get('ir.model.data')
+    company_pool = pool.get('res.company')
+    uom_map = {
+        'day': data_pool.get_object_reference(
+            cr, 1, 'product', 'uom_day')[1],
+        'hours': data_pool.get_object_reference(
+            cr, 1, 'product', 'uom_hour')[1],
+        }
+    cr.execute("""
+        SELECT
+            id,
+            openupgrade_legacy_project_time_mode
+        FROM
+            res_company
+        WHERE
+            openupgrade_legacy_project_time_mode IS NOT NULL
+        """)
+    for row in cr.fetchall():
+        if uom_map.get(row[1]):
+            company_pool.write(
+                cr, 1, row[0],
+                {'project_time_mode_id': uom_map(row[1])})
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    migrate_analytic(cr, pool)
+    openupgrade.set_defaults(cr, pool, defaults)
+    openupgrade.set_defaults(cr, pool, defaults_force, force=True)
+    migrate_task_parent_ids(cr, pool)

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import logging
+from openupgrade import openupgrade
+
+logger = logging.getLogger('OpenUpgrade: project')
+
+renamed_columns = {
+    'project_project': [
+        ('category_id', 'analytic_account_id'),
+        ('contact_id', 'openupgrade_legacy_contact_id'), # > aaa.contact_id
+        ('date_start', 'openupgrade_legacy_date_start'), # > aaa.date_start
+        ('date_end', 'openupgrade_legacy_date_end'),  # > aaa.date
+        ('manager', 'openupgrade_legacy_manager'),  # > aaa.user_id
+        ('name', 'openupgrade_legacy_name'), # > aaa.name
+        ('notes', 'openupgrade_legacy_notes'), # > aaa.description
+        ('parent_id', 'openupgrade_legacy_parent_id'), # aaa.parent_id of parent project's analytic account
+        ('partner_id', 'openupgrade_legacy_partner_id'), # > aaa.partner_id
+        ('state', 'openupgrade_legacy_state'), # > aaa.state (keys are equal)
+        ],
+    'project_task': [
+        ('date_close', 'date_end'), # simple change of name
+        ('type', 'type_id'), # name change
+        ('parent_id', 'openupgrade_legacy_parent_id'), # m2o -> m2m parent_ids
+        ],
+    'res_company': [
+        ('project_time_mode', 'openupgrade_legacy_project_time_mode'), # char selection -> m2o
+        ],
+    }
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, renamed_columns)
+    logger.warn(
+        "TODO: check whether project_task.date_deadline "
+        "preserves content when type changes from datetime to date")

=== 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 @@
+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.
+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.

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+def set_timesheet_id(cr):
+    """
+    Migrate an integer field that represents a
+    stock.incoterms' id field to a proper many2one
+    (i.e. weed out obsolete ids)
+    """
+    cr.execute("""
+        UPDATE
+            project_task_work
+        SET
+            hr_analytic_timesheet_id = hr_analytic_timesheet.id
+        FROM
+            hr_analytic_timesheet
+        WHERE
+            openupgrade_legacy_hr_analytic_timesheet_id = hr_analytic_timesheet.id
+        """)
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    set_timesheet_id(cr)

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+column_renames = {
+    'project_task_work': [
+        ('hr_analytic_timesheet_id', 'openupgrade_legacy_hr_analytic_timesheet_id'),
+        ],
+    }
+
+   
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, column_renames)
+

=== 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 @@
+This upgrade migrates timesheet entries on task work to a proper database relation.

=== 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data noupdate="1">
+
+    <record model="ir.rule" id="purchase_order_comp_rule">
+        <field name="name">Purchase Order multi-company</field>
+        <field name="model_id" ref="model_purchase_order"/>
+        <field name="global" eval="True"/>
+        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
+    </record>
+
+    <record model="ir.rule" id="purchase_order_line_comp_rule">
+        <field name="name">Purchase Order Line multi-company</field>
+        <field name="model_id" ref="model_purchase_order_line"/>
+        <field name="global" eval="True"/>
+        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
+    </record>
+
+</data>
+</openerp>

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+defaults_force = {
+    # False results in column value NULL
+    # None value triggers a call to the model's default function 
+    'purchase.order': [
+        ('company_id', None),
+        ],    
+    }
+
+def set_order_invoice_ids(cr, pool):
+    """
+    Migrate many2one to many2many
+    """
+    order_pool = pool.get('purchase.order')
+    cr.execute('SELECT id, openupgrade_legacy_invoice_id '
+               'FROM purchase_order '
+               'WHERE openupgrade_legacy_invoice_id IS NOT NULL')
+    for row in cr.fetchall():
+        order_pool.write(
+            cr, 1, row[0], {'invoice_ids': [(4, row[1])]})
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults_force, force=True)
+    set_order_invoice_ids(cr, pool)
+    openupgrade.load_xml(cr, 'purchase', 'migrations/6.0.1.1/data.xml')

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+logger = logging.getLogger('OpenUpgrade: purchase')
+
+column_renames = {
+    # this is a mapping per table from old column name
+    # to new column name
+    'purchase_order': [
+        ('invoice_id', 'openupgrade_legacy_invoice_id')
+        ],
+    }
+
+renamed_xmlids = [
+    ('mrp.act_buy', 'purchase.act_buy'),
+    ('mrp.trans_buy_make_done', 'purchase.trans_buy_make_done'),
+    ('mrp.trans_buy_cancel', 'purchase.trans_buy_cancel'),
+]   
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, column_renames)
+    openupgrade.rename_xmlids(cr, renamed_xmlids)
+    logger.warn(
+        'TODO: check whether datetime field preserves '
+        'content when migrated to date field '
+        '(purchase_order.minimum_planned_date and po_line.date_planned)')

=== 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 @@
+This upgrade allows multiple purchase orders to be related to multiple invoices instead of only one.
+

=== 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 @@
+Nothing to do for module 'purchase_analytic_plans'

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+defaults_force = {
+    # False results in column value NULL
+    # None value triggers a call to the model's default function 
+    'sale.shop': [('company_id', None)],    
+    }
+
+
+def set_incoterm(cr):
+    """
+    Migrate selection field that represents a
+    stock.incoterms' code field to a proper many2one
+    """
+    cr.execute("""
+        UPDATE
+            sale_order
+        SET
+            incoterm = stock_incoterms.id
+        FROM
+            stock_incoterms
+        WHERE
+            openupgrade_legacy_incoterm IS NOT NULL
+            AND openupgrade_legacy_incoterm = stock_incoterms.code
+        """)
+ 
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults_force, force=True)
+    set_incoterm(cr)

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+column_renames = {
+    'sale_order': [
+        ('incoterm', 'openupgrade_legacy_incoterm'),
+        ],
+    }
+
+   
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, column_renames)
+

=== 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 @@
+This upgrade stores a sale order's incoterm as a proper database relation. It also reloads the modified access permissions and security rules.

=== 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 @@
+Nothing to do for module 'sale_analytic_plans'

=== 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 @@
+Nothing to do for module 'sale_journal'

=== 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data noupdate="1">
+        <!-- Add a standard scrap location -->
+        <record id="stock_location_scrapped" model="stock.location">
+            <field name="name">Scrapped</field>
+            <field name="location_id" ref="stock_location_locations_virtual"/>
+            <field name="scrap_location">True</field>
+            <field name="usage">inventory</field>
+            <field name="company_id"></field>
+        </record>
+        <!-- The new stock journal -->
+        <record id="journal_delivery" model="stock.journal">
+            <field name="name">Delivery Orders</field>
+        </record>
+        <!-- update the output location with the new fields -->
+        <record id="stock_location_output" model="stock.location">
+            <field name="chained_auto_packing">transparent</field>
+            <field name="chained_picking_type">out</field>
+            <field name="chained_journal_id" ref="journal_delivery"/>
+        </record>
+        <!-- new sequences -->
+        <!-- We copied the old single sequence and sequence type
+        to these 'in' resources, but we still want to update the
+        name and code -->
+        <record id="seq_type_picking_in" model="ir.sequence.type">
+            <field name="name">Picking IN</field>
+            <field name="code">stock.picking.in</field>
+        </record>
+        
+        <record id="seq_type_picking_out" model="ir.sequence.type">
+            <field name="name">Picking OUT</field>
+            <field name="code">stock.picking.out</field>
+        </record>
+        
+        <record id="seq_type_picking_internal" model="ir.sequence.type">
+            <field name="name">Picking INT</field>
+            <field name="code">stock.picking.internal</field>
+        </record>
+
+        <record id="seq_picking_in" model="ir.sequence">
+            <field name="name">Picking IN</field>
+            <field name="code">stock.picking.in</field>
+            <field name="prefix">IN/</field>
+            <field name="padding">5</field>
+        </record>
+        
+        <record id="seq_picking_out" model="ir.sequence">
+            <field name="name">Picking OUT</field>
+            <field name="code">stock.picking.out</field>
+            <field name="prefix">OUT/</field>
+            <field name="padding">5</field>
+        </record>
+        
+        <record id="seq_picking_internal" model="ir.sequence">
+            <field name="name">Picking INT</field>
+            <field name="code">stock.picking.internal</field>
+            <field name="prefix">INT/</field>
+            <field name="padding">5</field>
+        </record>
+    </data>
+</openerp>

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pooler
+from openupgrade import openupgrade
+
+defaults_force = {
+    'stock.inventory': [('company_id', None)],
+    'stock.location': [('company_id', None)],
+    'stock.move': [('company_id', None)],
+    'stock.picking': [('company_id', None)],
+    'stock.production.lot': [('company_id', None)],
+    'stock.warehouse': [('company_id', None)],
+    }
+
+def update_picking_type(cr):
+    """
+    Picking type 'out' is now applied instead
+    of type 'delivery'
+    """
+    openupgrade.logged_query(
+        cr, 
+        """
+        UPDATE stock_picking
+        SET type = 'out'
+        WHERE type = 'delivery'
+        """)
+
+def set_valuation_accounts(cr):
+    """
+    The obsolete account_id field is now split up
+    in an incoming and outoing account
+    """
+    if openupgrade.column_exists(
+        cr, 'stock_location', 'openupgrade_legacy_account_id'):
+        openupgrade.logged_query(
+            cr,
+            """
+        UPDATE stock_location
+        SET valuation_in_account_id = openupgrade_legacy_account_id, 
+        valuation_out_account_id = openupgrade_legacy_account_id
+        """)
+
+def set_move_date(cr):
+    """ Move date records the date expected
+    or picking date when done. The latter is not available
+    at upgrade time, so we set it to date expected
+    Note that 'date' field is the old date of creation,
+    which is now replaced by displaying the history field
+    'create_date' (which assumingly already contains
+    appropriate values)
+    """
+    openupgrade.logged_query(
+        cr, """
+        UPDATE stock_move
+        SET date = date_expected
+        """)
+    
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    openupgrade.set_defaults(cr, pool, defaults)
+    openupgrade.set_defaults(cr, pool, defaults_force, force=True)
+    set_valuation_accounts(cr)
+    set_move_date(cr)
+    update_picking_type(cr)

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+renamed_columns = {
+    'stock_move': [
+        ('date_planned', 'date_expected'),
+        ],
+    'stock_location': [
+        ('account_id', 'openupgrade_legacy_account_id'),
+        ],
+    }
+
+renamed_xmlids = [
+    ('stock.seq_type_picking', 'stock.seq_type_picking_in'),
+    ('stock.seq_picking', 'stock.seq_picking_in'),
+    ]
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    openupgrade.rename_columns(cr, renamed_columns)
+    openupgrade.rename_xmlids(cr, renamed_xmlids)
+

=== 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 @@
+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.


Follow ups