Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
2596 Vistas

hi , here is my code but it doesn't work  : 







 

JS : 

/** @odoo-module **/

import { ListController } from '@web/views/list/list_controller';
import { patch } from '@web/core/utils/patch';
import { useService } from '@web/core/utils/hooks';

patch(ListController.prototype, "bp_cdc"{
setup() {
this._super.apply();
this._action = useService("action");
},

btn_function() {
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"
});
}
});

Avatar
Descartar
Autor Mejor respuesta

I found the solution , there it is : 

/** @odoo-module **/

import { ListController } from '@web/views/list/list_controller';
import { patch } from '@web/core/utils/patch';
import { useService } from '@web/core/utils/hooks';

patch(ListController.prototype,{
setup() {
super.setup(...arguments);
this._action = useService("action");
},

btn_function() {
var archive_button = document.getElementById('display_archives');

if (archive_button.className == "btn btn-secondary") {
archive_button.className = "btn btn-primary";
} else {
archive_button.className = "btn btn-secondary";
}

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"
});
}
});

Avatar
Descartar
Mejor respuesta

Hi, you can follow this: https://youtu.be/MCEKCBA7zGk

Hope it helps,

Thanks

Avatar
Descartar
Mejor respuesta

Hi,

You can refer to our below blog to know how to add a button in tree view near Create button

https://www.cybrosys.com/blog/how-to-add-a-create-button-near-tree-and-kanban-view-in-odoo-16


Hope it helps

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
mar 24
921
0
mar 24
1436
0
mar 24
1251
4
may 25
8435
2
dic 24
5899