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.


Odoo 9: How to set display strings for boolean_button?

Matthew Watkins
on 8/24/16, 2:31 PM 184 views

Is there a way to set the text displayed in each state for a boolean button?


Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 8/24/16, 6:38 PM

not in the default code... but you can extend the widget your self...

by default:

    active: Active/Inactive

    archive: Active/Archive

    prod_environment: Product/Test

    by default : On/Off

via the option "terminology"

<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>


 Here a sample of code to do it... https://github.com/odoo-dev/odoo/commit/e43ec89ec5e6a4e2cc43bad31e3452f130210acb

Thank you. This is great. Looks perfect. I will try it out ASAP.

Matthew Watkins
on 8/25/16, 1:18 AM

Hi, I'm having a bit of difficulty using your example.

My code is:

odoo.define("custom_boolean_button.FieldBooleanButton", function (require) {

"use strict";

var form_widgets = require("web.form_widgets");


init: function() {

this._super.apply(this, arguments);

switch (this.options["terminology"]) {

case "active":

this.string_true = _t("Active");

this.hover_true = _t("Deactivate");

this.string_false = _t("Inactive");

this.hover_false = _t("Activate");


case "archive":

this.string_true = _t("Not Archived");

this.hover_true = _t("Archive");

this.string_false = _t("Archived");

this.hover_false = _t("Unarchive");


case "custom":

if (this.options["terminology_values"]) {

var terms = this.options["terminology_values"];

this.string_true = _t(terms.string_true); this.hover_true = _t(terms.hover_true);

this.string_false = _t(terms.string_false);

this.hover_false = _t(terms.hover_false);




this.string_true = _t("On");

this.hover_true = _t("Switch Off");

this.string_false = _t("Off");

this.hover_false = _t("Switch On");





I get the error:

TypeError: Cannot read property 'include' of undefined

Matthew Watkins
on 8/25/16, 11:39 AM
On 8/25/16, 1:09 AM
<field name="your_boolean_field" nolabel="1"/>
<label attrs="{'invisible':[('your_boolean_field', '=', False)]}">

<label attrs="{'invisible':[('Your_boolean_field','=',True)]}">

    Not Checked


Thanks for the reply. I'm sorry if I wasn't clear enough in my post. I'm actually looking for a way to change the strings displayed by the boolean_button widget. It has to be the widget because I'm using it to trigger a call to reload_on_button. I appreciate your reply, which would be otherwise totally workable.

Matthew Watkins
on 8/25/16, 1:15 AM

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

2 follower(s)


Asked: 8/24/16, 2:31 PM
Seen: 184 times
Last updated: 8/25/16, 2:34 AM