Files
jikimo_sf/sf_manufacturing/static/src/js/kanban_change.js

74 lines
2.4 KiB
JavaScript

/** @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);
}
buttonClick(ev) {
const button = ev.currentTarget;
const id = button.getAttribute('data-id');
console.log('true_id', id);
const context = {production_line_show: 'shengchanxian1'}
this.env.services.rpc('/web/dataset/call_kw', {
model: 'mrp.workcenter',
method: 'search_read',
args: [[], ['id']],
kwargs: {}
}).then((records) => {
const ids = records.map(record => record.id);
const context = {production_line_show: id};
this.env.services.rpc('/web/dataset/call_kw', {
model: 'mrp.workcenter',
method: 'write',
args: [ids, context],
kwargs: {}
}).then((response) => {
console.log('response', response);
});
});
}
async getAllWorkOrders() {
const response = await this.env.services.rpc('/web/dataset/call_kw',{
model: 'sf.production.line',
method: 'search_read',
args: [],
kwargs: {},
});
// const response1 = await this.env.services.rpc('/web/dataset/call_kw',{
// model: 'mrp.workcenter',
// method: 'search_read',
// args: [],
// kwargs: {},
// });
console.log('response', response);
// console.log('response1', response1);
// 你可以在这里处理响应,例如将其存储在控制器的状态中
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);