Se rendre au contenu
Menu
Cette question a été signalée
3 Réponses
2662 Vues

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
Ignorer
Auteur Meilleure réponse

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
Ignorer
Meilleure réponse

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

Hope it helps,

Thanks

Avatar
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
0
mars 24
988
0
mars 24
1472
0
mars 24
1271
4
mai 25
8604
2
déc. 24
5990