From 1bb60e0e98e1f011b4595b33ae7a2cfeda845647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 6 Sep 2013 22:34:16 +0200 Subject: [PATCH] Migration to python-sql review1001002 --- dashboard.py | 12 ++++++++---- res.py | 7 +++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/dashboard.py b/dashboard.py index ed89c8214a..406fe05268 100644 --- a/dashboard.py +++ b/dashboard.py @@ -2,7 +2,7 @@ #this repository contains the full copyright notices and license terms. from trytond.model import ModelView, ModelSQL, fields from trytond.transaction import Transaction -from trytond.backend import TableHandler +from trytond import backend from trytond.pyson import Eval __all__ = ['DashboardAction'] @@ -13,9 +13,7 @@ class DashboardAction(ModelSQL, ModelView): __name__ = "dashboard.action" user = fields.Many2One('res.user', 'User', required=True, select=True) - sequence = fields.Integer('Sequence', - order_field='(%(table)s.sequence IS NULL) %(order)s, ' - '%(table)s.sequence %(order)s') + sequence = fields.Integer('Sequence') act_window = fields.Many2One('ir.action.act_window', 'Action', required=True, ondelete='CASCADE', domain=[ ('res_model', '!=', None), @@ -35,6 +33,7 @@ class DashboardAction(ModelSQL, ModelView): @classmethod def __register__(cls, module_name): + TableHandler = backend.get('TableHandler') cursor = Transaction().cursor table = TableHandler(cursor, cls, module_name) @@ -42,3 +41,8 @@ class DashboardAction(ModelSQL, ModelView): # Migration from 2.4: drop required on sequence table.not_null_action('sequence', action='remove') + + @staticmethod + def order_sequence(tables): + table, _ = tables[None] + return [table.sequence == None, table.sequence] diff --git a/res.py b/res.py index b3aeb5089e..bb0e3e877c 100644 --- a/res.py +++ b/res.py @@ -1,7 +1,7 @@ #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 trytond.model import fields -from trytond.backend import TableHandler +from trytond import backend from trytond.transaction import Transaction from trytond.pool import PoolMeta @@ -31,8 +31,11 @@ class User: @classmethod def __register__(cls, module_name): - super(User, cls).__register__(module_name) + TableHandler = backend.get('TableHandler') cursor = Transaction().cursor + + super(User, cls).__register__(module_name) + table = TableHandler(cursor, cls, module_name) # Migration from 1.6