Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion addons/event/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
from . import controllers
from . import models
from . import report
from . import tools
20 changes: 0 additions & 20 deletions addons/event/models/event_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def _default_question_ids(self):
('A4_french_fold', 'A4 foldable'),
('A6', 'A6'),
('four_per_sheet', '4 per sheet'),
('96x82', '96x82mm (Badge Printer)'),
], default='A6', required=True)
badge_image = fields.Image('Badge Background', max_width=1024, max_height=1024)
ticket_instructions = fields.Html('Ticket Instructions', translate=True,
Expand Down Expand Up @@ -858,22 +857,3 @@ def _gc_mark_events_done(self):
])
if ended_events:
ended_events.action_set_done()

def _get_event_timeframe_string(self):
self.ensure_one()
start_datetime = format_datetime(self.env, self.date_begin, self.date_tz, "short")
if self.is_one_day:
end_datetime = format_time(self.env, self.date_end, self.date_tz, "short")
else:
end_datetime = format_datetime(self.env, self.date_end, self.date_tz, "short")
return _("%(start_date)s to %(end_date)s", start_date=start_datetime, end_date=end_datetime)

def _get_event_print_details(self):
self.ensure_one()
return {
'name': self.name,
'badge_image': self.badge_image,
'timeframe': self._get_event_timeframe_string(),
'address': self.address_id.name if self.address_id else None,
'logo': self.company_id.logo,
}
33 changes: 0 additions & 33 deletions addons/event/models/event_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os

from odoo import _, api, fields, models, SUPERUSER_ID
from odoo.addons.event.tools.esc_label_tools import print_event_attendees, setup_printer, layout_96x82
from odoo.osv import expression
from odoo.tools import email_normalize, email_normalize_all, formataddr
from odoo.exceptions import AccessError, ValidationError
Expand Down Expand Up @@ -433,18 +432,6 @@ def _message_post_after_hook(self, message, msg_vals):

def _get_registration_summary(self):
self.ensure_one()
if self.event_id.badge_format == "96x82" and self.env.get("iot.device") is not None:
badge_printers = self.env["iot.device"].search([("subtype", "=", "label_printer")])
iot_printers = badge_printers.mapped(lambda printer: {
"id": printer.id,
"name": printer.name,
"identifier": printer.identifier,
"iotIdentifier": printer.iot_id.identifier,
"ip": printer.iot_id.ip,
"ipUrl": printer.iot_id.ip_url
})
else:
iot_printers = []
return {
'id': self.id,
'name': self.name,
Expand All @@ -455,25 +442,5 @@ def _get_registration_summary(self):
'event_display_name': self.event_id.display_name,
'registration_answers': self.registration_answer_ids.filtered('value_answer_id').mapped('display_name'),
'company_name': self.company_name,
'iot_printers': iot_printers,
'badge_format': self.event_id.badge_format
}

def _get_registration_print_details(self):
return {
'name': self.name,
'ticket_name': self.event_ticket_id.name if self.event_ticket_id else None,
'ticket_color': self.event_ticket_id.color if self.event_ticket_id else None,
'registration_answers': self.registration_answer_choice_ids.mapped('display_name'),
'company_name': self.company_name
}

def _generate_esc_label_badges(self):
command = setup_printer(layout_96x82)

attendees_per_event = self.grouped("event_id").items()
for (event, attendees) in attendees_per_event:
attendees_details = attendees.mapped(lambda attendee: attendee._get_registration_print_details())
command.concat(print_event_attendees(event._get_event_print_details(), attendees_details, layout_96x82))

return command.to_string()
11 changes: 0 additions & 11 deletions addons/event/report/event_event_reports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,6 @@
<field name="paperformat_id" ref="paperformat_event_badge"/>
</record>

