[FW][FIX] (website_)event_booth_sale: add tests and test tour
PURPOSE Forward-port changed since this has been fixed properly in v15.0+ This commit adds the tests only and doesn't contain the fix as previously LINKS Task-2657480 Closes: odoo/odoo#89618 X-original-commit: 02932cb2e6ae43c414f222f27080ee7d265c5b39 Forward-port-of: #89277 Part-of: odoo/odoo#89744
This commit is contained in:
@@ -40,6 +40,7 @@ class EventBoothCategory(models.Model):
|
||||
if category.product_id and category.product_id.list_price:
|
||||
category.price = category.product_id.list_price + category.product_id.price_extra
|
||||
|
||||
@api.depends_context('pricelist', 'quantity')
|
||||
@api.depends('product_id', 'price')
|
||||
def _compute_price_reduce(self):
|
||||
for category in self:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_event_booth_sale
|
||||
from . import test_event_internals
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from odoo import Command, fields
|
||||
from odoo.addons.event_booth_sale.tests.common import TestEventBoothSaleCommon
|
||||
from odoo.addons.sales_team.tests.common import TestSalesCommon
|
||||
from odoo.tests.common import users
|
||||
from odoo.tools import float_compare
|
||||
|
||||
|
||||
class TestEventBoothSale(TestEventBoothSaleCommon, TestSalesCommon):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestEventBoothSale, cls).setUpClass()
|
||||
|
||||
cls.event_0 = cls.env['event.event'].create({
|
||||
'name': 'TestEvent',
|
||||
'auto_confirm': True,
|
||||
'date_begin': fields.Datetime.to_string(datetime.today() + timedelta(days=1)),
|
||||
'date_end': fields.Datetime.to_string(datetime.today() + timedelta(days=15)),
|
||||
'date_tz': 'Europe/Brussels',
|
||||
})
|
||||
|
||||
cls.booth_1 = cls.env['event.booth'].create({
|
||||
'name': 'Test Booth 1',
|
||||
'booth_category_id': cls.event_booth_category_1.id,
|
||||
'event_id': cls.event_0.id,
|
||||
})
|
||||
|
||||
cls.booth_2 = cls.env['event.booth'].create({
|
||||
'name': 'Test Booth 2',
|
||||
'booth_category_id': cls.event_booth_category_1.id,
|
||||
'event_id': cls.event_0.id,
|
||||
})
|
||||
|
||||
@users('user_sales_salesman')
|
||||
def test_event_booth_prices_with_sale_order(self):
|
||||
pricelist = self.env['product.pricelist'].sudo().create({
|
||||
'name': 'Test Pricelist',
|
||||
'currency_id': self.env.ref('base.USD').id,
|
||||
})
|
||||
sale_order = self.env['sale.order'].create({
|
||||
'partner_id': self.event_customer.id,
|
||||
'pricelist_id': pricelist.id,
|
||||
'order_line': [
|
||||
Command.create({
|
||||
'product_id': self.event_booth_product.id,
|
||||
'event_id': self.event_0.id,
|
||||
'event_booth_category_id': self.event_booth_category_1.id,
|
||||
'event_booth_pending_ids': (self.booth_1 + self.booth_2).ids
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
self.assertEqual(self.event_booth_product.list_price, self.booth_1.price,
|
||||
"Booth price should be equal from product price.")
|
||||
# Here we expect the price to be the sum of the booth ($40.0)
|
||||
self.assertEqual(float_compare(sale_order.amount_untaxed, 40.0, precision_rounding=0.1), 0,
|
||||
"Untaxed amount should be the sum of the booths prices.")
|
||||
|
||||
self.event_booth_category_1.write({'price': 100.0})
|
||||
sale_order.update_prices()
|
||||
|
||||
self.assertNotEqual(self.event_booth_product.list_price, self.booth_1.price,
|
||||
"Booth price should be different from product price.")
|
||||
# Here we expect the price to be the sum of the booth ($200.0)
|
||||
self.assertEqual(float_compare(sale_order.amount_untaxed, 200.0, precision_rounding=0.1), 0,
|
||||
"Untaxed amount should be the sum of the booths prices.")
|
||||
@@ -17,7 +17,10 @@ Use the e-commerce to sell your event booths.
|
||||
'assets': {
|
||||
'web.assets_frontend': [
|
||||
'/website_event_booth_sale/static/src/js/booth_register.js',
|
||||
]
|
||||
],
|
||||
'web.assets_tests': [
|
||||
'/website_event_booth_sale/static/tests/tours/website_event_booth.js',
|
||||
],
|
||||
},
|
||||
'license': 'LGPL-3',
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import tour from 'web_tour.tour';
|
||||
|
||||
tour.register('website_event_booth_tour', {
|
||||
test: true,
|
||||
url: '/event',
|
||||
}, [
|
||||
{
|
||||
content: 'Open "Test Event Booths" event',
|
||||
trigger: 'h5.card-title span:contains("Test Event Booths")',
|
||||
}, {
|
||||
content: 'Go to "Get A Booth" page',
|
||||
trigger: 'li.nav-item a:has(span:contains("Get A Booth"))',
|
||||
}, {
|
||||
content: 'Select the first two booths',
|
||||
trigger: '.o_wbooth_booths input[name="event_booth_ids"]',
|
||||
run: function () {
|
||||
$('.o_wbooth_booths input[name="event_booth_ids"]:lt(2)').click();
|
||||
},
|
||||
}, {
|
||||
content: 'Confirm the booths by clicking the submit button',
|
||||
trigger: 'button.o_wbooth_registration_submit',
|
||||
}, {
|
||||
content: 'Fill in your contact information',
|
||||
trigger: 'input[name="contact_name"]',
|
||||
run: function () {
|
||||
$('input[name="contact_name"]').val('John Doe');
|
||||
$('input[name="contact_email"]').val('jdoe@example.com');
|
||||
},
|
||||
}, {
|
||||
content: 'Submit your informations',
|
||||
trigger: 'button[type="submit"]',
|
||||
}, {
|
||||
content: 'Check if the price is correct',
|
||||
trigger: 'tr#order_total_untaxed .oe_currency_value:containsExact(200.00)',
|
||||
run: function () {},
|
||||
}, {
|
||||
content: 'Click confirm to continue',
|
||||
trigger: 'a[role="button"] span:contains("Confirm")',
|
||||
}, {
|
||||
content: 'Check if the price is correct',
|
||||
trigger: 'tr#order_total_untaxed .oe_currency_value:containsExact(200.00)',
|
||||
run: function () {},
|
||||
},
|
||||
]);
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_event_booth_sale
|
||||
@@ -0,0 +1,57 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from odoo import Command, fields
|
||||
from odoo.tests import HttpCase
|
||||
from odoo.tests.common import tagged
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestWebsiteEventBoothSale(HttpCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.booth_product = self.env['product.product'].create({
|
||||
'name': 'Test Booth Product',
|
||||
'description_sale': 'Mighty Booth Description',
|
||||
'list_price': 20,
|
||||
'standard_price': 60.0,
|
||||
'detailed_type': 'event_booth',
|
||||
})
|
||||
self.event_booth_category = self.env['event.booth.category'].create({
|
||||
'name': 'Standard',
|
||||
'description': '<p>Standard</p>',
|
||||
'product_id': self.booth_product.id,
|
||||
'price': 100.0,
|
||||
})
|
||||
self.event_type = self.env['event.type'].create({
|
||||
'name': 'Booth Type',
|
||||
'event_type_booth_ids': [
|
||||
Command.create({
|
||||
'name': 'Standard 1',
|
||||
'booth_category_id': self.event_booth_category.id,
|
||||
}),
|
||||
Command.create({
|
||||
'name': 'Standard 2',
|
||||
'booth_category_id': self.event_booth_category.id,
|
||||
}),
|
||||
Command.create({
|
||||
'name': 'Standard 3',
|
||||
'booth_category_id': self.event_booth_category.id,
|
||||
}),
|
||||
],
|
||||
})
|
||||
self.env['event.event'].create({
|
||||
'name': 'Test Event Booths',
|
||||
'event_type_id': self.event_type.id,
|
||||
'date_begin': fields.Datetime.to_string(datetime.today() + timedelta(days=1)),
|
||||
'date_end': fields.Datetime.to_string(datetime.today() + timedelta(days=15)),
|
||||
'website_published': True,
|
||||
'website_menu': True,
|
||||
'booth_menu': True,
|
||||
})
|
||||
|
||||
def test_tour(self):
|
||||
self.start_tour('/event', 'website_event_booth_tour', login='portal')
|
||||
Reference in New Issue
Block a user