Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
1408 Zobrazení
simple javascript not calling in odoo.
its work in console
want to set update the label

odoo.define('aretx_product_pricelist.custom', function (require) {
"use strict";

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

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

var test = $('.form-check-label').text('newText');
$('html body .form-check-label').text('newText123');
$('.form-check-label').text('newText123');
$('html .form-check-label').text('newText123');
$('body .form-check-label').text('newText132');

});

above code are working on chorme developer console but when i put in odoo js does not work simply i want to inherit the view and change the label file locate is odoo16/addons/product/staic/src/xml/price_report.xml





want to change this label checkbox so please tell me how to do that
Avatar
Zrušit
Nejlepší odpověď

However, manipulating the DOM directly using jQuery might not be the recommended approach in Odoo, as Odoo follows a more declarative approach using QWeb templates.


To change the label of a checkbox in Odoo, you should override the specific QWeb template associated with the view. In your case, you want to change the label of a checkbox in the price_report.xml file.


Here's an example of how you can override the label using Odoo JavaScript and QWeb:


odoo.define('your_module.custom_price_report', function (require) {
    "use strict";

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

    var QWeb = core.qweb;

    FieldOne2Many.include({
        _renderEdit: function () {
            this._super.apply(this, arguments);

            // Override the label text
            this.$('.o_field_many2manytags_checkbox label').text('New Label');
        },
    });
});


In this example, we are using the FieldOne2Many widget to override the rendering behavior of a One2Many field. We are using the _renderEdit method to change the label text.


Please replace 'your_module.custom_price_report' with the actual module name you are using. Also, make sure to adjust the selector according to the structure of your checkbox label.


Remember to check the Odoo version and the structure of the template in your specific version, as they might vary. Additionally, always test changes in a safe environment before applying them to a production system.

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
kvě 25
2133
1
dub 25
3212
1
dub 25
4019
1
dub 25
1520
4
bře 25
6503