Initial commit: Sale packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:49 +02:00
commit 14e3d26998
6469 changed files with 2479670 additions and 0 deletions

View file

@ -0,0 +1,47 @@
/** @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_booth' is selected.
*
* This allows keeping an editable list view for sales order and remove the noise of
* those 3 fields ('event_id', 'event_booth_category_id' and 'event_booth_ids')
*/
class EventBoothConfiguratorRelationalModel extends RelationalModel {}
class EventBoothConfiguratorRecord extends Record {
//--------------------------------------------------------------------------
// Overrides
//--------------------------------------------------------------------------
async save() {
const isSaved = await super.save(...arguments);
if (!isSaved) {
return false;
}
this.model.action.doAction({type: 'ir.actions.act_window_close', infos: {
eventBoothConfiguration: {
event_id: this.data.event_id,
event_booth_category_id: this.data.event_booth_category_id,
event_booth_pending_ids: {
operation: 'MULTI',
commands: [{
operation: 'REPLACE_WITH',
ids: this.data.event_booth_ids.currentIds,
}],
}
}
}});
return true;
}
}
EventBoothConfiguratorRelationalModel.Record = EventBoothConfiguratorRecord;
registry.category("views").add("event_booth_configurator_form", {
...formView,
Model: EventBoothConfiguratorRelationalModel,
});

View file

@ -0,0 +1,72 @@
/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { SaleOrderLineProductField } from '@sale/js/sale_product_field';
patch(SaleOrderLineProductField.prototype, 'event_booth_sale', {
async _onProductUpdate() {
this._super(...arguments);
if (this.props.record.data.product_type === 'event_booth') {
this._openEventBoothConfigurator(false);
}
},
_editLineConfiguration() {
this._super(...arguments);
if (this.props.record.data.product_type === 'event_booth') {
this._openEventBoothConfigurator(true);
}
},
get isConfigurableLine() {
return this._super(...arguments) || Boolean(this.props.record.data.event_booth_category_id);
},
async _openEventBoothConfigurator(edit) {
let actionContext = {
default_product_id: this.props.record.data.product_id[0],
};
if (edit) {
const recordData = this.props.record.data;
if (recordData.event_id) {
actionContext.default_event_id = recordData.event_id[0];
}
if (recordData.event_booth_category_id) {
actionContext.default_event_booth_category_id = recordData.event_booth_category_id[0];
}
if (recordData.event_booth_pending_ids) {
actionContext.default_event_booth_ids = recordData.event_booth_pending_ids.records.map(
record => {
return [4, record.data.id];
}
);
}
}
this.action.doAction(
'event_booth_sale.event_booth_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 eventBoothConfiguration = closeInfo.eventBoothConfiguration;
this.props.record.update({
event_id: eventBoothConfiguration.event_id,
event_booth_category_id: eventBoothConfiguration.event_booth_category_id,
event_booth_pending_ids: eventBoothConfiguration.event_booth_pending_ids,
});
}
}
}
);
},
});