diff --git a/addons/event_sale/static/src/js/event_configurator_controller.js b/addons/event_sale/static/src/js/event_configurator_controller.js deleted file mode 100644 index 884a7067224..00000000000 --- a/addons/event_sale/static/src/js/event_configurator_controller.js +++ /dev/null @@ -1,38 +0,0 @@ -odoo.define('event.EventConfiguratorFormController', function (require) { -"use strict"; - -var FormController = require('web.FormController'); - -/** - * This controller is overridden to allow configuring sale_order_lines through a popup - * window when a product with 'detailed_type' == 'event' is selected. - * - * This allows keeping an editable list view for sales order and remove the noise of - * those 2 fields ('event_id' + 'event_ticket_id') - */ -var EventConfiguratorFormController = FormController.extend({ - /** - * We let the regular process take place to allow the validation of the required fields - * to happen. - * - * Then we can manually close the window, providing event information to the caller. - * - * @override - */ - saveRecord: function () { - var self = this; - return this._super.apply(this, arguments).then(function () { - var state = self.renderer.state.data; - self.do_action({type: 'ir.actions.act_window_close', infos: { - eventConfiguration: { - event_id: {id: state.event_id.data.id}, - event_ticket_id: {id: state.event_ticket_id.data.id} - } - }}); - }); - } -}); - -return EventConfiguratorFormController; - -}); diff --git a/addons/event_sale/static/src/js/event_configurator_model.js b/addons/event_sale/static/src/js/event_configurator_model.js new file mode 100644 index 00000000000..79995b110f5 --- /dev/null +++ b/addons/event_sale/static/src/js/event_configurator_model.js @@ -0,0 +1,43 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { formView } from "@web/views/form/form_view" +import { Record, RelationalModel } from "@web/views/relational_model"; + +/** + * This model is overridden to allow configuring sale_order_lines through a popup + * window when a product with 'detailed_type' == 'event' is selected. + * + * This allows keeping an editable list view for sales order and remove the noise of + * those 2 fields ('event_id' + 'event_ticket_id') + */ + +class EventConfiguratorRelationalModel extends RelationalModel {} + +class EventConfiguratorRecord extends Record { + + /** + * We let the regular process take place to allow the validation of the required fields + * to happen. + * + * Then we can manually close the window, providing event information to the caller. + * + * @override + */ + async save(options = {}) { + await super.save(options); + this.model.action.doAction({type: 'ir.actions.act_window_close', infos: { + eventConfiguration: { + event_id: {id: this.data.event_id[0]}, + event_ticket_id: {id: this.data.event_ticket_id[0]} + } + }}); + } +} + +EventConfiguratorRelationalModel.Record = EventConfiguratorRecord; + +registry.category("views").add("event_configurator_form", { + ...formView, + Model: EventConfiguratorRelationalModel, +}); diff --git a/addons/event_sale/static/src/js/event_configurator_view.js b/addons/event_sale/static/src/js/event_configurator_view.js deleted file mode 100644 index 67aebba4987..00000000000 --- a/addons/event_sale/static/src/js/event_configurator_view.js +++ /dev/null @@ -1,21 +0,0 @@ -odoo.define('event.EventConfiguratorFormView', function (require) { -"use strict"; - -var EventConfiguratorFormController = require('event.EventConfiguratorFormController'); -var FormView = require('web.FormView'); -var viewRegistry = require('web.view_registry'); - -/** - * @see EventConfiguratorFormController for more information - */ -var EventConfiguratorFormView = FormView.extend({ - config: _.extend({}, FormView.prototype.config, { - Controller: EventConfiguratorFormController - }), -}); - -viewRegistry.add('event_configurator_form', EventConfiguratorFormView); - -return EventConfiguratorFormView; - -});