~camptocamp/sale-wkfl/product_procurement_type

« back to all changes in this revision

Viewing changes to product_procurement_type_dropshipping/migrations/7.0.0.1/post-migration.py

  • Committer: alexandre.fayolle at camptocamp
  • Date: 2014-06-04 22:48:17 UTC
  • Revision ID: alexandre.fayolle@camptocamp.com-20140604224817-pt50btgk2u87s87s
the migration scripts are not longer called on installation -> move to init method

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
#    Author: Alexandre Fayolle
5
 
#    Copyright 2014 Camptocamp SA
6
 
#
7
 
#    This program is free software: you can redistribute it and/or modify
8
 
#    it under the terms of the GNU Affero General Public License as
9
 
#    published by the Free Software Foundation, either version 3 of the
10
 
#    License, or (at your option) any later version.
11
 
#
12
 
#    This program is distributed in the hope that it will be useful,
13
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
#    GNU Affero General Public License for more details.
16
 
#
17
 
#    You should have received a copy of the GNU Affero General Public License
18
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 
#
20
 
##############################################################################
21
 
 
22
 
import logging
23
 
 
24
 
logger = logging.getLogger('openerp.upgrade')
25
 
 
26
 
 
27
 
def migrate(cr, version):
28
 
    logger.info('Migrating product_procurement_type_dropshipping')
29
 
    query = ("UPDATE product_template AS pt "
30
 
             "SET procurement_type=%(procurement_type)s "
31
 
             "FROM product_supplierinfo AS psi "
32
 
             "WHERE procure_method=%(procure_method)s "
33
 
             "  AND supply_method=%(supply_method)s "
34
 
             "  AND psi.product_id = pt.id "
35
 
             "  AND psi.direct_delivery_flag = true")
36
 
    fixes = [{'procurement_type': 'direct_delivery', 'procure_method': 'make_to_order', 'supply_method': 'buy'},
37
 
             ]
38
 
    for fix in fixes:
39
 
        cr.execute(query, fix)