Skip to Content
Menu
This question has been flagged
3 Replies
2358 Views

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
Discard
Author Best Answer

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
Discard
Best Answer

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

Hope it helps,

Thanks

Avatar
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
0
Mar 24
746
0
Mar 24
1243
0
Mar 24
977
4
May 25
7770
2
Dec 24
5418