Debian Codegraph @

addons/lunch/static/src/mixins/lunch_renderer_mixin.js

raw symbols SCIP
1 import { _t } from "@web/core/l10n/translation";
2 import { useBus, useService } from "@web/core/utils/hooks";
3
4 export const LunchRendererMixin = (T) => class LunchRendererMixin extends T {
5 setup() {
6 super.setup(...arguments);
7
8 this.action = useService("action");
9 useBus(this.env.bus, 'lunch_open_order', (ev) => this.openOrderLine(ev.detail.productId));
10 }
11
12 openOrderLine(productId, orderId) {
13 let context = {};
14
15 if (this.env.searchModel.lunchState.userId) {
16 context['default_user_id'] = this.env.searchModel.lunchState.userId;
17 }
18 if (this.env.searchModel.lunchState.date) {
19 context['default_date'] = this.env.searchModel.lunchState.date;
20 }
21 if (this.env.searchModel.lunchState.locationId) {
22 context['default_lunch_location_id'] = this.env.searchModel.lunchState.locationId;
23 }
24
25 let action = {
26 res_model: 'lunch.order',
27 name: _t('Configure Your Order'),
28 type: 'ir.actions.act_window',
29 views: [[false, 'form']],
30 target: 'new',
31 context: {
32 ...context,
33 default_product_id: productId,
34 },
35 };
36
37 if (orderId) {
38 action['res_id'] = orderId;
39 }
40
41 this.action.doAction(action, {
42 onClose: () => this.env.bus.trigger('lunch_update_dashboard')
43 });
44 }
45 };