[FIX] pos*: fix test without demo data

pos*: pos_online_payment, pos_sale, pos_self_order

Prior to this commit, different tests were using the demo data
to run which was causing problems when the demo data were not installed.
In this commit, we add products, categories, floor, table, etc. at the
setup of the test so that the test can run without demo data.

X-original-commit: 6ef51b11f7f67a1f17225541cb2341a178a98aad
Part-of: odoo/odoo#142212
This commit is contained in:
Adrien Guilliams (adgu)
2023-12-01 15:51:51 +00:00
parent 357cbb8bd0
commit 72d4e2e759
17 changed files with 243 additions and 109 deletions
+6 -6
View File
@@ -303,12 +303,12 @@ class PosConfig(models.Model):
if pm.journal_id and pm.journal_id.currency_id and pm.journal_id.currency_id != config.currency_id:
raise ValidationError(_("All payment methods must be in the same currency as the Sales Journal or the company currency if that is not set."))
if any(self.available_pricelist_ids.mapped(lambda pricelist: pricelist.currency_id != self.currency_id)):
raise ValidationError(_("All available pricelists must be in the same currency as the company or"
" as the Sales Journal set on this point of sale if you use"
" the Accounting application."))
if self.invoice_journal_id.currency_id and self.invoice_journal_id.currency_id != self.currency_id:
raise ValidationError(_("The invoice journal must be in the same currency as the Sales Journal or the company currency if that is not set."))
if config.use_pricelist and config.pricelist_id and any(config.available_pricelist_ids.mapped(lambda pricelist: pricelist.currency_id != config.currency_id)):
raise ValidationError(_("All available pricelists must be in the same currency as the company or"
" as the Sales Journal set on this point of sale if you use"
" the Accounting application."))
if config.invoice_journal_id.currency_id and config.invoice_journal_id.currency_id != config.currency_id:
raise ValidationError(_("The invoice journal must be in the same currency as the Sales Journal or the company currency if that is not set."))
@api.constrains('iface_start_categ_id', 'iface_available_categ_ids')
def _check_start_categ(self):
@@ -63,6 +63,9 @@ export class NumberPopup extends AbstractAwaitablePopup {
this.inputRef.el.focus();
}
}
get decimalSeparator() {
return this.env.services.localization.decimalPoint;
}
getNumpadButtons() {
const { isPassword, cheap } = this.props;
return [
@@ -80,7 +83,7 @@ export class NumberPopup extends AbstractAwaitablePopup {
...(!isPassword ? [{ value: "-" }] : []),
{ value: "Delete", text: "C" },
{ value: "0" },
...(!isPassword ? [{ value: this.env.services.localization.decimalPoint }] : []),
...(!isPassword ? [{ value: this.decimalSeparator }] : []),
{ value: "Backspace", text: "⌫" },
];
}
@@ -111,7 +111,7 @@ registry.category("web_tour.tours").add("ChromeTour", {
// Invoice an order
ProductScreen.addOrderline("Whiteboard Pen", "5", "6"),
ProductScreen.clickPartnerButton(),
ProductScreen.clickCustomer("Nicole Ford"),
ProductScreen.clickCustomer("Partner Test 1"),
ProductScreen.clickPayButton(),
PaymentScreen.clickPaymentMethod("Bank"),
PaymentScreen.clickInvoiceButton(),
@@ -217,7 +217,7 @@ registry.category("web_tour.tours").add("PaymentScreenRoundingHalfUpCashAndBank"
ProductScreen.clickHomeCategory(),
ProductScreen.addOrderline("Product Test 40", "1"),
ProductScreen.clickPartnerButton(),
ProductScreen.clickCustomer("Nicole Ford"),
ProductScreen.clickCustomer("Partner Test 1"),
ProductScreen.clickPayButton(),
PaymentScreen.totalIs("40.00"),
@@ -238,7 +238,7 @@ registry.category("web_tour.tours").add("PaymentScreenRoundingHalfUpCashAndBank"
ProductScreen.clickHomeCategory(),
ProductScreen.addOrderline("Product Test 41", "1"),
ProductScreen.clickPartnerButton(),
ProductScreen.clickCustomer("Nicole Ford"),
ProductScreen.clickCustomer("Partner Test 1"),
ProductScreen.clickPayButton(),
PaymentScreen.totalIs("41.00"),
@@ -62,13 +62,13 @@ registry.category("web_tour.tours").add("ProductScreenTour", {
ProductScreen.orderIsEmpty(),
// Check different subcategories
ProductScreen.clickSubcategory("Desks"),
ProductScreen.clickSubcategory("Desk test"),
ProductScreen.productIsDisplayed("Desk Pad"),
ProductScreen.clickHomeCategory(),
ProductScreen.clickSubcategory("Misc"),
ProductScreen.clickSubcategory("Misc test"),
ProductScreen.productIsDisplayed("Whiteboard Pen"),
ProductScreen.clickHomeCategory(),
ProductScreen.clickSubcategory("Chairs"),
ProductScreen.clickSubcategory("Chair test"),
ProductScreen.productIsDisplayed("Letter Tray"),
ProductScreen.clickHomeCategory(),
@@ -115,18 +115,18 @@ registry.category("web_tour.tours").add("OrderPaidInCash", {
].flat(),
});
registry
.category("web_tour.tours")
.add("ReceiptTrackingMethodTour", {
test: true,
url: "/pos/ui",
steps: () => [
registry.category("web_tour.tours").add("ReceiptTrackingMethodTour", {
test: true,
url: "/pos/ui",
steps: () =>
[
ProductScreen.confirmOpeningPopup(),
ProductScreen.clickHomeCategory(),
ProductScreen.clickDisplayedProduct('Product A'),
ProductScreen.enterLotNumber('123456789'),
ProductScreen.clickDisplayedProduct("Product A"),
ProductScreen.enterLotNumber("123456789"),
ProductScreen.clickPayButton(),
PaymentScreen.clickPaymentMethod('Cash'),
PaymentScreen.clickPaymentMethod("Cash"),
PaymentScreen.clickValidate(),
ReceiptScreen.trackingMethodIsLot(),
].flat(),
});
});
@@ -40,19 +40,19 @@ registry.category("web_tour.tours").add("TicketScreenTour", {
TicketScreen.clickDiscard(),
ProductScreen.addOrderline("Desk Pad", "1", "2"),
ProductScreen.clickPartnerButton(),
ProductScreen.clickCustomer("Nicole Ford"),
ProductScreen.clickCustomer("Partner Test 1"),
Chrome.clickMenuButton(),
Chrome.clickTicketButton(),
TicketScreen.nthRowContains(2, "Nicole Ford", false),
TicketScreen.nthRowContains(2, "Partner Test 1", false),
TicketScreen.clickNewTicket(),
ProductScreen.addOrderline("Desk Pad", "1", "3"),
ProductScreen.clickPartnerButton(),
ProductScreen.clickCustomer("Brandon Freeman"),
ProductScreen.clickCustomer("Partner Test 2"),
ProductScreen.clickPayButton(),
PaymentScreen.isShown(),
Chrome.clickMenuButton(),
Chrome.clickTicketButton(),
TicketScreen.nthRowContains(3, "Brandon Freeman", false),
TicketScreen.nthRowContains(3, "Partner Test 2", false),
TicketScreen.clickNewTicket(),
ProductScreen.addOrderline("Desk Pad", "2", "4"),
ProductScreen.clickPayButton(),
@@ -70,12 +70,12 @@ registry.category("web_tour.tours").add("TicketScreenTour", {
TicketScreen.nthRowContains(2, "Ongoing"),
TicketScreen.selectFilter("All active orders"),
TicketScreen.nthRowContains(4, "Receipt"),
TicketScreen.search("Customer", "Nicole"),
TicketScreen.nthRowContains(2, "Nicole", false),
TicketScreen.search("Customer", "Brandon"),
TicketScreen.nthRowContains(2, "Brandon", false),
TicketScreen.search("Receipt Number", "-0005"),
TicketScreen.nthRowContains(2, "Receipt"),
TicketScreen.search("Customer", "Partner Test 1"),
TicketScreen.nthRowContains(2, "Partner Test 1", false),
TicketScreen.search("Customer", "Partner Test 2"),
TicketScreen.nthRowContains(2, "Partner Test 2", false),
// Close the TicketScreen to see the current order which is in ReceiptScreen.
// This is just to remove the search string in the search bar.
TicketScreen.clickDiscard(),
@@ -103,7 +103,7 @@ registry.category("web_tour.tours").add("TicketScreenTour", {
Chrome.clickMenuButton(),
Chrome.clickTicketButton(),
TicketScreen.selectFilter("Paid"),
TicketScreen.nthRowContains(2, "Brandon Freeman", false),
TicketScreen.nthRowContains(2, "Partner Test 2", false),
TicketScreen.nthRowContains(3, "-0005"),
// Invoice order
TicketScreen.selectOrder("-0005"),
@@ -111,10 +111,10 @@ registry.category("web_tour.tours").add("TicketScreenTour", {
TicketScreen.clickControlButton("Invoice"),
Chrome.confirmPopup(),
PartnerListScreen.isShown(),
PartnerListScreen.clickPartner("Colleen Diaz"),
PartnerListScreen.clickPartner("Partner Test 3"),
TicketScreen.invoicePrinted(),
TicketScreen.clickBackToMainTicketScreen(),
TicketScreen.partnerIs("Colleen Diaz"),
TicketScreen.partnerIs("Partner Test 3"),
// Reprint receipt
TicketScreen.clickControlButton("Print Receipt"),
ReceiptScreen.isShown(),
@@ -130,7 +130,7 @@ registry.category("web_tour.tours").add("TicketScreenTour", {
// Filter should be automatically 'Paid'.
TicketScreen.filterIs("Paid"),
TicketScreen.selectOrder("-0005"),
TicketScreen.partnerIs("Colleen Diaz"),
TicketScreen.partnerIs("Partner Test 3"),
inLeftSide(Order.hasLine({ productName: "Desk Pad", withClass: ".selected" })),
ProductScreen.pressNumpad("3"),
// Error should show because 2 is more than the number
+7
View File
@@ -11,6 +11,13 @@ import logging
_logger = logging.getLogger(__name__)
def archive_products(env):
# Archive all existing product to avoid noise during the tours
all_pos_product = env['product.product'].search([('available_in_pos', '=', True)])
discount = env.ref('point_of_sale.product_product_consumable')
tip = env.ref('point_of_sale.product_product_tip')
(all_pos_product - discount - tip)._write({'active': False})
class TestPointOfSaleCommon(ValuationReconciliationTestCommon):
@classmethod
@@ -77,7 +77,7 @@ def setup_pos_combo_items(self):
}
)
desk_accessories_combo = self.env["pos.combo"].create(
self.desk_accessories_combo = self.env["pos.combo"].create(
{
"name": "Desk Accessories Combo",
"combo_line_ids": [
@@ -128,7 +128,7 @@ def setup_pos_combo_items(self):
}
)
desks_combo = self.env["pos.combo"].create(
self.desks_combo = self.env["pos.combo"].create(
{
"name": "Desks Combo",
"combo_line_ids": [
@@ -188,7 +188,7 @@ def setup_pos_combo_items(self):
}
)
chairs_combo = self.env["pos.combo"].create(
self.chairs_combo = self.env["pos.combo"].create(
{
"name": "Chairs Combo",
"combo_line_ids": [
@@ -206,19 +206,17 @@ def setup_pos_combo_items(self):
)
# Create Office Combo
office_combo = self.env["product.product"].create(
self.office_combo = self.env["product.product"].create(
{
"available_in_pos": True,
"list_price": 40,
"name": "Office Combo",
"type": "combo",
"categ_id": self.env.ref("product.product_category_5").id,
"categ_id": self.env.ref("product.product_category_1").id,
"uom_id": self.env.ref("uom.product_uom_unit").id,
"uom_po_id": self.env.ref("uom.product_uom_unit").id,
"combo_ids": [
(6, 0, [desks_combo.id, chairs_combo.id, desk_accessories_combo.id])
(6, 0, [self.desks_combo.id, self.chairs_combo.id, self.desk_accessories_combo.id])
],
}
)
return office_combo
+32 -27
View File
@@ -7,6 +7,7 @@ from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
from odoo.addons.account.tests.common import AccountTestInvoicingHttpCommon
from odoo.addons.point_of_sale.tests.common_setup_methods import setup_pos_combo_items
from datetime import date, timedelta
from odoo.addons.point_of_sale.tests.common import archive_products
import odoo.tests
@@ -89,20 +90,19 @@ class TestPointOfSaleHttpCommon(AccountTestInvoicingHttpCommon):
'sequence': 10,
})
# Archive all existing product to avoid noise during the tours
all_pos_product = env['product.product'].search([('available_in_pos', '=', True)])
discount = env.ref('point_of_sale.product_product_consumable')
archive_products(env)
cls.tip = env.ref('point_of_sale.product_product_tip')
(all_pos_product - discount - cls.tip)._write({'active': False})
# In DESKS categ: Desk Pad
pos_categ_desks = env.ref('point_of_sale.pos_category_desks')
# In DESKS categ: Whiteboard Pen
pos_categ_misc = env.ref('point_of_sale.pos_category_miscellaneous')
# In CHAIR categ: Letter Tray
pos_categ_chairs = env.ref('point_of_sale.pos_category_chairs')
pos_desk_misc_test = env['pos.category'].create({
'name': 'Misc test',
})
pos_cat_chair_test = env['pos.category'].create({
'name': 'Chair test',
})
pos_cat_desk_test = env['pos.category'].create({
'name': 'Desk test',
})
# test an extra price on an attribute
cls.whiteboard_pen = env['product.product'].create({
@@ -112,7 +112,7 @@ class TestPointOfSaleHttpCommon(AccountTestInvoicingHttpCommon):
'taxes_id': False,
'weight': 0.01,
'to_weight': True,
'pos_categ_ids': [(4, pos_categ_misc.id)],
'pos_categ_ids': [(4, pos_desk_misc_test.id)],
})
cls.wall_shelf = env['product.product'].create({
'name': 'Wall Shelf Unit',
@@ -146,14 +146,14 @@ class TestPointOfSaleHttpCommon(AccountTestInvoicingHttpCommon):
'available_in_pos': True,
'list_price': 1.98,
'taxes_id': False,
'pos_categ_ids': [(4, pos_categ_desks.id)],
'pos_categ_ids': [(4, pos_cat_desk_test.id)],
})
cls.letter_tray = env['product.product'].create({
'name': 'Letter Tray',
'available_in_pos': True,
'list_price': 4.80,
'taxes_id': False,
'pos_categ_ids': [(4, pos_categ_chairs.id)],
'pos_categ_ids': [(4, pos_cat_chair_test.id)],
})
cls.desk_organizer = env['product.product'].create({
'name': 'Desk Organizer',
@@ -505,6 +505,11 @@ class TestPointOfSaleHttpCommon(AccountTestInvoicingHttpCommon):
'available_pricelist_ids': [(4, pricelist.id) for pricelist in all_pricelists],
})
# Set customers
cls.partner_test_1 = cls.env['res.partner'].create({'name': 'Partner Test 1'})
cls.partner_test_2 = cls.env['res.partner'].create({'name': 'Partner Test 2'})
cls.partner_test_3 = cls.env['res.partner'].create({'name': 'Partner Test 3'})
# Change the default sale pricelist of customers,
# so the js tests can expect deterministically this pricelist when selecting a customer.
env['ir.property']._set_default("property_product_pricelist", "res.partner", public_pricelist, main_company)
@@ -747,8 +752,8 @@ class TestUi(TestPointOfSaleHttpCommon):
'only_round_cash_method': True
})
self.main_pos_config.open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenRoundingHalfUpCashAndBank', login="accountman")
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenRoundingHalfUpCashAndBank', login="pos_user")
invoiced_orders = self.env['pos.order'].search([('state', '=', 'invoiced')])
self.assertEqual(len(invoiced_orders), 2, 'There should be 2 invoiced orders.')
@@ -867,8 +872,8 @@ class TestUi(TestPointOfSaleHttpCommon):
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'ReceiptScreenDiscountWithPricelistTour', login="pos_user")
def test_07_pos_combo(self):
combo_product = setup_pos_combo_items(self)
combo_product.write({'lst_price': 50})
setup_pos_combo_items(self)
self.office_combo.write({'lst_price': 50})
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour(f"/pos/ui?config_id={self.main_pos_config.id}", 'PosComboPriceTaxIncludedTour', login="pos_user")
order = self.env['pos.order'].search([])
@@ -977,8 +982,8 @@ class TestUi(TestPointOfSaleHttpCommon):
'barcode': '3760171283370',
})
self.main_pos_config.open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'GS1BarcodeScanningTour', login="accountman")
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'GS1BarcodeScanningTour', login="pos_user")
def test_refund_order_with_fp_tax_included(self):
#create a tax of 15% tax included
@@ -1020,8 +1025,8 @@ class TestUi(TestPointOfSaleHttpCommon):
'tax_regime_selection': True,
})
self.main_pos_config.open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'FiscalPositionNoTaxRefund', login="accountman")
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'FiscalPositionNoTaxRefund', login="pos_user")
def test_lot_refund(self):
@@ -1033,8 +1038,8 @@ class TestUi(TestPointOfSaleHttpCommon):
'available_in_pos': True,
})
self.main_pos_config.open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'LotRefundTour', login="accountman")
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'LotRefundTour', login="pos_user")
def test_receipt_tracking_method(self):
self.product_a = self.env['product.product'].create({
@@ -1044,8 +1049,8 @@ class TestUi(TestPointOfSaleHttpCommon):
'categ_id': self.env.ref('product.product_category_all').id,
'available_in_pos': True,
})
self.main_pos_config.open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'ReceiptTrackingMethodTour', login="accountman")
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'ReceiptTrackingMethodTour', login="pos_user")
def test_limited_product_pricelist_loading(self):
self.env['ir.config_parameter'].sudo().set_param('point_of_sale.limited_product_count', '1')
@@ -10,6 +10,7 @@ from odoo.addons.pos_online_payment.models.pos_order import PosOrder
from odoo.addons.pos_online_payment.tests.online_payment_common import OnlinePaymentCommon
from odoo.addons.account.models.account_payment_method import AccountPaymentMethod
from odoo.osv.expression import AND
from odoo.addons.point_of_sale.tests.common import archive_products
import odoo.tests
@@ -108,6 +109,20 @@ class TestUi(AccountTestInvoicingCommon, OnlinePaymentCommon):
cls.pos_user.partner_id.email = 'pos_op_user@test.com'
# End of code from addons/point_of_sale/tests/test_frontend.py
archive_products(cls.env)
pos_categ_misc = cls.env['pos.category'].create({
'name': 'Miscellaneous',
})
cls.letter_tray = cls.env['product.product'].create({
'name': 'Letter Tray',
'type': 'product',
'available_in_pos': True,
'list_price': 4.8,
'taxes_id': False,
'pos_categ_ids': [(4, pos_categ_misc.id)],
})
# Code from addons/account_payment/tests/common.py
@classmethod
def _prepare_provider(cls, provider_code='none', company=None, update_values=None):
@@ -170,7 +170,7 @@ registry.category("web_tour.tours").add("SplitBillScreenTour4PosCombo", {
...SplitBillScreen.orderlineHas("Combo Product 4", "1", "0"),
...SplitBillScreen.orderlineHas("Combo Product 7", "1", "0"),
...SplitBillScreen.subtotalIs("54.13"),
...SplitBillScreen.subtotalIs("53.80"),
...SplitBillScreen.clickPay(),
...PaymentScreen.clickPaymentMethod("Bank"),
...PaymentScreen.clickValidate(),
@@ -186,6 +186,6 @@ registry.category("web_tour.tours").add("SplitBillScreenTour4PosCombo", {
...ProductScreen.selectedOrderlineHas("Combo Product 4", "1.0", "14.66", "Office Combo"),
...ProductScreen.clickOrderline("Combo Product 7"),
...ProductScreen.selectedOrderlineHas("Combo Product 7", "1.0", "22.00", "Office Combo"),
...ProductScreen.totalAmountIs("45.86"),
...ProductScreen.totalAmountIs("45.53"),
],
});
+35 -25
View File
@@ -3,16 +3,14 @@
import odoo.tests
from odoo.addons.point_of_sale.tests.common_setup_methods import setup_pos_combo_items
from odoo.addons.point_of_sale.tests.common import archive_products
@odoo.tests.tagged('post_install', '-at_install')
class TestFrontend(odoo.tests.HttpCase):
def setUp(self):
super().setUp()
self.env = self.env(user=self.env.ref('base.user_admin'))
self.env.ref('base.user_demo').write({
'groups_id': [(4, self.env.ref('point_of_sale.group_pos_manager').id)],
})
archive_products(self.env)
account_obj = self.env['account.account']
account_receivable = account_obj.create({'code': 'X1012',
@@ -174,35 +172,46 @@ class TestFrontend(odoo.tests.HttpCase):
self.pos_config = pos_config
self.pos_admin = self.env['res.users'].create({
'name': 'A powerfull PoS man!',
'login': 'pos_admin',
'password': 'pos_admin',
'groups_id': [
(4, self.env.ref('base.group_user').id),
(4, self.env.ref('point_of_sale.group_pos_manager').id),
],
})
self.pos_admin.partner_id.email = 'pos_admin@test.com'
def test_01_pos_restaurant(self):
self.pos_config.with_user(self.env.ref('base.user_demo')).open_ui()
self.pos_config.with_user(self.pos_admin).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'pos_restaurant_sync', login="demo")
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'pos_restaurant_sync', login="pos_admin")
self.assertEqual(1, self.env['pos.order'].search_count([('amount_total', '=', 4.4), ('state', '=', 'draft')]))
self.assertEqual(1, self.env['pos.order'].search_count([('amount_total', '=', 4.4), ('state', '=', 'paid')]))
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'pos_restaurant_sync_second_login', login="demo")
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'pos_restaurant_sync_second_login', login="pos_admin")
self.assertEqual(0, self.env['pos.order'].search_count([('amount_total', '=', 4.4), ('state', '=', 'draft')]))
self.assertEqual(1, self.env['pos.order'].search_count([('amount_total', '=', 2.2), ('state', '=', 'draft')]))
self.assertEqual(2, self.env['pos.order'].search_count([('amount_total', '=', 4.4), ('state', '=', 'paid')]))
def test_02_others(self):
self.pos_config.with_user(self.env.ref('base.user_demo')).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'SplitBillScreenTour', login="demo")
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'ControlButtonsTour', login="demo")
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'FloorScreenTour', login="demo")
self.pos_config.with_user(self.pos_admin).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'SplitBillScreenTour', login="pos_admin")
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'ControlButtonsTour', login="pos_admin")
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'FloorScreenTour', login="pos_admin")
def test_04_ticket_screen(self):
self.pos_config.with_user(self.env.ref('base.user_demo')).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'PosResTicketScreenTour', login="demo")
self.pos_config.with_user(self.pos_admin).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'PosResTicketScreenTour', login="pos_admin")
def test_05_tip_screen(self):
self.pos_config.write({'set_tip_after_payment': True, 'iface_tipproduct': True, 'tip_product_id': self.env.ref('point_of_sale.product_product_tip')})
self.pos_config.with_user(self.env.ref('base.user_demo')).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'PosResTipScreenTour', login="demo")
self.pos_config.with_user(self.pos_admin).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'PosResTipScreenTour', login="pos_admin")
order1 = self.env['pos.order'].search([('pos_reference', 'ilike', '%-0001')], limit=1, order='id desc')
order2 = self.env['pos.order'].search([('pos_reference', 'ilike', '%-0002')], limit=1, order='id desc')
@@ -217,19 +226,20 @@ class TestFrontend(odoo.tests.HttpCase):
self.assertTrue(order5.is_tipped and order5.tip_amount == 0.00)
def test_06_split_bill_screen(self):
self.pos_config.with_user(self.env.ref('base.user_demo')).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'SplitBillScreenTour2', login="demo")
self.pos_config.with_user(self.pos_admin).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'SplitBillScreenTour2', login="pos_admin")
def test_07_split_bill_screen(self):
self.pos_config.with_user(self.env.ref('base.user_demo')).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'SplitBillScreenTour3', login="demo")
self.pos_config.with_user(self.pos_admin).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'SplitBillScreenTour3', login="pos_admin")
def test_08_refund_stay_current_table(self):
self.pos_config.with_user(self.env.ref('base.user_demo')).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'RefundStayCurrentTableTour', login="demo")
self.pos_config.with_user(self.pos_admin).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'RefundStayCurrentTableTour', login="pos_admin")
def test_09_combo_split_bill(self):
combo_product = setup_pos_combo_items(self)
combo_product.write({'lst_price': 40})
self.pos_config.with_user(self.env.ref('base.user_demo')).open_ui()
self.start_tour(f"/pos/ui?config_id={self.pos_config.id}", 'SplitBillScreenTour4PosCombo', login="demo")
setup_pos_combo_items(self)
self.office_combo.write({'lst_price': 40})
self.pos_config.with_user(self.pos_admin).open_ui()
self.start_tour(f"/pos/ui?config_id={self.pos_config.id}", 'SplitBillScreenTour4PosCombo', login="pos_admin")
@@ -84,19 +84,19 @@ class TestPoSSaleReport(TestPoSCommon):
def test_different_shipping_address(self):
product_0 = self.create_product('Product 0', self.categ_basic, 0.0, 0.0)
sale_order = self.env['sale.order'].create({
'partner_id': self.env.ref('base.res_partner_1').id,
'partner_shipping_id': self.env.ref('base.res_partner_2').id,
'partner_id': self.customer.id,
'partner_shipping_id': self.other_customer.id,
'order_line': [(0, 0, {
'product_id': product_0.id,
})],
})
self.open_new_session()
data = self.create_ui_order_data([(product_0, 1)], self.env.ref('base.res_partner_1'), True)
data = self.create_ui_order_data([(product_0, 1)], self.customer, True)
data['data']['lines'][0][2]['sale_order_origin_id'] = sale_order.read()[0]
data['data']['lines'][0][2]['sale_order_line_id'] = sale_order.order_line[0].read()[0]
order_ids = self.env['pos.order'].create_from_ui([data])
move_id = self.env['account.move'].browse(order_ids[0]['account_move'])
self.assertEqual(move_id.partner_id.id, self.env.ref('base.res_partner_1').id)
self.assertEqual(move_id.partner_shipping_id.id, self.env.ref('base.res_partner_2').id)
self.assertEqual(move_id.partner_id.id, self.customer.id)
self.assertEqual(move_id.partner_shipping_id.id, self.other_customer.id)
@@ -9,7 +9,7 @@ registry.category("web_tour.tours").add("self_combo_selector", {
test: true,
steps: () => [
Utils.clickBtn("Order Now"),
ProductPage.clickProduct("Office combo"),
ProductPage.clickProduct("Office Combo"),
...ProductPage.setupCombo([
{
product: "Desk Organizer",
@@ -19,16 +19,16 @@ registry.category("web_tour.tours").add("self_combo_selector", {
],
},
{
product: "Desk Combination",
product: "Combo Product 5",
attributes: [],
},
{
product: "Office Chair Black",
product: "Combo Product 8",
attributes: [],
},
]),
Utils.clickBtn("Order"),
...CartPage.checkCombo("Office combo", [
...CartPage.checkCombo("Office Combo", [
{
product: "Desk Organizer",
attributes: [
@@ -37,11 +37,11 @@ registry.category("web_tour.tours").add("self_combo_selector", {
],
},
{
product: "Desk Combination",
product: "Combo Product 5",
attributes: [],
},
{
product: "Office Chair Black",
product: "Combo Product 8",
attributes: [],
},
]),
@@ -4,7 +4,7 @@
import odoo.tests
from odoo import Command
from odoo.addons.point_of_sale.tests.common import archive_products
@odoo.tests.tagged("post_install", "-at_install")
class SelfOrderCommonTest(odoo.tests.HttpCase):
@@ -14,6 +14,7 @@ class SelfOrderCommonTest(odoo.tests.HttpCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
archive_products(cls.env)
cls.pos_user = cls.env['res.users'].create({
'name': 'POS User',
'login': 'pos_user',
@@ -33,6 +34,76 @@ class SelfOrderCommonTest(odoo.tests.HttpCase):
],
})
pos_categ_misc = cls.env['pos.category'].create({
'name': 'Miscellaneous',
})
cls.cola = cls.env['product.product'].create({
'name': 'Coca-Cola',
'type': 'product',
'list_price': 2.2,
'taxes_id': False,
'available_in_pos': True,
'pos_categ_ids': [(4, pos_categ_misc.id)],
})
cls.fanta = cls.env['product.product'].create({
'name': 'Fanta',
'type': 'product',
'list_price': 2.2,
'taxes_id': False,
'available_in_pos': True,
'pos_categ_ids': [(4, pos_categ_misc.id)],
})
#desk organizer
cls.desk_organizer = cls.env['product.product'].create({
'name': 'Desk Organizer',
'available_in_pos': True,
'list_price': 5.10,
'pos_categ_ids': [(4, pos_categ_misc.id)],
})
desk_size_attribute = cls.env['product.attribute'].create({
'name': 'Size',
'display_type': 'radio',
'create_variant': 'no_variant',
})
desk_size_s = cls.env['product.attribute.value'].create({
'name': 'S',
'attribute_id': desk_size_attribute.id,
})
desk_size_m = cls.env['product.attribute.value'].create({
'name': 'M',
'attribute_id': desk_size_attribute.id,
})
desk_size_l = cls.env['product.attribute.value'].create({
'name': 'L',
'attribute_id': desk_size_attribute.id,
})
cls.env['product.template.attribute.line'].create({
'product_tmpl_id': cls.desk_organizer.product_tmpl_id.id,
'attribute_id': desk_size_attribute.id,
'value_ids': [(6, 0, [desk_size_s.id, desk_size_m.id, desk_size_l.id])]
})
desk_fabrics_attribute = cls.env['product.attribute'].create({
'name': 'Fabric',
'display_type': 'select',
'create_variant': 'no_variant',
})
desk_fabrics_leather = cls.env['product.attribute.value'].create({
'name': 'Leather',
'attribute_id': desk_fabrics_attribute.id,
})
desk_fabrics_other = cls.env['product.attribute.value'].create({
'name': 'Custom',
'attribute_id': desk_fabrics_attribute.id,
'is_custom': True,
})
cls.env['product.template.attribute.line'].create({
'product_tmpl_id': cls.desk_organizer.product_tmpl_id.id,
'attribute_id': desk_fabrics_attribute.id,
'value_ids': [(6, 0, [desk_fabrics_leather.id, desk_fabrics_other.id])]
})
def _add_tax_to_product_from_different_company(self):
new_company = self.env['res.company'].create({
'name': 'Test Company',
@@ -85,6 +156,22 @@ class SelfOrderCommonTest(odoo.tests.HttpCase):
}
)
# We need a table and a floor to be able to do some tours when we do not have demo data.
# and thus no floors.
self.pos_main_floor = self.env['restaurant.floor'].create({
'name': 'Main Floor Test',
'pos_config_ids': [(4, self.pos_config.id)],
})
self.pos_table_1 = self.env['restaurant.table'].create({
'name': '1',
'floor_id': self.pos_main_floor.id,
'seats': 4,
'shape': 'square',
'position_h': 150,
'position_v': 100,
})
# we need a default tax fixed at 15% to all product because in the test prices are based on this tax.
# some time with the localization this may not be the case. So we force it.
self.env["product.product"].search([]).taxes_id = self.default_tax15
@@ -3,11 +3,20 @@
import odoo.tests
from odoo.addons.pos_self_order.tests.self_order_common_test import SelfOrderCommonTest
from odoo.addons.point_of_sale.tests.common_setup_methods import setup_pos_combo_items
@odoo.tests.tagged("post_install", "-at_install")
class TestSelfOrderCombo(SelfOrderCommonTest):
def test_self_order_combo(self):
setup_pos_combo_items(self)
desk_organizer_with_attributes_combo_line = self.env["pos.combo.line"].create(
{
"product_id": self.desk_organizer.id,
"combo_price": 0,
}
)
self.desk_accessories_combo.combo_line_ids += desk_organizer_with_attributes_combo_line
self.pos_config.write({
'self_ordering_default_user_id': self.pos_admin.id,
'self_ordering_takeaway': False,