diff --git a/portal_event_tickets/__manifest__.py b/portal_event_tickets/__manifest__.py index 0df8c80..887a8e9 100644 --- a/portal_event_tickets/__manifest__.py +++ b/portal_event_tickets/__manifest__.py @@ -12,7 +12,6 @@ "portal", "partner_event", "website_event_sale", - "website_event_attendee_fields", "website_sale_refund", ], "data": [ @@ -20,8 +19,15 @@ "views/event_registration.xml", "views/event_event.xml", "data/mail_template_data.xml", - "views/assets.xml", ], + "assets": { + "web.assets_frontend": [ + "/portal_event_tickets/static/src/js/portal.esm.js", + ], + "web.assets_tests": [ + "/portal_event_tickets/static/src/js/ticket_transfer.tour.esm.js", + ], + }, "qweb": [], "demo": ["data/res_users_demo.xml"], } diff --git a/portal_event_tickets/controllers/main.py b/portal_event_tickets/controllers/main.py index 5754854..36bf8e8 100644 --- a/portal_event_tickets/controllers/main.py +++ b/portal_event_tickets/controllers/main.py @@ -145,13 +145,13 @@ def portal_get_ticket(self, ticket_id=None, **kw): registration_badge_template = ( report_template_for_portal.get_metadata()[0].get("xmlid") if report_template_for_portal - else "event.report_event_registration_badge" + else "event.action_report_event_registration_badge" ) pdf = ( - request.env.ref(registration_badge_template) + request.env["ir.actions.report"] .with_user(SUPERUSER_ID) - ._render_qweb_pdf([ticket.id])[0] + ._render_qweb_pdf(registration_badge_template, [ticket.id])[0] ) pdfhttpheaders = [ @@ -277,12 +277,20 @@ def ticket_transfer_receive(self, transfer_ticket=None, **kw): tickets = WebsiteEventController()._process_tickets_form( ticket.event_id, {f"nb_register-{ticket.event_ticket_id.id or 0}": 1} ) + default_first_attendee = {} + if ticket.attendee_partner_id: + default_first_attendee = { + "name": ticket.attendee_partner_id.name, + "phone": ticket.attendee_partner_id.phone, + "email": ticket.attendee_partner_id.email, + } values.update( { "transfer_ticket": ticket, "tickets": tickets, "event": ticket.event_id, "availability_check": True, + "default_first_attendee": default_first_attendee, } ) return request.render( @@ -297,7 +305,6 @@ def ticket_transfer_receive(self, transfer_ticket=None, **kw): )[0] registration["event_id"] = ticket.event_id.id partner_vals = request.env["event.registration"]._prepare_partner(registration) - assert not partner_vals.get("email") receiver.sudo().write(partner_vals) diff --git a/portal_event_tickets/static/src/js/portal.esm.js b/portal_event_tickets/static/src/js/portal.esm.js new file mode 100644 index 0000000..1718a61 --- /dev/null +++ b/portal_event_tickets/static/src/js/portal.esm.js @@ -0,0 +1,34 @@ +/** @odoo-module **/ + +import publicWidget from "@web/legacy/js/public/public_widget"; + +publicWidget.registry.TransferTicketWidget = publicWidget.Widget.extend({ + selector: "#transfer_ticket", + + async willStart() { + await this._super(...arguments); + + const event_name = this.$el.data("event-name"); + const $modal = $("#modal_attendees_registration"); + + /* Show form inline */ + $modal.find("form").attr("action", "/my/tickets/transfer/receive"); + $modal.removeClass("modal fade"); + + /* Remove Cancel button; update title */ + var $submit = $modal.find("[type=submit]"); + $submit.parent().empty().append($submit); + $submit.text("Confirm"); + + /* Remove Close button */ + $modal.find(".close").remove(); + + /* Make email non-editable */ + $modal.find("[name=1-email]").attr("disabled", "1"); + + /* Update title */ + $modal + .find("h4.modal-title") + .html("Receive the ticket for " + event_name + ""); + }, +}); diff --git a/portal_event_tickets/static/src/js/portal.js b/portal_event_tickets/static/src/js/portal.js deleted file mode 100644 index c8491cc..0000000 --- a/portal_event_tickets/static/src/js/portal.js +++ /dev/null @@ -1,37 +0,0 @@ -odoo.define("portal_event_tickets.portal", function (require) { - "use strict"; - - var publicWidget = require("web.public.widget"); - - publicWidget.registry.transferTicketWidget = publicWidget.Widget.extend({ - selector: "#transfer_ticket", - - start: function () { - var def = this._super.apply(this, arguments); - - var event_name = this.$el.data("event-name"); - var $modal = $("#modal_attendees_registration"); - - /* Show form inline */ - $modal.find("form").attr("action", "/my/tickets/transfer/receive"); - $modal.removeClass("modal fade"); - - /* Remove Cancel button; update title */ - var $submit = $modal.find("[type=submit]"); - $submit.parent().empty().append($submit); - $submit.text("Confirm"); - - /* Remove Close button */ - $modal.find(".close").remove(); - - /* Make email non-editable */ - $modal.find("[name=1-email]").attr("disabled", "1"); - - /* Update title */ - $modal - .find("h4.modal-title") - .html("Receive the ticket for " + event_name + ""); - return def; - }, - }); -}); diff --git a/portal_event_tickets/static/src/js/ticket_transfer.tour.esm.js b/portal_event_tickets/static/src/js/ticket_transfer.tour.esm.js new file mode 100644 index 0000000..4709640 --- /dev/null +++ b/portal_event_tickets/static/src/js/ticket_transfer.tour.esm.js @@ -0,0 +1,30 @@ +/** @odoo-module **/ + +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("ticket_transfer_receive", { + test: true, + url: "/my/tickets/transfer/receive", + steps: () => [ + { + content: "Fill attendees details", + trigger: "input[type='email']", + run: function () { + // Fill: + // * phone (optional) + $("input[name^='1-phone']").val("111 111"); + }, + }, + { + content: "Validate attendees details", + trigger: 'button:contains("Confirm")', + }, + { + content: "We are redirected to /my/tickets page", + trigger: ".breadcrumb-item:contains(Tickets)", + run: function () { + // It's needed to don't make a click on the link + }, + }, + ], +}); diff --git a/portal_event_tickets/static/src/js/ticket_transfer.tour.js b/portal_event_tickets/static/src/js/ticket_transfer.tour.js deleted file mode 100644 index 7e1194f..0000000 --- a/portal_event_tickets/static/src/js/ticket_transfer.tour.js +++ /dev/null @@ -1,40 +0,0 @@ -odoo.define("portal_event_tickets.ticket_transfer_tour", function (require) { - "use strict"; - - var tour = require("web_tour.tour"); - - var options = { - test: true, - url: "/my/tickets/transfer/receive", - }; - - var tour_name = "ticket_transfer_receive"; - tour.register(tour_name, options, [ - { - content: "Fill attendees details", - extra_trigger: "input[name='1-function']", - trigger: "input[name='1-name']", - run: function () { - // Fill: - // * phone (optional) - // * country_id (mandatory) - // skip: - // * job position (optional) - $("input[name='1-phone']").val("111 111"); - $("select[name='1-country_id']").val("1"); - }, - }, - { - content: "Validate attendees details", - extra_trigger: "input[name='1-phone']", - trigger: 'button:contains("Confirm")', - }, - { - content: "We are redirected to /my/tickets page", - trigger: ".breadcrumb-item:contains(Tickets)", - run: function () { - // It's needed to don't make a click on the link - }, - }, - ]); -}); diff --git a/portal_event_tickets/tests/common.py b/portal_event_tickets/tests/common.py index 9863eb8..2afef6d 100644 --- a/portal_event_tickets/tests/common.py +++ b/portal_event_tickets/tests/common.py @@ -29,34 +29,6 @@ def setUp(self): {"event_id": self.event.id} ) - self.event.write( - { - "attendee_field_ids": [ - ( - 6, - 0, - [ - self.env.ref( - "website_event_attendee_fields.attendee_field_name" - ).id, - self.env.ref( - "website_event_attendee_fields.attendee_field_email" - ).id, - self.env.ref( - "website_event_attendee_fields.attendee_field_phone" - ).id, - self.env.ref( - "website_event_attendee_fields.attendee_field_country_id" - ).id, - self.env.ref( - "website_event_attendee_fields.attendee_field_function" - ).id, - ], - ) - ] - } - ) - # create Portal User self.user_portal1 = self.env.ref("portal_event_tickets.user_portal1") @@ -79,7 +51,6 @@ def _create_ticket(self, ticket_type, partner, event): "note": "Invoice after delivery", } ) - sale_order.onchange_partner_id() # In the sale order I add some sale order lines. i choose event product sale_order_line = self.env["sale.order.line"].create( diff --git a/portal_event_tickets/views/assets.xml b/portal_event_tickets/views/assets.xml deleted file mode 100644 index fd7a11a..0000000 --- a/portal_event_tickets/views/assets.xml +++ /dev/null @@ -1,20 +0,0 @@ - - -