Migration to python-sql

review1001002
This commit is contained in:
Cédric Krier committed 2013-09-06 22:34:56 +02:00
1 parent b3903f2627
commit 41d599b492
5 files changed
+28 -13

No files matched your search

+1
View File
@@ -5,6 +5,7 @@ Prerequisites
-------------
* Python 2.6 or later (http://www.python.org/)
* python-sql (http://code.google.com/p/python-sql/)
* trytond (http://www.tryton.org/)
* trytond_party (http://www.tryton.org/)
* trytond_product (http://www.tryton.org/)
+2 -1
View File
@@ -3,7 +3,7 @@
from trytond.model import ModelView, ModelSQL, fields
from trytond.pyson import If, Equal, Eval, Not, In, Get
from trytond.transaction import Transaction
from trytond.backend import TableHandler
from trytond import backend
__all__ = ['OrderPoint']
@@ -87,6 +87,7 @@ class OrderPoint(ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
cursor = Transaction().cursor
# Migration from 2.2
table = TableHandler(cursor, cls, module_name)
+5 -3
View File
@@ -84,12 +84,14 @@ class PurchaseRequest(ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
cursor = Transaction().cursor
sql_table = cls.__table__()
super(PurchaseRequest, cls).__register__(module_name)
# Migration from 2.0: empty order point origin is -1 instead of 0
cursor.execute('UPDATE "%s" '
'SET origin = %%s WHERE origin = %%s' % cls._table,
('stock.order_point,-1', 'stock.order_point,0'))
cursor.execute(*sql_table.update(
columns=[sql_table.origin],
values=['stock.order_point,-1'],
where=sql_table.origin == 'stock.order_point,0'))
def get_rec_name(self, name):
if self.warehouse:
+1 -1
View File
@@ -21,7 +21,7 @@ major_version, minor_version, _ = info.get('version', '0.0.1').split('.', 2)
major_version = int(major_version)
minor_version = int(minor_version)
requires = []
requires = ['python-sql']
for dep in info.get('depends', []):
if not re.match(r'(ir|res|webdav)(\W|$)', dep):
requires.append('trytond_%s >= %s.%s, < %s.%s' %
+19 -8
View File
@@ -1,5 +1,8 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from sql import Table
from sql.functions import Overlay, Position
from trytond.model import ModelView, ModelSQL
from trytond.wizard import Wizard, StateView, StateAction, Button
from trytond.transaction import Transaction
@@ -16,15 +19,23 @@ class ShipmentInternal(ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
cursor = Transaction().cursor
model_data = Table('ir_model_data')
model = Table('ir_model')
# Migration from 1.2: packing renamed into shipment
cursor.execute("UPDATE ir_model_data "
"SET fs_id = REPLACE(fs_id, 'packing', 'shipment') "
"WHERE fs_id like '%%packing%%' AND module = %s",
(module_name,))
cursor.execute("UPDATE ir_model "
"SET model = REPLACE(model, 'packing', 'shipment') "
"WHERE model like '%%packing%%' AND module = %s",
(module_name,))
cursor.execute(*model_data.update(
columns=[model_data.fs_id],
values=[Overlay(model_data.fs_id, 'shipment',
Position('packing', model_data.fs_id),
len('packing'))],
where=model_data.fs_id.like('%packing%')
& (model_data.module == module_name)))
cursor.execute(*model.update(
columns=[model.model],
values=[Overlay(model.model, 'shipment',
Position('packing', model.model),
len('packing'))],
where=model.model.like('%packing%')
& (model.module == module_name)))
super(ShipmentInternal, cls).__register__(module_name)
@classmethod