<record id="action_report_event_registration_badge_96x82" model="ir.actions.report">
<field name="name">Badge (96x82mm)</field>
<field name="model">event.registration</field>
<field name="group_ids" eval="[Command.link(ref('base.group_no_one'))]"/>
<field name="report_type">qweb-text</field>
<field name="report_name">event.event_report_template_esc_label_96x82_badge</field>
<field name="report_file">event.event_report_template_esc_label_96x82_badge</field>
<field name="binding_model_id" ref="model_event_registration"/>
<field name="binding_type">report</field>
</record>

<record id="action_report_event_event_badge" model="ir.actions.report">
<field name="name">Badge Example</field>
<field name="model">event.event</field>
Expand Down
6 changes: 0 additions & 6 deletions addons/event/report/event_event_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@
</t>
</template>

<!-- EVENT ESC/LABEL 96x82mm -->

<template id="event_report_template_esc_label_96x82_badge">
<t t-esc="docs._generate_esc_label_badges()"/>
</template>

<!-- EVENT REGISTRATION BADGE - REDIRECTING TO EVENT FORMAT BADGE ABOVE -->

<template id="event_registration_report_template_badge">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ import { Component, onMounted, useState, useRef } from "@odoo/owl";
import { isBarcodeScannerSupported } from "@web/core/barcode/barcode_video_scanner";
import { Dialog } from "@web/core/dialog/dialog";
import { useService } from "@web/core/utils/hooks";
import { browser } from "@web/core/browser/browser";
import { _t } from "@web/core/l10n/translation";

const PRINT_SETTINGS_LOCAL_STORAGE_KEY = "event.registration_print_settings";
const DEFAULT_PRINT_SETTINGS = {
autoPrint: false,
iotPrinterId: null
};

