Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
2658 Visualizzazioni

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
Abbandona
Autore Risposta migliore

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
Abbandona
Risposta migliore

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

Hope it helps,

Thanks

Avatar
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
mar 24
986
0
mar 24
1471
0
mar 24
1270
4
mag 25
8593
2
dic 24
5988