Skip to content

Commit

Permalink
[FIX] website_sale_order_type: speed up tour
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jairo Llopis committed Nov 6, 2020
1 parent 280385a commit 7830084
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion website_sale_order_type/tests/test_website_sale_order_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7830084

Please sign in to comment.