[IMP] Add the state field
[IMP] Return the value of self.write in action_validate [IMP] Draw the screen for the Add Maintenance Contract wizard bzr revid: stephane@tinyerp.com-20081202185232-9hszwznnz6vwz9md
This commit is contained in:
parent
862a0230db
commit
7af013fd48
|
@ -60,15 +60,18 @@ class maintenance_contract_wizard(osv.osv_memory):
|
|||
_columns = {
|
||||
'name' : fields.char('Contract ID', size=256, required=True ),
|
||||
'password' : fields.char('Password', size=64, required=True),
|
||||
'state' : fields.selection([('draft', 'Draft'),('validated', 'Validated'),('unvalidated', 'Unvalidated')], 'States'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state' : lambda *a: 'draft',
|
||||
}
|
||||
|
||||
def action_validate(self, cr, uid, ids, context):
|
||||
if not ids:
|
||||
return False
|
||||
|
||||
contract = self.read(cr, uid, ids, ['name', 'password'])[0]
|
||||
if contract['name'] == 'toto':
|
||||
self.write(cr, uid, ids, { 'name' : 'trouduc' })
|
||||
return False
|
||||
|
||||
login, password, remote_db, remote_server, port = 'admin', 'admin', 'trunk', 'localhost', 8069
|
||||
|
||||
|
@ -88,7 +91,7 @@ class maintenance_contract_wizard(osv.osv_memory):
|
|||
}
|
||||
)
|
||||
|
||||
return res
|
||||
return self.write(cr, uid, ids, {'state' : ('unvalidated', 'validated')[bool(res)] }, context=context)
|
||||
|
||||
maintenance_contract_wizard()
|
||||
|
||||
|
|
|
@ -54,19 +54,27 @@
|
|||
<field name="model">maintenance.contract.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Add Maintenance Contract" col="4">
|
||||
<form string="Add Maintenance Contract" col="2">
|
||||
<image name="gtk-dialog-info" />
|
||||
<group>
|
||||
<separator string="Add Maintenance Contract" colspan="2"/>
|
||||
<newline />
|
||||
<field name="name" />
|
||||
<newline />
|
||||
<field name="password" password="True" />
|
||||
<group col="1">
|
||||
<separator string="Add Maintenance Contract" />
|
||||
<group states="draft">
|
||||
<field name="name" width="250" />
|
||||
<newline />
|
||||
<field name="password" password="True" />
|
||||
<field name="state" invisible="1" />
|
||||
</group>
|
||||
<group states="validated">
|
||||
<label string="Maintenance contract added !"/>
|
||||
</group>
|
||||
<group states="unvalidated">
|
||||
<label string="Could you check your contract information ?" />
|
||||
</group>
|
||||
</group>
|
||||
<newline />
|
||||
<group colspan="2">
|
||||
<button type="object" string="Cancel" special="cancel" icon="gtk-cancel" />
|
||||
<button name="action_validate" type="object" string="Validate" icon="gtk-apply" />
|
||||
<group colspan="4">
|
||||
<button type="object" string="_Cancel" icon="gtk-cancel" special="cancel" states="draft"/>
|
||||
<button type="object" string="_Validate" icon="gtk-apply" name="action_validate" states="draft"/>
|
||||
<button type="object" string="_Close" icon="gtk-close" special="cancel" states="validated,unvalidated"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue