Hi hda,
looking at the wizard_partner_balance_report i found this line in the fields
section of a form :
'date2': {'string':'End date', 'type':'date', 'required':True,'default': lambda
*a: time.strftime('%Y-%m-%d')},
using the 'default' option I was able to set the default value for the url
field using the wizard fields declaration rather than using the init action.
Another problem i encounterd was the limit of the number of characters
displayed in the edit field. Passing the 'size'='254' solved this problem.
For other newbees like me, please find below the full example of a simple
wizard, created for OpenERP V5.0.3:
example of a basic wizard, setting default values of fields in wizard and
passing values between forms of wizard
===============================================
import wizard
import netsvc
import time
from tools.translate import _
sync_form1 = '''<?xml version="1.0"?>
<form string="Sync with server">
<newline />
<label string="Are you sure you want to synchronize with server?"
colspan="2" align="0.0"/>
<newline />
<field name="url_server"/>
<newline />
</form>'''
sync_fields1 = {
'url_server':{'string':'Server', 'type':'char', 'size':'254',
'required':True, 'default': lambda *a: "http://www.myurl.com:8050"},
}
sync_form2 = '''<?xml version="1.0"?>
<form string="Sync with Server">
<newline />
<label string="Synchronizing with Server finished" colspan="2"/>
</form>'''
sync_fields2 = {
'result':{'string':'Result', 'type':'char', 'readonly':True},
}
def _sync_server(self, cr, uid, args, context):
# Do synchro here
cResult = oWebService.synchro(params)
# Create dictionary to store the result of the synchro in
# Note that dictonary contains "result" key which corresponds with the
field "result" in the fields of sync_fields2
dctValues["result"] = cResult
# Pass the result to next page
return dctValues
class sync_with_server(wizard.interface):
states = {
'init': {
'actions': [],
'result': {
'type':'form',
'arch':sync_form1,
'fields':sync_fields1,
'state':[
('end','Cancel', 'gtk-cancel'),
('sync_server','Synchronize', '', True),
]
}
},
'sync_server': {
'actions': [_sync_server],
'result': {
'type':'form',
'arch':sync_form2,
'fields':sync_fields2,
'state':[
('end','Ok'),
]
},
}
}
sync_with_server("sync_with_server")
=============================================
-------------------- m2f --------------------
--
http://www.openobject.com/forum/viewtopic.php?p=43900#43900
-------------------- m2f --------------------
_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman2/listinfo/tinyerp-users