Debian Codegraph @

addons/event_sale/static/src/js/event_configurator_controller.js

raw
1 import { registry } from "@web/core/registry";
2 import { useService } from "@web/core/utils/hooks";
3 import { formView } from "@web/views/form/form_view";
4
5 /**
6 * This controller is overridden to allow configuring sale_order_lines through a popup
7 * window when a service product linked to events is selected.
8 *
9 * This allows keeping an editable list view for sales order and remove the noise of
10 * those 3 fields ('event_id' + 'event_slot_id' + 'event_ticket_id')
11 */
12
13 export class EventConfiguratorController extends formView.Controller {
14 setup() {
15 super.setup();
16 this.action = useService("action");
17 }
18
19 /**
20 * We let the regular process take place to allow the validation of the required fields
21 * to happen.
22 *
23 * Then we can manually close the window, providing event information to the caller.
24 *
25 * @override
26 */
27 async onRecordSaved(record) {
28 await super.onRecordSaved(...arguments);
29 const { event_id, event_slot_id, event_ticket_id } = record.data;
30 return this.action.doAction({
31 type: "ir.actions.act_window_close",
32 infos: {
33 eventConfiguration: {
34 event_id,
35 event_slot_id,
36 event_ticket_id,
37 },
38 },
39 });
40 }
41 }
42
43 registry.category("views").add("event_configurator_form", {
44 ...formView,
45 Controller: EventConfiguratorController,
46 });