Skip to content

Commit

Permalink
[MIG] portal_event_tickets: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
azimkhankuat authored and em230418 committed Oct 31, 2024
1 parent 42ed7e1 commit 2b0ab44
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 178 deletions.
10 changes: 8 additions & 2 deletions portal_event_tickets/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@
"portal",
"partner_event",
"website_event_sale",
"website_event_attendee_fields",
"website_sale_refund",
],
"data": [
"views/portal_templates.xml",
"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"],
}
15 changes: 11 additions & 4 deletions portal_event_tickets/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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(
Expand All @@ -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)

Expand Down
34 changes: 34 additions & 0 deletions portal_event_tickets/static/src/js/portal.esm.js
Original file line number Diff line number Diff line change
@@ -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 <b>" + event_name + "</b>");
},
});
37 changes: 0 additions & 37 deletions portal_event_tickets/static/src/js/portal.js

This file was deleted.

30 changes: 30 additions & 0 deletions portal_event_tickets/static/src/js/ticket_transfer.tour.esm.js
Original file line number Diff line number Diff line change
@@ -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
},
},
],
});
40 changes: 0 additions & 40 deletions portal_event_tickets/static/src/js/ticket_transfer.tour.js

This file was deleted.

29 changes: 0 additions & 29 deletions portal_event_tickets/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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(
Expand Down
20 changes: 0 additions & 20 deletions portal_event_tickets/views/assets.xml

This file was deleted.

2 changes: 1 addition & 1 deletion portal_event_tickets/views/event_event.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<xpath expr="//field[@name='tag_ids']" position="after">
<field name="report_template_for_portal" groups="base.group_no_one" />
</xpath>
<xpath expr="//field[@name='auto_confirm']" position="before">
<xpath expr="//field[@name='badge_format']" position="before">
<field name="ticket_transferring" />
<field name="ticket_changing" />
</xpath>
Expand Down
3 changes: 2 additions & 1 deletion portal_event_tickets/views/event_registration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
</xpath>
<xpath expr="//sheet/*[1]" position="before">
<!-- put it before first element in the form -->
<field name="is_transferring" invisible="1" />
<p
attrs="{'invisible': [('is_transferring', '=', False)]}"
invisible="is_transferring == False"
style="color: red"
>Ticket transferring was started, but haven't finished!</p>
</xpath>
Expand Down
Loading

0 comments on commit 2b0ab44

Please sign in to comment.