From 5bc8790861ecdf21f9f37df5eb2d3fc31bca9f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 14 May 2012 15:36:34 +0200 Subject: [PATCH] Remove required on sequence review348001 --- dashboard.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dashboard.py b/dashboard.py index 83eb03a4a1..56111d393c 100644 --- a/dashboard.py +++ b/dashboard.py @@ -1,6 +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 trytond.model import ModelView, ModelSQL, fields +from trytond.transaction import Transaction +from trytond.backend import TableHandler class DashboardAction(ModelSQL, ModelView): @@ -9,7 +11,9 @@ class DashboardAction(ModelSQL, ModelView): user = fields.Many2One('res.user', 'User', required=True, select=True) - sequence = fields.Integer('Sequence', required=True) + sequence = fields.Integer('Sequence', + order_field='(%(table)s.sequence IS NULL) %(order)s, ' + '%(table)s.sequence %(order)s') act_window = fields.Many2One('ir.action.act_window', 'Action', required=True, ondelete='CASCADE', domain=[ ('res_model', '!=', None), @@ -20,4 +24,13 @@ class DashboardAction(ModelSQL, ModelView): super(DashboardAction, self).__init__() self._order.insert(0, ('sequence', 'ASC')) + def init(self, module_name): + cursor = Transaction().cursor + table = TableHandler(cursor, self, module_name) + + super(DashboardAction, self).init(module_name) + + # Migration from 2.4: drop required on sequence + table.not_null_action('sequence', action='remove') + DashboardAction()