Odoo Help


set default checked checkbox when I create new object?

on 4/15/13, 3:22 PM 1,786 views


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"/>

But it seems not working !

Danimar Ribeiro
On 4/15/13, 3:45 PM

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.

on 4/16/13, 7:24 AM

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

Danimar Ribeiro
on 4/16/13, 9:20 AM

Help plz it doesn't work at all

on 4/17/13, 9:47 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 4/15/13, 3:22 PM
Seen: 1786 times
Last updated: 3/16/15, 8:10 AM