From 902baeeafc262b4b1e2c006e157151bc2c7ff706 Mon Sep 17 00:00:00 2001 From: Kuat Azimkhan Date: Wed, 23 Oct 2024 16:15:18 +0500 Subject: [PATCH] [MIG] portal_event_tickets: Migration to 17.0 --- portal_event_tickets/__manifest__.py | 10 ++++- portal_event_tickets/controllers/main.py | 13 +++++- .../static/src/js/portal.esm.js | 34 ++++++++++++++++ portal_event_tickets/static/src/js/portal.js | 37 ----------------- ...er.tour.js => ticket_transfer.tour.esm.js} | 27 +++++-------- portal_event_tickets/tests/common.py | 30 +------------- portal_event_tickets/views/assets.xml | 20 ---------- portal_event_tickets/views/event_event.xml | 2 +- .../views/event_registration.xml | 1 - .../views/portal_templates.xml | 40 +++++++++---------- 10 files changed, 85 insertions(+), 129 deletions(-) create mode 100644 portal_event_tickets/static/src/js/portal.esm.js delete mode 100644 portal_event_tickets/static/src/js/portal.js rename portal_event_tickets/static/src/js/{ticket_transfer.tour.js => ticket_transfer.tour.esm.js} (53%) delete mode 100644 portal_event_tickets/views/assets.xml 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..5fdde2c 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) .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, + "country_id": ticket.attendee_partner_id.country_id.id, + } values.update( { "transfer_ticket": ticket, "tickets": tickets, "event": ticket.event_id, "availability_check": True, + "default_first_attendee": default_first_attendee, } ) return request.render( @@ -296,6 +304,7 @@ def ticket_transfer_receive(self, transfer_ticket=None, **kw): ticket.event_id, kw )[0] registration["event_id"] = ticket.event_id.id + registration.pop("email", None) partner_vals = request.env["event.registration"]._prepare_partner(registration) assert not partner_vals.get("email") 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.js b/portal_event_tickets/static/src/js/ticket_transfer.tour.esm.js similarity index 53% rename from portal_event_tickets/static/src/js/ticket_transfer.tour.js rename to portal_event_tickets/static/src/js/ticket_transfer.tour.esm.js index 7e1194f..654157d 100644 --- a/portal_event_tickets/static/src/js/ticket_transfer.tour.js +++ b/portal_event_tickets/static/src/js/ticket_transfer.tour.esm.js @@ -1,32 +1,27 @@ -odoo.define("portal_event_tickets.ticket_transfer_tour", function (require) { - "use strict"; +/** @odoo-module **/ - var tour = require("web_tour.tour"); +import {registry} from "@web/core/registry"; - var options = { - test: true, - url: "/my/tickets/transfer/receive", - }; - - var tour_name = "ticket_transfer_receive"; - tour.register(tour_name, options, [ +registry.category("web_tour.tours").add("ticket_transfer_receive", { + test: true, + url: "/my/tickets/transfer/receive", + steps: () => [ { content: "Fill attendees details", - extra_trigger: "input[name='1-function']", - trigger: "input[name='1-name']", + trigger: "input[type='email']", 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"); + // $("input[name='1-phone']").val("111 111"); + // $("select[name='1-country_id']").val("1"); + $("input[type='email']").val("test@test.com"); }, }, { content: "Validate attendees details", - extra_trigger: "input[name='1-phone']", trigger: 'button:contains("Confirm")', }, { @@ -36,5 +31,5 @@ odoo.define("portal_event_tickets.ticket_transfer_tour", function (require) { // 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..3b00d7f 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,7 @@ def _create_ticket(self, ticket_type, partner, event): "note": "Invoice after delivery", } ) - sale_order.onchange_partner_id() + # 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 @@ - - -