mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-26 13:52:05 +02:00
Initial commit: Sale packages
This commit is contained in:
commit
14e3d26998
6469 changed files with 2479670 additions and 0 deletions
|
|
@ -0,0 +1,46 @@
|
|||
/** @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')
|
||||
*/
|
||||
|
||||
export class EventConfiguratorRelationalModel extends RelationalModel {}
|
||||
|
||||
export 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() {
|
||||
const isSaved = await super.save(...arguments);
|
||||
if (!isSaved) {
|
||||
return false;
|
||||
}
|
||||
this.model.action.doAction({type: 'ir.actions.act_window_close', infos: {
|
||||
eventConfiguration: {
|
||||
event_id: this.data.event_id,
|
||||
event_ticket_id: this.data.event_ticket_id,
|
||||
}
|
||||
}});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
EventConfiguratorRelationalModel.Record = EventConfiguratorRecord;
|
||||
|
||||
registry.category("views").add("event_configurator_form", {
|
||||
...formView,
|
||||
Model: EventConfiguratorRelationalModel,
|
||||
});
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { SaleOrderLineProductField } from '@sale/js/sale_product_field';
|
||||
|
||||
|
||||
patch(SaleOrderLineProductField.prototype, 'event_sale', {
|
||||
|
||||
async _onProductUpdate() {
|
||||
this._super(...arguments);
|
||||
if (this.props.record.data.product_type === 'event') {
|
||||
this._openEventConfigurator();
|
||||
}
|
||||
},
|
||||
|
||||
_editLineConfiguration() {
|
||||
this._super(...arguments);
|
||||
if (this.props.record.data.product_type === 'event') {
|
||||
this._openEventConfigurator();
|
||||
}
|
||||
},
|
||||
|
||||
get isConfigurableLine() {
|
||||
return this._super(...arguments) || Boolean(this.props.record.data.event_ticket_id);
|
||||
},
|
||||
|
||||
async _openEventConfigurator() {
|
||||
let actionContext = {
|
||||
'default_product_id': this.props.record.data.product_id[0],
|
||||
};
|
||||
if (this.props.record.data.event_id) {
|
||||
actionContext.default_event_id = this.props.record.data.event_id[0];
|
||||
}
|
||||
if (this.props.record.data.event_ticket_id) {
|
||||
actionContext.default_event_ticket_id = this.props.record.data.event_ticket_id[0];
|
||||
}
|
||||
this.action.doAction(
|
||||
'event_sale.event_configurator_action',
|
||||
{
|
||||
additionalContext: actionContext,
|
||||
onClose: async (closeInfo) => {
|
||||
if (!closeInfo || closeInfo.special) {
|
||||
// wizard popup closed or 'Cancel' button triggered
|
||||
if (!this.props.record.data.event_ticket_id) {
|
||||
// remove product if event configuration was cancelled.
|
||||
this.props.record.update({
|
||||
[this.props.name]: undefined,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const eventConfiguration = closeInfo.eventConfiguration;
|
||||
this.props.record.update(eventConfiguration);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue