Odoo Help


This community 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.


How to set the opt_out checkbox to a default value?

Gérald Janniaux
on 3/6/14, 11:17 AM 2,255 views

I would like when opening the partner view to have the opt_out checkbox always checked. How can I do that?


Jusab Sida (jsi)

--Jusab Sida (jsi)--
Tiny ERP Pvt Ltd
| 2 1 5
Gandhinagar, India
--Jusab Sida (jsi)--

Jusab Sida (jsi)
On 4/5/16, 9:54 AM

(Credit goes to Med Said BARA)


For that you need to change here: For V8

module : email_template

file : res_partner.py 

 _defaults = {
    'opt_out': True,

For V9:

module: mail

file: res_partner

opt_out = fields.Boolean(
'Opt-Out', default=True, help="If opt-out is checked, this contact has refused to receive emails for mass mailing and marketing campaign. "
"Filter 'Available for Mass Mailing' allows users to filter the partners when performing mass mailing.")

Then restart your server, update module(email_temaplte(v8), mail(v9)).

Just refresh your page, click on create of partner form and see the magic in opt_out.

(It will be good if you do that all thing by inheriting respected model) 


Med Said BARA

--Med Said BARA--
| 5 5 7
--Med Said BARA--
Med Said BARA
On 3/6/14, 12:20 PM


Edit the file .../openerp/addons/crm/crm_lead.py around the line 317 add 'opt_out': 1,


_defaults = {

   'opt_out': 1,    <------------------- add this line

    'active': 1,

    'type': 'lead',

    'user_id': lambda s, cr, uid, c: s._get_default_user(cr, uid, c),

    'email_from': lambda s, cr, uid, c: s._get_default_email(cr, uid, c),

    'stage_id': lambda s, cr, uid, c: s._get_default_stage_id(cr, uid, c),

    'section_id': lambda s, cr, uid, c: s._get_default_section_id(cr, uid, c),

    'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),

    'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],

    'color': 0,


_sql_constraints = [

Update the module crm.

Sory, change it here: openerp/addons/email_template/res_partner.py

Change False to True

_defaults = {

    'opt_out': False,

try with:

_defaults = {

    'opt_out':  lambda *a: True,

Well, this does not work. I've also changed the 'active' value to 0, restarted the server updating all modules, and nothing changed.

Gérald Janniaux
on 3/6/14, 1:20 PM

Already tried the 'False to True' change in openerp/addons/email_template/res_partner.py. This has no effect....

Gérald Janniaux
on 3/6/14, 2:11 PM

I've found a way to do it. Here is the description:

Activate the "Technical features" from Settings -> Users -> Users -> USERNAME -> Access Rights (tab in the form) and check the "Technical features" checkbox and refresh with F5.

After this go to Settings -> Technical -> Actions -> User-defined Defaults. Then click on "Create" and fill in the fields as follows:

Name = opt_out (field name)

Model Name - leave it empty, because the next field will auto fill it

Model = res.partner (you can set also crm.lead if you use CRM module)

Condition - leave empty, because you want in any condition to have the opt_out field checked

User - leave empty if you want to activate this action for every user

Textarea (under Model field) = 1.

Finally, save the action and create a new partner. The field opt_out should be checked by default now.

I have used the same procedure to check this field by default for crm.lead and res.partner models. It works fine.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 3/6/14, 11:17 AM
Seen: 2255 times
Last updated: 5/24/16, 9:19 AM