Setting default values for wizard start form

28 views
Skip to first unread message

Khurram Shahzad

unread,
Dec 1, 2017, 6:05:07 AM12/1/17
to try...@googlegroups.com
Hi,

I saw an example where some values are passed using field names 'context' and 'domain' as:

<record model="ir.action.act_window" id="act_medicament_by_category">

        <field name="name">Medicament by Category</field>

        <field name="res_model">gnuhealth.medicament</field>


        <field name="context" eval="{'categories': [Eval('active_id')]}" pyson="1"/>

	<field name="domain"  eval="[('category', 'child_of', [Eval('active_id')], 'parent')]" 
  pyson="1"/>
 
</record>

Clearly, value for 'categories' is passed.

I want to achieve the same for my wizard but it failed:


<record model="ir.action.wizard" id="patient_proc_test_request">
            <field name="name">Request Procedure</field>
            <field name="wiz_name">anth.patient.proc.test.request</field>
<field name="context" eval="{'day_care_test_only': True}" pyson="1"/>
</record> <record model="ir.action.keyword" id="act_open_patient_proc_request_form_keyword1"> <field name="keyword">form_action</field> <field name="model">gnuhealth.patient,-1</field> <field name="action" ref="patient_proc_test_request"/> </record> Here I am trying to pass a Boolean value for a field 'day_care_test' to be true. This field will be shown on the startup form of wizard and I want it sometimes checked and sometimes unchecked by default.

It is not working and throwing keyError. Any ideas on how to set default values for wizard from xml file?

Regards,
Khurram.

Sergi Almacellas Abellana

unread,
Dec 1, 2017, 6:13:07 AM12/1/17
to try...@googlegroups.com
El 01/12/17 a les 11:42, Khurram Shahzad ha escrit:
>
> It is not working and throwing keyError. Any ideas on how to set default values for wizard from xml file?
You can't. You should define a python code that set the default values
of your StateViews by using a default_<field> method. This method can
return values from the context if you want.

Additionally, you can set the default values of a transition, by setting
the default_<transition> method on the wizard. This method can read
values from previous wizard steps. See [1] for an example.

Hope it helps.

[1] http://hg.tryton.org/modules/account/file/e1457237de9e/account.py#l2128

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Khurram Shahzad

unread,
Dec 1, 2017, 4:00:07 PM12/1/17
to try...@googlegroups.com
Thanks a lot.
Reply all
Reply to author
Forward
0 new messages