Use required on states for dashboard_layout

Extending a Model by adding hard required breaks the migration
This commit is contained in:
Cédric Krier committed 2010-05-28 20:25:24 +02:00
1 parent d2e9f76433
commit e744802f77
2 files changed
+14 -1

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
* Use required on states for dashboard_layout
Version 1.6.0 - 2010-05-09
* Bug fixes (see mercurial logs for details)
+12 -1
View File
@@ -1,6 +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 Model, fields
from trytond.backend import TableHandler
class User(Model):
@@ -12,7 +13,10 @@ class User(Model):
('stack_left', 'Stack Left'),
('stack_top', 'Stack Top'),
('stack_bottom', 'Stack Bottom'),
], string='Dashboard Layout', required=True)
], string='Dashboard Layout',
states={
'required': True,
})
dashboard_actions = fields.One2Many('dashboard.action', 'user',
'Dashboard Actions')
@@ -23,6 +27,13 @@ class User(Model):
'dashboard_actions',
]
def init(self, cursor, module_name):
super(User, self).init(cursor, module_name)
table = TableHandler(cursor, self, module_name)
# Migration from 1.6
table.not_null_action('dashboard_layout', action='remove')
def default_dashboard_layout(self, cursor, user, context=None):
return 'square'