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 committed Oct 23, 2024
1 parent a3b871b commit 902baee
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 129 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"],
}
13 changes: 11 additions & 2 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)
.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,
"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(
Expand All @@ -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")

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.

Original file line number Diff line number Diff line change
@@ -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("[email protected]");
},
},
{
content: "Validate attendees details",
extra_trigger: "input[name='1-phone']",
trigger: 'button:contains("Confirm")',
},
{
Expand All @@ -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
},
},
]);
],
});
30 changes: 1 addition & 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,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(
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
1 change: 0 additions & 1 deletion portal_event_tickets/views/event_registration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<xpath expr="//sheet/*[1]" position="before">
<!-- put it before first element in the form -->
<p
attrs="{'invisible': [('is_transferring', '=', False)]}"
style="color: red"
>Ticket transferring was started, but haven't finished!</p>
</xpath>
Expand Down
40 changes: 19 additions & 21 deletions portal_event_tickets/views/portal_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
t-if="ticket.event_id.ticket_transferring"
role="button"
class="btn btn-primary btn-block mb8"
data-toggle="modal"
data-target="#transferTicketModal"
data-bs-toggle="modal"
data-bs-target="#transferTicketModal"
href="#"
>
<i class="fa fa-exchange" />
Expand All @@ -121,8 +121,8 @@
<a
t-if="ticket.event_id.ticket_transferring"
role="button"
data-toggle="modal"
data-target="#changeTicketModal"
data-bs-toggle="modal"
data-bs-target="#changeTicketModal"
href="#"
class="btn btn-primary btn-block mb8"
>
Expand Down Expand Up @@ -164,7 +164,7 @@
class="modal fade"
id="transferTicketModal"
tabindex="-1"
role="dialog"
role="modal"
aria-labelledby="myModalLabel"
>
<div class="modal-dialog" role="document">
Expand All @@ -181,18 +181,17 @@
t-att-value="ticket.id"
/>
<div class="modal-header">
<h4
class="modal-title"
id="myModalLabel"
>Ticket transferring</h4>
<button
type="button"
class="close"
data-dismiss="modal"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&amp;times;</span>
</button>
<h4
class="modal-title"
id="myModalLabel"
>Ticket transferring</h4>
</div>
<div class="modal-body">
<div class="form-group">
Expand All @@ -213,7 +212,7 @@
<button
type="button"
class="btn btn-default"
data-dismiss="modal"
data-bs-dismiss="modal"
>Close</button>
<button
type="submit"
Expand Down Expand Up @@ -246,18 +245,17 @@
t-att-value="ticket.id"
/>
<div class="modal-header">
<h4
class="modal-title"
id="myModalLabel"
>Upgrade / change ticket</h4>
<button
type="button"
class="close"
data-dismiss="modal"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&amp;times;</span>
</button>
<h4
class="modal-title"
id="myModalLabel"
>Upgrade / change ticket</h4>
</div>
<div class="modal-body">
<p
Expand All @@ -268,7 +266,7 @@
<button
type="button"
class="btn btn-default"
data-dismiss="modal"
data-bs-dismiss="modal"
>Close</button>
<button
type="submit"
Expand Down

0 comments on commit 902baee

Please sign in to comment.