From 48dafd5b2011cee966920f664a904de2e2715ae8 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 20 Nov 2018 11:48:47 +0000 Subject: [PATCH] [FIX] point_of_sale: default pricelist test The POS js tests expect the "Public Pricelist" when selecting a lambda customer in the pos interface. Nevertheless, when installing a localization with a specific currency, other than the currency of the public pricelist, it creates a new pricelist called "Default %(currency)s pricelist for %(company)s" and sets it by default for the customers sale pricelist. See https://github.com/odoo/odoo/commit/787e1037cdca48fe361ae65d790056a3d57e6b67#diff-840bfc6fc7a986fbf0e248c83d2ac1d5R57 Therefore, in the POS js tests, the pricelist selected when selecting a lambda user was no longer 'public pricelist' but the one mentioned above, and the tests therefore failed. The issue is solved by creating a dedicated "Public Pricelist" for the purpose of these tests, and sets it by default for the customer sale pricelist, as well as for the pos config default pricelist. The test case was to install `l10n_pe` with `point_of_sale` while activating the test. e.g. `-i l10n_pe,point_of_sale --test-enable` opw-1890928 opw-1910249 closes odoo/odoo#28839 --- addons/point_of_sale/tests/test_frontend.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/point_of_sale/tests/test_frontend.py b/addons/point_of_sale/tests/test_frontend.py index b3dae4e9350..6e1feed1066 100644 --- a/addons/point_of_sale/tests/test_frontend.py +++ b/addons/point_of_sale/tests/test_frontend.py @@ -197,6 +197,10 @@ class TestUi(odoo.tests.HttpCase): one_week_from_now = today + timedelta(weeks=1) two_weeks_from_now = today + timedelta(weeks=2) + public_pricelist = env['product.pricelist'].create({ + 'name': 'Public Pricelist', + }) + env['product.pricelist'].create({ 'name': 'Dates', 'item_ids': [(0, 0, { @@ -283,9 +287,19 @@ class TestUi(odoo.tests.HttpCase): 'type': 'cash', 'company_id': main_company.id, 'journal_user': True})], + 'pricelist_id': public_pricelist.id, 'available_pricelist_ids': [(4, pricelist.id) for pricelist in all_pricelists], }) + # Change the default sale pricelist of customers, + # so the js tests can expect deterministically this pricelist when selecting a customer. + field = env['ir.model.fields']._get('res.partner', 'property_product_pricelist') + env['ir.property'].search([ + ('name', '=', 'property_product_pricelist'), + ('fields_id', '=', field.id), + ('res_id', '=', False) + ]).write({'value_reference': 'product.pricelist,%s' % public_pricelist.id}) + # open a session, the /pos/web controller will redirect to it main_pos_config.open_session_cb()