89 lines
3.3 KiB
JavaScript
89 lines
3.3 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()
|
|
// if you override willStart(), don't forget to call super.willStart()
|
|
// if you override destroy(), don't forget to call super.destroy()
|
|
|
|
async setup() {
|
|
super.setup();
|
|
// console.log('99999999111');
|
|
this.workOrders = await this.getAllWorkOrders();
|
|
// this.workOrdersNew = this.workOrders;
|
|
// console.log('lines222222222', this.workOrders);
|
|
// console.log(typeof this.workOrders);
|
|
// console.log(Array.isArray(this.workOrders));
|
|
// console.log(this.workOrders.every(order =>
|
|
// typeof order === 'object' && order.id !== undefined));
|
|
// var aDiv = document.getElementsByClassName('o_kanban_record')
|
|
// for (var i = 0; i < aDiv.length; i++) {
|
|
// console.log(aDiv[i])
|
|
// }
|
|
// console.log(aDiv)
|
|
}
|
|
|
|
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) => {
|
|
// console.log(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);
|
|
location.reload();
|
|
window.onload = function () {
|
|
button.classList.add('choose');
|
|
};
|
|
});
|
|
});
|
|
}
|
|
|
|
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);
|