Skip to content

Commit

Permalink
[MIG] website_event_sale_b2x_alt_price: Migration to version 17.0
Browse files Browse the repository at this point in the history
TT51967
  • Loading branch information
pilarvargas-tecnativa committed Dec 11, 2024
1 parent 782f575 commit 10aeb09
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 85 deletions.
1 change: 1 addition & 0 deletions website_event_sale_b2x_alt_price/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Contributors
- Jairo Llopis
- Carlos Roca
- David Vidal
- Pilar Vargas

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion website_event_sale_b2x_alt_price/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Online event ticket sales with alternative prices",
"summary": "Display alt. price (B2B for B2C websites, and viceversa)",
"version": "15.0.1.1.0",
"version": "17.0.1.0.0",
"development_status": "Beta",
"category": "Website",
"website": "https://github.com/OCA/event",
Expand Down
3 changes: 2 additions & 1 deletion website_event_sale_b2x_alt_price/models/event_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class EventEventTicket(models.Model):

def _get_ticket_combination_info(self):
"""Imitate product.template's _get_combination_info()."""
website = self.env["website"].get_current_website(fallback=False)
# Obtain the inverse field of the normal b2b/b2c behavior
alt_field = (
"total_included"
if self.env.user.has_group("account.group_show_line_subtotals_tax_excluded")
if website.show_line_subtotals_tax_selection == "tax_excluded"
else "total_excluded"
)
price, alt_price = self.price_reduce, self.price_reduce_taxinc
Expand Down
1 change: 1 addition & 0 deletions website_event_sale_b2x_alt_price/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
- Jairo Llopis
- Carlos Roca
- David Vidal
- Pilar Vargas
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Jairo Llopis</li>
<li>Carlos Roca</li>
<li>David Vidal</li>
<li>Pilar Vargas</li>
</ul>
</li>
</ul>
Expand Down
60 changes: 29 additions & 31 deletions website_event_sale_b2x_alt_price/static/src/js/b2b.esm.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
/** @odoo-module */

/* Copyright 2022 Carlos Roca - Tecnativa
Copyright 2021 Tecnativa - David Vidal
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
*/
import tour from "web_tour.tour";

export const steps = [
{
trigger: "a:has(span:contains('Test Event One Ticket'))",
},
{
trigger: "a[href='/event']",
extra_trigger:
".o_wevent_registration_single:has(span[data-oe-field='price_reduce']:contains('100.0')):has(span.js_alt_price:contains('122.00')):has(h6:contains('Test Ticket'))",
},
{
trigger: "a:has(span:contains('Test Event More Tickets'))",
},
{
trigger:
"#o_wevent_tickets_collapse > div:has(span[data-oe-field='price_reduce']:contains('100.00')):has(span.js_alt_price:contains('122.00')):has(h5:contains('Test Ticket 1'))",
},
{
trigger:
"#o_wevent_tickets_collapse > div:has(span[data-oe-field='price_reduce']:contains('100.00')):not(:has(span.js_alt_price)):has(h5:contains('Test Ticket 2'))",
},
];
import {registry} from "@web/core/registry";
import wsTourUtils from "@website_sale/js/tours/tour_utils";

tour.register(
"website_event_sale_b2x_alt_price_b2b",
{
test: true,
url: "/event",
},
steps
);
registry.category("web_tour.tours").add("website_event_sale_b2x_alt_price_b2b", {
test: true,
url: "/event",
steps: () => [
{
content: "Open the Test Event One Ticket event page",
trigger: '.o_wevent_events_list a:contains("Test Event One Ticket")',
},
{
content: "Open the register modal",
trigger: 'button:contains("Register")',
},
{
extra_trigger:
".o_wevent_registration_single:has(span[data-oe-field='price_reduce']:contains('100.00')):has(span.js_alt_price:contains('122.00'))",
trigger: '.btn-primary.o_wait_lazy_js:contains("Register")',
},
{
content: "Validate attendees details",
extra_trigger:
"input[name*='1-name'], input[name*='2-name'], input[name*='3-name']",
trigger: 'button[type=submit]:contains("Go to Payment")',
},
wsTourUtils.goToCart({quantity: 1}),
],
});
60 changes: 29 additions & 31 deletions website_event_sale_b2x_alt_price/static/src/js/b2c.esm.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
/** @odoo-module */

/* Copyright 2022 Carlos Roca - Tecnativa
Copyright 2021 Tecnativa - David Vidal
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
*/
import tour from "web_tour.tour";

export const steps = [
{
trigger: "a:has(span:contains('Test Event One Ticket'))",
},
{
trigger: "a[href='/event']",
extra_trigger:
".o_wevent_registration_single:has(span[data-oe-field='price_reduce_taxinc']:contains('122.0')):has(span.js_alt_price:contains('100.00')):has(h6:contains('Test Ticket'))",
},
{
trigger: "a:has(span:contains('Test Event More Tickets'))",
},
{
trigger:
"#o_wevent_tickets_collapse > div:has(span[data-oe-field='price_reduce_taxinc']:contains('122.00')):has(span.js_alt_price:contains('100.00')):has(h5:contains('Test Ticket 1'))",
},
{
trigger:
"#o_wevent_tickets_collapse > div:has(span[data-oe-field='price_reduce_taxinc']:contains('100.00')):not(:has(span.js_alt_price)):has(h5:contains('Test Ticket 2'))",
},
];
import {registry} from "@web/core/registry";
import wsTourUtils from "@website_sale/js/tours/tour_utils";

