Follow PEP-0249 for Transaction and backends

This commit is contained in:
jmartin 2016-03-10 13:35:15 +01:00
parent f455cdf383
commit f395312690
2 changed files with 6 additions and 11 deletions

View File

@ -4,7 +4,6 @@
from trytond import backend
from trytond.model import ModelSQL, ModelView, fields
from trytond.pyson import Eval
from trytond.transaction import Transaction
__all__ = ['SaleDevice', 'SaleDeviceStatementJournal']
@ -32,11 +31,10 @@ class SaleDevice(ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
cursor = Transaction().cursor
old_table = 'sale_pos_device'
if TableHandler.table_exist(cursor, old_table):
TableHandler.table_rename(cursor, old_table, cls._table)
if TableHandler.table_exist(old_table):
TableHandler.table_rename(old_table, cls._table)
super(SaleDevice, cls).__register__(module_name)
@ -64,12 +62,11 @@ class SaleDeviceStatementJournal(ModelSQL):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
cursor = Transaction().cursor
table = TableHandler(cursor, cls, module_name)
table = TableHandler(cls, module_name)
old_table = 'sale_pos_device_account_statement_journal'
if TableHandler.table_exist(cursor, old_table):
TableHandler.table_rename(cursor, old_table, cls._table)
if TableHandler.table_exist(old_table):
TableHandler.table_rename(old_table, cls._table)
old_column = 'pos_device'
new_column = 'device'

View File

@ -5,7 +5,6 @@ from trytond import backend
from trytond.model import fields
from trytond.pool import PoolMeta
from trytond.pyson import Eval
from trytond.transaction import Transaction
__all__ = ['User']
@ -30,8 +29,7 @@ class User:
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
cursor = Transaction().cursor
table = TableHandler(cursor, cls, module_name)
table = TableHandler(cls, module_name)
# Migrate from sale_pos 3.0
old_column = 'pos_device'