跳至內容
選單
此問題已被標幟
1 回覆
5562 瀏覽次數

Holla

I want to set default checked checkbox when I create a new object, I just apply wath's in res.partner module ( customer checkbox and supplier checkbox), My action's code is :

<record id="action_mymodule_form" model="ir.actions.act_window">
            <field name="name">My module</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">my.module</field>
            <field name="view_type">form</field>
            <field name="domain">[('myfield','=',1)]</field>
            <field name="context">{'default_myfield':1, 'search_default_myfield':1}</field>
            <field name="filter" eval="True"/>
        </record>

But it seems not working !

頭像
捨棄
最佳答案

I think the best approach is to use _defaults in the class definition.

_defaults = { 'myfield':1 }

頭像
捨棄
作者

in my case, I have two fields myfields1 and myfields2 , I want just like in res.partner, in customer view the customer checkbox is checked, and in supplier view the supplier checkbox is checked.

You can use eval to the field I think. <field name="field1" eval="1" />

作者

Help plz it doesn't work at all

相關帖文 回覆 瀏覽次數 活動
3
7月 23
67645
4
3月 15
7378
1
3月 15
6622
0
3月 15
3762
0
3月 15
3697