Hi , so firtly i defined a basic button "btn-secondary" on my xml file and then i added this javascript function that call an action onclick , i want to change the text inside the button and change its color so it can look like primary btn once it's clicked :
/** @odoo-module **/
import { ListController } from '@web/views/list/list_controller';
import { patch } from '@web/core/utils/patch';
import { useService } from '@web/core/utils/hooks';
let isChecked = false;
function change_button_class() {
this.$el.find("#display_archives_button").removeClass("btn btn-secondary").addClass("btn btn-primary");
}
patch(ListController.prototype,{
setup() {
super.setup(...arguments);
this._action = useService("action");
this.isChecked = isChecked;
},
display_archives() {
change_button_class.call(this);
isChecked = !isChecked;
this.isChecked = isChecked;
if (this.isChecked == true){
this._action.doAction({
type: "ir.actions.act_window",
name: "Cahiers des charges archivés",
domain: [["jours_restants", "=", 0]],
views: [[false, "list"], [false, "form"]],
res_model: "bp.cdc",
target: 'self',
view_mode: "list,form"
});
}else if(this.isChecked == false){
this._action.doAction({
type: "ir.actions.act_window",
name: "Cahiers des charges en cours",
domain: [["jours_restants", "!=", 0]],
views: [[false, "list"], [false, "form"]],
res_model: "bp.cdc",
target: 'self',
view_mode: "list,form"
});
}
}
});