From 8e95ee68439e6a22744fe55f23f3cfcaa00ebf7c Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 27 Oct 2017 16:01:48 +0200 Subject: [PATCH] [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 --- addons/website_sale/models/sale_order.py | 5 +++-- 1 file 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