changeset c5007d98b0ba in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=c5007d98b0ba
description:
        Remove required on icon, action domain and action view sequence

        issue7889
        review54451002
diffstat:

 trytond/ir/action.py  |  32 +++++++++++++++++++++++---------
 trytond/ir/module.py  |  15 +++++++--------
 trytond/ir/ui/icon.py |  15 +++++++++++----
 3 files changed, 41 insertions(+), 21 deletions(-)

diffs (176 lines):

diff -r bfef7a2472b2 -r c5007d98b0ba trytond/ir/action.py
--- a/trytond/ir/action.py      Wed Nov 28 10:05:01 2018 +0100
+++ b/trytond/ir/action.py      Thu Nov 29 13:19:47 2018 +0100
@@ -7,7 +7,9 @@
 
 from sql import Null
 
-from ..model import ModelView, ModelStorage, ModelSQL, DeactivableMixin, fields
+from ..model import (
+    ModelView, ModelStorage, ModelSQL, DeactivableMixin, fields,
+    sequence_ordered)
 from ..tools import file_open
 from ..pyson import PYSONDecoder, PYSON, Eval
 from ..transaction import Transaction
@@ -861,19 +863,23 @@
         return Action.get_action_values(cls.__name__, [action_id])[0]
 
 
-class ActionActWindowView(DeactivableMixin, ModelSQL, ModelView):
+class ActionActWindowView(
+        sequence_ordered(), DeactivableMixin, ModelSQL, ModelView):
     "Action act window view"
     __name__ = 'ir.action.act_window.view'
-    sequence = fields.Integer('Sequence', required=True)
     view = fields.Many2One('ir.ui.view', 'View', required=True,
             ondelete='CASCADE')
     act_window = fields.Many2One('ir.action.act_window', 'Action',
             ondelete='CASCADE')
 
     @classmethod
-    def __setup__(cls):
-        super(ActionActWindowView, cls).__setup__()
-        cls._order.insert(0, ('sequence', 'ASC'))
+    def __register__(cls, module_name):
+        super().__register__(module_name)
+
+        table = cls.__table_handler__(module_name)
+
+        # Migration from 5.0: remove required on sequence
+        table.not_null_action('sequence', 'remove')
 
     @classmethod
     def create(cls, vlist):
@@ -895,11 +901,11 @@
         pool.get('ir.action.keyword')._get_keyword_cache.clear()
 
 
-class ActionActWindowDomain(DeactivableMixin, ModelSQL, ModelView):
+class ActionActWindowDomain(
+        sequence_ordered(), DeactivableMixin, ModelSQL, ModelView):
     "Action act window domain"
     __name__ = 'ir.action.act_window.domain'
     name = fields.Char('Name', translate=True)
-    sequence = fields.Integer('Sequence', required=True)
     domain = fields.Char('Domain')
     count = fields.Boolean('Count')
     act_window = fields.Many2One('ir.action.act_window', 'Action',
@@ -908,13 +914,21 @@
     @classmethod
     def __setup__(cls):
         super(ActionActWindowDomain, cls).__setup__()
-        cls._order.insert(0, ('sequence', 'ASC'))
         cls._error_messages.update({
                 'invalid_domain': ('Invalid domain or search criteria '
                     '"%(domain)s" on action "%(action)s".'),
                 })
 
     @classmethod
+    def __register__(cls, module_name):
+        super().__register__(module_name)
+
+        table = cls.__table_handler__(module_name)
+
+        # Migration from 5.0: remove required on sequence
+        table.not_null_action('sequence', 'remove')
+
+    @classmethod
     def default_count(cls):
         return False
 
diff -r bfef7a2472b2 -r c5007d98b0ba trytond/ir/module.py
--- a/trytond/ir/module.py      Wed Nov 28 10:05:01 2018 +0100
+++ b/trytond/ir/module.py      Thu Nov 29 13:19:47 2018 +0100
@@ -5,7 +5,7 @@
 
 from sql.operators import NotIn
 
-from trytond.model import ModelView, ModelSQL, fields, Unique
+from trytond.model import ModelView, ModelSQL, fields, Unique, sequence_ordered
 from trytond.modules import get_module_list, get_module_info
 from trytond.wizard import Wizard, StateView, Button, StateTransition, \
     StateAction
@@ -381,23 +381,17 @@
             return 'unknown'
 
 
-class ModuleConfigWizardItem(ModelSQL, ModelView):
+class ModuleConfigWizardItem(sequence_ordered(), ModelSQL, ModelView):
     "Config wizard to run after activating a module"
     __name__ = 'ir.module.config_wizard.item'
     action = fields.Many2One('ir.action', 'Action', required=True,
         readonly=True)
-    sequence = fields.Integer('Sequence', required=True)
     state = fields.Selection([
         ('open', 'Open'),
         ('done', 'Done'),
         ], string='State', required=True, select=True)
 
     @classmethod
-    def __setup__(cls):
-        super(ModuleConfigWizardItem, cls).__setup__()
-        cls._order.insert(0, ('sequence', 'ASC'))
-
-    @classmethod
     def __register__(cls, module_name):
         TableHandler = backend.get('TableHandler')
         cursor = Transaction().connection.cursor()
@@ -417,6 +411,11 @@
 
         super(ModuleConfigWizardItem, cls).__register__(module_name)
 
+        table = cls.__table_handler__(module_name)
+
+        # Migration from 5.0: remove required on sequence
+        table.not_null_action('sequence', 'remove')
+
     @staticmethod
     def default_state():
         return 'open'
diff -r bfef7a2472b2 -r c5007d98b0ba trytond/ir/ui/icon.py
--- a/trytond/ir/ui/icon.py     Wed Nov 28 10:05:01 2018 +0100
+++ b/trytond/ir/ui/icon.py     Thu Nov 29 13:19:47 2018 +0100
@@ -3,7 +3,7 @@
 
 import os
 
-from trytond.model import ModelView, ModelSQL, fields
+from trytond.model import ModelView, ModelSQL, fields, sequence_ordered
 from trytond.tools import file_open
 from trytond.transaction import Transaction
 from trytond.rpc import RPC
@@ -13,7 +13,7 @@
     ]
 
 
-class Icon(ModelSQL, ModelView):
+class Icon(sequence_ordered(), ModelSQL, ModelView):
     'Icon'
     __name__ = 'ir.ui.icon'
 
@@ -21,16 +21,23 @@
     module = fields.Char('Module', readonly=True, required=True)
     path = fields.Char('SVG Path', readonly=True, required=True)
     icon = fields.Function(fields.Char('Icon', depends=['path']), 'get_icon')
-    sequence = fields.Integer('Sequence', required=True)
 
     @classmethod
     def __setup__(cls):
         super(Icon, cls).__setup__()
-        cls._order.insert(0, ('sequence', 'ASC'))
         cls.__rpc__.update({
                 'list_icons': RPC(),
                 })
 
+    @classmethod
+    def __register__(cls, module_name):
+        super().__register__(module_name)
+
+        table = cls.__table_handler__(module_name)
+
+        # Migration from 5.0: remove required on sequence
+        table.not_null_action('sequence', 'remove')
+
     @staticmethod
     def default_module():
         return Transaction().context.get('module') or ''

Reply via email to