tour.register(
"website_event_sale_b2x_alt_price_b2c",
{
test: true,
url: "/event",
},
steps
);
registry.category("web_tour.tours").add("website_event_sale_b2x_alt_price_b2c", {
test: true,
url: "/event",
steps: () => [
{
content: "Open the Test Event One Ticket event page",
trigger: '.o_wevent_events_list a:contains("Test Event One Ticket")',
},
{
content: "Open the register modal",
trigger: 'button:contains("Register")',
},
{
extra_trigger:
".o_wevent_registration_single:has(span[data-oe-field='price_reduce_taxinc']:contains('122.00')):has(span.js_alt_price:contains('100.00'))",
trigger: '.btn-primary.o_wait_lazy_js:contains("Register")',
},
{
content: "Validate attendees details",
extra_trigger:
"input[name*='1-name'], input[name*='2-name'], input[name*='3-name']",
trigger: 'button[type=submit]:contains("Go to Payment")',
},
wsTourUtils.goToCart({quantity: 1}),
],
});
51 changes: 33 additions & 18 deletions website_event_sale_b2x_alt_price/templates/website_event_sale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,61 @@
<data>
<template
id="registration_template"
inherit_id="website_event_sale.registration_template"
inherit_id="website_event_sale.modal_ticket_registration"
>
<!-- Add the website_sale_b2x_alt_price.alt_price when more than 1 types of tickets -->
<xpath
expr="//div[hasclass('o_wevent_registration_multi_select')]//span[@itemprop='price']"
position="before"
>
<p class="text-muted small" t-call="website_sale_b2x_alt_price.alt_price">
<br />
<span
class="text-muted small"
t-call="website_sale_b2x_alt_price.alt_price"
>
<t
t-set="combination_info"
t-value="ticket._get_ticket_combination_info()"
/>
</p>
<t t-set="price" t-value="combination_info['price']" />
<t t-set="alt_price" t-value="combination_info['alt_price']" />
<t
t-set="alt_list_price"
t-value="combination_info['alt_list_price']"
/>
<t
t-set="has_discounted_price"
t-value="combination_info['has_discounted_price']"
/>
<t t-set="alt_field" t-value="combination_info['alt_field']" />
</span>
</xpath>
<!-- Add the website_sale_b2x_alt_price.alt_price when only 1 ticket -->
<xpath
expr="//div[hasclass('o_wevent_registration_single')]//span[@itemprop='price']"
position="before"
>
<p
class="text-muted small mb-0"
<br />
<span
class="text-muted small"
t-call="website_sale_b2x_alt_price.alt_price"
>
<t
t-set="combination_info"
t-value="tickets._get_ticket_combination_info()"
/>
</p>
</xpath>
<!-- Display correctly on website -->
<xpath
expr="//div[hasclass('o_wevent_registration_single')]//t[@t-if='tickets.price']/.."
position="attributes"
>
<attribute
name="class"
separator=" "
add="flex-column"
remove="align-self-stretch"
/>
<t t-set="price" t-value="combination_info['price']" />
<t t-set="alt_price" t-value="combination_info['alt_price']" />
<t
t-set="alt_list_price"
t-value="combination_info['alt_list_price']"
/>
<t
t-set="has_discounted_price"
t-value="combination_info['has_discounted_price']"
/>
<t t-set="alt_field" t-value="combination_info['alt_field']" />
</span>
</xpath>
</template>

Expand Down
4 changes: 1 addition & 3 deletions website_event_sale_b2x_alt_price/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ def setUp(self):
product_form.name = "Test Product Event Without Taxes"
product_form.lst_price = 100
product_form.detailed_type = "event"
product_form.type = "service"
self.product_without_taxes = product_form.save()
self.product_without_taxes.taxes_id = False
product_form = Form(self.env["product.product"])
product_form.name = "Test Product Event With Taxes"
product_form.lst_price = 100
product_form.detailed_type = "event"
product_form.type = "service"
self.product_with_taxes = product_form.save()
self.product_with_taxes.taxes_id = self.tax_22_sale
event_form = Form(self.env["event.event"])
Expand Down Expand Up @@ -84,7 +82,7 @@ def _switch_tax_mode(self, mode):

def test_ui_website_b2b(self):
"""Test frontend b2b tour."""
UICase._switch_tax_mode(self, "tax_excluded")
self._switch_tax_mode("tax_excluded")
self.start_tour(
"/event",
"website_event_sale_b2x_alt_price_b2b",
Expand Down

0 comments on commit 10aeb09

Please sign in to comment.