[IMP] event_sale: migrate configurator form to owl
closes odoo/odoo#101083 X-original-commit: 9cf190a461bd864c0e1972f458d6fbe5ac8ed814 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
});
|
||||
@@ -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,
|
||||
});
|
||||
@@ -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;
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user