[FIX] odoo_referral: Fix undeterministic crashing bug

The http request to odoo.com could lead to a timeout.

Avoid it in a testing environment, to avoid tests like
test_20_crawl_demo to crash.

closes odoo/odoo#48307

Taskid: 2222797
X-original-commit: 873699142f3427ecf486cf4319e158768a4e1336
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Yannick Tivisse
2020-03-25 09:09:40 +00:00
parent 859c7e7708
commit aa618d7661
+3 -1
View File
@@ -10,7 +10,7 @@ import threading
from hashlib import sha1
from werkzeug import url_encode
from odoo import api, models
from odoo import api, models, tools
DEST_SERVER_URL = 'https://www.odoo.com'
@@ -22,6 +22,8 @@ class Users(models.Model):
@api.model
def get_referral_updates_count_for_current_user(self):
if tools.config.options['test_enable']:
return 0
token = self.env.user._get_or_generate_referral_token()
if not token:
return 0