From 7830084547e7df29c6dcd377dd4dc39a0319b594 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Fri, 6 Nov 2020 10:39:44 +0000 Subject: [PATCH] [FIX] website_sale_order_type: speed up tour Without this patch, it's easy that the tour fails randomly due to a timeout when generating the sales order report. These assets can take a long time, increasing when more addons are installed. In an integrated database, this patch makes the test go from this log: 2020-11-06 10:34:53,941 34 INFO devel werkzeug: 127.0.0.1 - - [06/Nov/2020 10:34:53] "POST /payment/transfer/feedback HTTP/1.1" 302 - 730 4.368 11.800 To this one: 2020-11-06 10:32:55,517 34 INFO devel werkzeug: 127.0.0.1 - - [06/Nov/2020 10:32:55] "POST /payment/transfer/feedback HTTP/1.1" 302 - 479 2.906 5.771 That's about 50% the time. In the same patch, I remove the `self.env` patch that was only needed for Odoo v11 and lower. --- .../tests/test_website_sale_order_type.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/website_sale_order_type/tests/test_website_sale_order_type.py b/website_sale_order_type/tests/test_website_sale_order_type.py index 2ed1185f05..e4f855ab3a 100644 --- a/website_sale_order_type/tests/test_website_sale_order_type.py +++ b/website_sale_order_type/tests/test_website_sale_order_type.py @@ -8,7 +8,6 @@ class TestFrontend(HttpCase): def setUp(self): super(TestFrontend, self).setUp() - self.env = api.Environment(self.registry.test_cr, self.uid, {}) self.sale_type_model = self.env['sale.order.type'] self.partner = self.env.ref('base.partner_admin') @@ -42,6 +41,17 @@ def create_sale_type(self): def test_website_sale_order_type(self): self.partner.sale_type = self.sale_type existing_orders = self.env['sale.order'].search([]) + # Precreate SO report assets cache to avoid tour step timeouts + views = ( + "web.assets_common", + "web.report_assets_common", + "web.report_assets_pdf", + ) + for view in views: + self.env["ir.qweb"]._get_asset_nodes( + view, self.env.context, js=False) + self.env["ir.qweb"]._get_asset_nodes( + view, self.env.context, css=False) # In frontend, create an order tour_prefix = "odoo.__DEBUG__.services['web_tour.tour']" self.phantom_js(