diff --git a/addons/event_booth_sale/models/event_booth_category.py b/addons/event_booth_sale/models/event_booth_category.py index 7c33c93f6fc..b20a222f2c4 100644 --- a/addons/event_booth_sale/models/event_booth_category.py +++ b/addons/event_booth_sale/models/event_booth_category.py @@ -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: diff --git a/addons/event_booth_sale/tests/__init__.py b/addons/event_booth_sale/tests/__init__.py index 93a5521bfb0..c57ff84235b 100644 --- a/addons/event_booth_sale/tests/__init__.py +++ b/addons/event_booth_sale/tests/__init__.py @@ -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 diff --git a/addons/event_booth_sale/tests/test_event_booth_sale.py b/addons/event_booth_sale/tests/test_event_booth_sale.py new file mode 100644 index 00000000000..9bc00b1d0e7 --- /dev/null +++ b/addons/event_booth_sale/tests/test_event_booth_sale.py @@ -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.") diff --git a/addons/website_event_booth_sale/__manifest__.py b/addons/website_event_booth_sale/__manifest__.py index 1e75fe9edcd..09fb1146d2f 100644 --- a/addons/website_event_booth_sale/__manifest__.py +++ b/addons/website_event_booth_sale/__manifest__.py @@ -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', } diff --git a/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js b/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js new file mode 100644 index 00000000000..8be1ee84e9b --- /dev/null +++ b/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js @@ -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 () {}, +}, +]); diff --git a/addons/website_event_booth_sale/tests/__init__.py b/addons/website_event_booth_sale/tests/__init__.py new file mode 100644 index 00000000000..63f5c3df649 --- /dev/null +++ b/addons/website_event_booth_sale/tests/__init__.py @@ -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 diff --git a/addons/website_event_booth_sale/tests/test_event_booth_sale.py b/addons/website_event_booth_sale/tests/test_event_booth_sale.py new file mode 100644 index 00000000000..25825397f9c --- /dev/null +++ b/addons/website_event_booth_sale/tests/test_event_booth_sale.py @@ -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': '

Standard

', + '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')