Help

2

how to change name of Archive and Unarchive to Delete and Restore in odoo10.?

Avatar
kundan

Actually i added active field for my custom table to achieve  Archive and Unarchive menu after export menu now i want to change string name Archive and Unarchive to Delete and Restore but field name is active only for Archive and Unachive and i m passing string inside active field but nothing is happening....How to achieve this solution.

Avatar
Discard
2 Semua Jawaban
1

Hi Kundan,

There are some values for options "terminology" you can use to show different labels on button.

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

For the options terminology, you can use either archive or active.

active: It will show "Active" or "Inactive" on a click of a button. On mouse hover, it will show "Deactivate" or "Activate" string on button.

archive: It will show "Active" or "Archived" on a click of a button. On mouse hover, it will show "Archive" or "Unarchive" string on button.

If you don't use "options" attribute, by default it shows, "On" or "Off" (mouse hover : "Switch Off" or "Switch On")

If you want to change the labels as per your requirement, then you have to override the JS (web/static/src/js/views/form_widgets.js : common.AbstractField.extend) function in your custom module.

Hope this will help you a bit.


Sudhir Arya
ERP Harbor Consulting Services
skype: sudhir@erpharbor.com  website: http://www.erpharbor.com
1 Komentar
Avatar
Discard
Avatar
LaLibreRie
-

Hi, are 'active' and 'archive' the only terminology options available ?

0
Avatar
Amarildo Golloshi
Best Answer

You can create new widget :

In js file:

/module/static/src/js/views/form_widget.js

odoo.define('your_module.form_widgets', function (require) {

"use strict";

var core = require('web.core');

var common = require('web.form_common');

var _t = core._t;

var QWeb = core.qweb;var Field_YourName_BooleanButton = common.AbstractField.extend({     

    className: 'o_stat_info',     

    init: function() {     

            this._super.apply(this, arguments);

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

                case "your_case":

                    this.string_true = _t("your_value");

                    this.hover_true = _t("your_value");

                    this.string_false = _t("your_value");

                    this.hover_false = _t("your");

                    break;

                default:

                    this.string_true = _t("On");

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

                    this.string_false = _t("Off");

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

        }

    },

    render_value: function() {

        this._super();

        this.$el.html(QWeb.render("BooleanButton", {widget: this})); },

    is_false: function() {

        return false;

    },

});

core.form_widget_registry

.add('your_name_boolean_button', Field_YourName_BooleanButton);

});

in xml file:

<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive">    
        <field         
            name="active"         
            widget="your_name_boolean_button"        
            options='{"terminology": "your_case"}'/>
</button>
Avatar
Discard