Change states definition to use any fields

This commit is contained in:
Cédric Krier committed 2008-02-06 00:24:39 +01:00
1 parent 253ff1988b
commit ae1d2fb395
3 files changed
+23 -37

No files matched your search

+8 -7
View File
@@ -35,19 +35,20 @@
<field name="state" readonly="1"/>
<group col="6" colspan="2">
<button string="Install" name="button_install"
type="object" states="uninstalled"/>
type="object" states="state == 'uninstalled'"/>
<button string="Cancel Install" name="button_install_cancel"
type="object" states="to install"/>
type="object" states="state == 'to install'"/>
<button string="Uninstall (beta)" name="button_uninstall"
type="object" states="installed"/>
type="object" states="state == 'installed'"/>
<button string="Cancel Uninstall" name="button_uninstall_cancel"
type="object" states="to remove"/>
type="object" states="state == 'to remove'"/>
<button string="Upgrade" name="button_upgrade"
type="object" states="installed"/>
type="object" states="state == 'installed'"/>
<button string="Cancel Upgrade" name="button_upgrade_cancel"
type="object" states="to upgrade"/>
type="object" states="state == 'to upgrade'"/>
<!--
<button string="Update translations" name="button_update_translations" type="object" states="installed"/>
<button string="Update translations" name="button_update_translations"
type="object" states="state == 'installed'"/>
-->
</group>
</page>
+12 -27
View File
@@ -18,9 +18,7 @@ class Request(OSV):
_columns = {
'create_date': fields.DateTime('Created date', readonly=True),
'name': fields.Char('Subject', states={
'waiting': [('readonly', True)],
'active': [('readonly', True)],
'closed': [('readonly', True)],
'readonly': "state in ('waiting', 'active', 'closed')",
}, required=True, size=128),
'active': fields.Boolean('Active'),
'priority': fields.Selection([
@@ -28,26 +26,22 @@ class Request(OSV):
('1', 'Normal'),
('2', 'High'),
], 'Priority', states={
'waiting': [('readonly', True)],
'closed': [('readonly', True)],
'readonly': "state in ('waiting', 'closed')",
}, required=True),
'act_from': fields.Many2One('res.user', 'From', required=True,
readonly=True, states={
'closed': [('readonly', True)],
'readonly': "state == 'closed'",
}),
'act_to': fields.Many2One('res.user', 'To', required=True,
states={
'waiting': [('readonly', True)],
'closed': [('readonly', True)],
'readonly': "state in ('waiting', 'closed')",
}),
'body': fields.Text('Request', states={
'waiting': [('readonly', True)],
'closed': [('readonly', True)],
'readonly': "state in ('waiting', 'closed')",
}),
'date_sent': fields.DateTime('Date', readonly=True),
'trigger_date': fields.DateTime('Trigger Date', states={
'waiting': [('readonly', True)],
'closed': [('readonly', True)],
'readonly': "state in ('waiting', 'closed')",
}),
# 'ref_partner_id': fields.Many2One('res.partner', 'Partner Ref.',
# states={
@@ -56,11 +50,11 @@ class Request(OSV):
#TODO: use one2many instead limit number of reference
'ref_doc1': fields.Reference('Document Ref 1', selection=_links_get,
size=128, states={
'closed': [('readonly', True)],
'readonly': "state == 'closed'",
}),
'ref_doc2': fields.Reference('Document Ref 2', selection=_links_get,
size=128, states={
'closed': [('readonly', True)],
'readonly': "state == 'closed'",
}),
'state': fields.Selection([
('draft', 'draft'),
@@ -153,23 +147,14 @@ class RequestHistory(OSV):
_name = 'res.request.history'
_description = __doc__
_columns = {
'name': fields.Char('Summary', size=128, states={
'active': [('readonly', True)],
'waiting': [('readonly', True)],
}, required=True),
'name': fields.Char('Summary', size=128, required=True),
'req_id': fields.Many2One('res.request', 'Request', required=True,
ondelete='cascade', select=True),
'act_from': fields.Many2One('res.user', 'From', required=True,
readonly=True),
'act_to': fields.Many2One('res.user', 'To', required=True, states={
'waiting': [('readonly', True)],
}),
'body': fields.Text('Body', states={
'waiting': [('readonly', True)],
}),
'date_sent': fields.DateTime('Date sent', states={
'waiting': [('readonly', True)],
}, required=True)
'act_to': fields.Many2One('res.user', 'To', required=True),
'body': fields.Text('Body'),
'date_sent': fields.DateTime('Date sent', required=True)
}
_defaults = {
'name': lambda *a: 'NoName',
+3 -3
View File
@@ -41,9 +41,9 @@
<label name="trigger_date"/>
<field name="trigger_date"/>
<group col="2" colspan="2">
<button name="request_send" states="draft,active"
<button name="request_send" states="state in ('draft', 'active')"
string="Send" type="object"/>
<button name="request_reply" states="waiting"
<button name="request_reply" states="state == 'waiting'"
string="Reply" type="object"/>
</group>
<separator string="References" colspan="4"/>
@@ -60,7 +60,7 @@
<group col="3" colspan="2">
<label name="active"/>
<field name="active"/>
<button name="request_close" states="waiting,draft,active"
<button name="request_close" states="state in ('waiting', 'draft', 'active')"
string="Close" type="object"/>
</group>
</page>