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

View File

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