合并企业版代码(未测试,先提交到测试分支)
This commit is contained in:
62
mrp_workorder/static/src/views/form_view.js
Normal file
62
mrp_workorder/static/src/views/form_view.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
import { useViewButtons } from "@web/views/view_button/view_button_hook";
|
||||
import { useBus } from "@web/core/utils/hooks";
|
||||
|
||||
import { formView } from "@web/views/form/form_view";
|
||||
import { FormController } from "@web/views/form/form_controller";
|
||||
|
||||
const { useRef } = owl;
|
||||
|
||||
export class WorkorderFormController extends FormController {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.workorderBus = this.props.workorderBus;
|
||||
useBus(this.workorderBus, "force_save_workorder", async (ev) => {
|
||||
if (this.model.root.resModel === "mrp.workorder") {
|
||||
await this.model.root.save({ stayInEdition: true });
|
||||
ev.detail.resolve();
|
||||
}
|
||||
});
|
||||
useBus(this.workorderBus, "force_save_check", async (ev) => {
|
||||
if (this.model.root.resModel === "quality.check") {
|
||||
await this.model.root.save({ stayInEdition: true });
|
||||
ev.detail.resolve();
|
||||
}
|
||||
});
|
||||
const rootRef = useRef("root");
|
||||
// before executing button action
|
||||
const beforeExecuteAction = async (params) => {
|
||||
await this.model.root.save({ stayInEdition: true });
|
||||
if (params.type && params.type === "workorder_event") {
|
||||
this.workorderBus.trigger("workorder_event", params.name);
|
||||
return false;
|
||||
}
|
||||
if (this.model.root.resModel === "mrp.workorder") {
|
||||
if (this.model.root.data.current_quality_check_id) {
|
||||
await new Promise((resolve) =>
|
||||
this.workorderBus.trigger("force_save_check", { resolve })
|
||||
);
|
||||
}
|
||||
}
|
||||
if (this.model.root.resModel === "quality.check") {
|
||||
await new Promise((resolve) =>
|
||||
this.workorderBus.trigger("force_save_workorder", { resolve })
|
||||
);
|
||||
}
|
||||
};
|
||||
// after executing button action
|
||||
const reload = () => this.workorderBus.trigger("refresh");
|
||||
useViewButtons(this.model, rootRef, { beforeExecuteAction, reload });
|
||||
}
|
||||
}
|
||||
|
||||
WorkorderFormController.props = {
|
||||
...FormController.props,
|
||||
workorderBus: Object,
|
||||
};
|
||||
registry.category("views").add("workorder_form", {
|
||||
...formView,
|
||||
Controller: WorkorderFormController,
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { KanbanController } from '@web/views/kanban/kanban_controller';
|
||||
|
||||
export class MrpWorkorderKanbanController extends KanbanController {
|
||||
|
||||
setup() {
|
||||
super.setup();
|
||||
this.context = {};
|
||||
this.orm = useService('orm');
|
||||
}
|
||||
|
||||
actionBack() {
|
||||
this.actionService.doAction('mrp.mrp_workcenter_kanban_action', {
|
||||
clearBreadcrumbs: true,
|
||||
});
|
||||
}
|
||||
|
||||
async openRecord(record, mode) {
|
||||
const action = await this.orm.call(
|
||||
'mrp.workorder',
|
||||
'open_tablet_view',
|
||||
[record.resId],
|
||||
);
|
||||
Object.assign(action.context, this.context);
|
||||
this.actionService.doAction(action);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { kanbanView } from "@web/views/kanban/kanban_view";
|
||||
import { MrpWorkorderKanbanController } from "./mrp_workorder_kanban_controller";
|
||||
import { registry } from "@web/core/registry";
|
||||
|
||||
export const MrpWorkorderKanbanView = {
|
||||
...kanbanView,
|
||||
Controller: MrpWorkorderKanbanController,
|
||||
buttonTemplate: 'mrp_workorder.overviewButtonsKanban',
|
||||
};
|
||||
|
||||
registry.category("views").add('tablet_kanban_view', MrpWorkorderKanbanView);
|
||||
@@ -0,0 +1,11 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { ListController } from "@web/views/list/list_controller";
|
||||
|
||||
export class MrpWorkorderListController extends ListController {
|
||||
actionBack() {
|
||||
this.actionService.doAction("mrp.mrp_workcenter_kanban_action", {
|
||||
clearBreadcrumbs: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { listView } from "@web/views/list/list_view";
|
||||
import { MrpWorkorderListController } from "./mrp_workorder_list_controller";
|
||||
import { registry } from "@web/core/registry";
|
||||
|
||||
export const MrpWorkorderListView = {
|
||||
...listView,
|
||||
Controller: MrpWorkorderListController,
|
||||
buttonTemplate: "mrp_workorder.overviewButtonsList",
|
||||
};
|
||||
|
||||
registry.category("views").add("tablet_list_view", MrpWorkorderListView);
|
||||
21
mrp_workorder/static/src/views/xml/mrp_workorder_buttons.xml
Normal file
21
mrp_workorder/static/src/views/xml/mrp_workorder_buttons.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-name="mrp_workorder.overviewButtonsKanban" t-inherit="web.KanbanView.Buttons" t-inherit-mode="primary" owl="1">
|
||||
<xpath expr="(//div/*)[last()]" position="after">
|
||||
<div>
|
||||
<button t-on-click="actionBack" class="btn btn-secondary o_back_button">
|
||||
<i class="fa fa-arrow-left"/>
|
||||
</button>
|
||||
</div>
|
||||
</xpath>
|
||||
</t>
|
||||
<t t-name="mrp_workorder.overviewButtonsList" t-inherit="web.ListView.Buttons" t-inherit-mode="primary" owl="1">
|
||||
<xpath expr="(//div/*)[last()]" position="after">
|
||||
<div>
|
||||
<button t-on-click="actionBack" class="btn btn-secondary o_back_button">
|
||||
<i class="fa fa-arrow-left"/>
|
||||
</button>
|
||||
</div>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
Reference in New Issue
Block a user