export class EventRegistrationSummaryDialog extends Component {
static template = "event.EventRegistrationSummaryDialog";
Expand All @@ -27,32 +19,15 @@ export class EventRegistrationSummaryDialog extends Component {
this.isBarcodeScannerSupported = isBarcodeScannerSupported();
this.orm = useService("orm");
this.notification = useService("notification");
this.iotHttpService = useService("iot_http");
this.continueButtonRef = useRef("continueButton");

this.registrationStatus = useState({value: this.registration.status});
const storedPrintSettings = browser.localStorage.getItem(PRINT_SETTINGS_LOCAL_STORAGE_KEY);
this.printSettings = useState(storedPrintSettings ? JSON.parse(storedPrintSettings) : DEFAULT_PRINT_SETTINGS);
this.useIotPrinter = this.registration.iot_printers.length > 0;

if (this.useIotPrinter && !this.registration.iot_printers.map(printer => printer.id).includes(this.printSettings.iotPrinterId)) {
this.printSettings.iotPrinterId = null;
}

if (this.registration.iot_printers.length === 1) {
this.printSettings.iotPrinterId = this.registration.iot_printers[0].id;
}

this.dialogState = useState({ isHidden: this.willAutoPrint });

onMounted(() => {
if (['already_registered', 'need_manual_confirmation'].includes(this.props.registration.status) && this.props.playSound) {
this.props.playSound("notify");
} else if (['not_ongoing_event', 'canceled_registration'].includes(this.props.registration.status) && this.props.playSound) {
this.props.playSound("error");
} else if (this.willAutoPrint) {
this.onRegistrationPrintPdf()
.catch(() => { this.dialogState.isHidden = false; });
}
// Without this, repeat barcode scans don't work as focus is lost
this.continueButtonRef.el?.focus();
Expand All @@ -63,23 +38,10 @@ export class EventRegistrationSummaryDialog extends Component {
return this.props.registration;
}

get selectedPrinter() {
return this.registration.iot_printers.find(printer => printer.id === this.printSettings.iotPrinterId);
}

get needManualConfirmation() {
return this.registrationStatus.value === "need_manual_confirmation";
}

get willAutoPrint() {
return (
this.registration.status === "confirmed_registration" &&
this.printSettings.autoPrint &&
this.useIotPrinter &&
this.hasSelectedPrinter()
);
}

async onRegistrationConfirm() {
await this.orm.call("event.registration", "action_set_done", [this.registration.id]);
this.registrationStatus.value = "confirmed_registration";
Expand All @@ -105,19 +67,13 @@ export class EventRegistrationSummaryDialog extends Component {
}

async onRegistrationPrintPdf() {
if (this.useIotPrinter && this.printSettings.iotPrinterId) {
await this.printWithBadgePrinter();
} else {
await this.actionService.doAction({
type: "ir.actions.report",
report_type: "qweb-pdf",
report_name: `event.event_registration_report_template_badge/${this.registration.id}`,
});
}
await this.actionService.doAction({
type: "ir.actions.report",
report_type: "qweb-pdf",
report_name: `event.event_registration_report_template_badge/${this.registration.id}`,
});
if (this.props.doNextScan) {
this.onScanNext();
} else {
this.dialogState.isHidden = false;
}
}

Expand All @@ -138,32 +94,4 @@ export class EventRegistrationSummaryDialog extends Component {
this.props.doNextScan();
}
}

hasSelectedPrinter() {
return !this.useIotPrinter || this.printSettings.iotPrinterId != null;
}

savePrintSettings() {
browser.localStorage.setItem(PRINT_SETTINGS_LOCAL_STORAGE_KEY, JSON.stringify(this.printSettings));
}

async printWithBadgePrinter() {
const reportName = `event.event_report_template_esc_label_${this.registration.badge_format}_badge`;
const [{ id: reportId }] = await this.orm.searchRead("ir.actions.report", [["report_name", "=", reportName]], ["id"]);
const ticket_type = this.registration.ticket_name ? this.registration.ticket_name : '';

this.notification.add(
_t("'%(name)s' %(type)s badge sent to printer '%(printer)s'", {
name: this.registration.name,
type: ticket_type,
printer: this.selectedPrinter.name,
}),
{ type: "info" }
);
const [{ iot_box_ip, device_identifier, document }] = await this.orm.call(
"ir.actions.report", "render_document",
[reportId, [this.selectedPrinter], [this.registration.id], null],
);
this.iotHttpService.action(iot_box_ip, device_identifier, { document });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<templates xml:space="preserve">

<t t-name="event.EventRegistrationSummaryDialog" >
<Dialog t-if="!dialogState.isHidden" size="'md'" title.translate="Home">
<Dialog size="'md'" title.translate="Home">
<div class="row">
<div class="col-lg-10 w-100 fs-2">
<div t-if="['confirmed_registration', 'unconfirmed_registration'].includes(registrationStatus.value)" class="alert alert-success d-flex justify-content-center" role="alert">
Expand Down Expand Up @@ -61,21 +61,9 @@
</table>
</div>
</div>
<div class="d-flex justify-content-between">
<select t-if="useIotPrinter" type="select" class="form-select w-75" t-model.number="printSettings.iotPrinterId" t-on-change="savePrintSettings">
<option value="" disabled="true" t-att-selected="!printSettings.iotPrinterId">Select printer...</option>
<option t-foreach="registration.iot_printers" t-as="printer" t-key="printer.id" t-att-value="printer.id">
<t t-esc="printer.name" />
</option>
</select>
<div t-if="useIotPrinter" class="form-check">
<input id="autoprint" type="checkbox" class="form-check-input" t-model="printSettings.autoPrint" t-on-change="savePrintSettings"></input>
<label for="autoprint" class="form-check-label">Auto-Print</label>
</div>
</div>
<t t-set-slot="footer">
<button t-ref="continueButton" class="btn btn-primary" t-on-click="() => this.onRegistrationConfirm()">Continue</button>
<button t-att-disabled="!hasSelectedPrinter()" class="btn btn-primary" t-on-click="() => this.onRegistrationPrintPdf()">Print</button>
<button id="print_button" class="btn btn-primary" t-on-click="() => this.onRegistrationPrintPdf()">Print</button>
<button class="btn btn-secondary" t-on-click="() => this.onRegistrationView()">Edit</button>
</t>
</Dialog>
Expand Down
1 change: 0 additions & 1 deletion addons/event/tools/__init__.py

This file was deleted.

Loading