实现基础的rpc拿取后端生产线数据功能

This commit is contained in:
mgw
2023-08-03 17:24:37 +08:00
parent 1afd164712
commit 810ef41c05
4 changed files with 90 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
/** @odoo-module */
import { KanbanController } from "@web/views/kanban/kanban_controller";
import { kanbanView } from "@web/views/kanban/kanban_view";
import { registry } from "@web/core/registry";
// the controller usually contains the Layout and the renderer.
class CustomKanbanController extends KanbanController {
// Your logic here, override or insert new methods...
// if you override setup(), don't forget to call super.setup()
async setup() {
super.setup();
console.log('99999999111');
this.workOrders = await this.getAllWorkOrders();
console.log('lines', this.workOrders);
}
async getAllWorkOrders() {
const response = await this.env.services.rpc('/web/dataset/call_kw',{
model: 'sf.production.line',
method: 'search_read',
args: [],
kwargs: {},
});
console.log('response', response);
// 你可以在这里处理响应,例如将其存储在控制器的状态中
return response;
}
}
CustomKanbanController.template = "sf_manufacturing.CustomKanbanView1";
export const customKanbanView = {
...kanbanView, // contains the default Renderer/Controller/Model
Controller: CustomKanbanController,
};
// Register it to the views registry
registry.category("views").add("custom_kanban1", customKanbanView);