summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2017-10-27 16:01:48 +0200
committerLucas Perais (lpe) <lpe@odoo.com>2017-10-30 09:35:22 +0100
commit8e95ee68439e6a22744fe55f23f3cfcaa00ebf7c (patch)
tree62b43e22773a9676b6732352a0774c05addf8678
parent76408ecdd7810f9f6048f27ccc43ed15637d93d6 (diff)
[FIX] website_sale: website_public_price computation not necessarily depends on a request
Before this commit, when trying to access website_public_price from the backend (when adding this field to a view for example), a traceback saying that the website attribute on the request object was non existent was raised. After this commit, we control for this and the field displays correctly OPW 778586 closes #20536
-rw-r--r--addons/website_sale/models/sale_order.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py
index 6735d3848f9..ea8a1914e3d 100644
--- a/addons/website_sale/models/sale_order.py
+++ b/addons/website_sale/models/sale_order.py
@@ -245,12 +245,13 @@ class Website(models.Model):
:param bool show_visible: if True, we don't display pricelist where selectable is False (Eg: Code promo)
:returns: pricelist recordset
"""
- website = request and request.website or None
+ website = request and hasattr(request, 'website') and request.website or None
if not website:
if self.env.context.get('website_id'):
website = self.browse(self.env.context['website_id'])
else:
- website = self.search([], limit=1)
+ # In the weird case we are coming from the backend (https://github.com/odoo/odoo/issues/20245)
+ website = len(self) == 1 and self or self.search([], limit=1)
isocountry = request and request.session.geoip and request.session.geoip.get('country_code') or False
partner = self.env.user.partner_id
order_pl = partner.last_website_so_id and partner.last_website_so_id.state == 'draft' and partner.last_website_so_id.pricelist_id