跳至內容
選單
此問題已被標幟
3 回覆
2659 瀏覽次數

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

頭像
捨棄
作者 最佳答案

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

頭像
捨棄
最佳答案

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

Hope it helps,

Thanks

頭像
捨棄
最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
3月 24
986
0
3月 24
1471
0
3月 24
1270
4
5月 25
8593
2
12月 24
5988