summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorDenis Ledoux <dle@odoo.com>2016-01-29 17:48:02 +0100
committerDenis Ledoux <dle@odoo.com>2016-01-29 17:51:51 +0100
commit56e3d2d51216aef3652b2fbca8a9d7b176cc480c (patch)
tree0a54feff5247605c892db91f6dc0de499c9ffe79 /addons
parent6c8bbc3d466b9d5d83d3b7f46f3a904bd433cdaf (diff)
[FIX] website_sale: get_pricelist_available from the backend.
The method `get_pricelist_available` can be called from the backend. (e.g. when using `website.pricelist_id`, whic is a function field ultimately calling `get_pricelist_available`). In such a case, `request.website` is not available, as the request is not done from the website. Therefore, we have to fallback in a work-around to detect the website for which we would like to get the available pricelists. Passing the `website_id` in the context is kinda crappy, but as the website for which we would like the available pricelists is not passed in the method params (trough a parameter `ids` for instance), this is one way to put it through. opw-668230
Diffstat (limited to 'addons')
-rw-r--r--addons/website_sale/models/sale_order.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py
index 7e07c31f5f4..87a6aac943a 100644
--- a/addons/website_sale/models/sale_order.py
+++ b/addons/website_sale/models/sale_order.py
@@ -139,8 +139,8 @@ class website(orm.Model):
def _get_pricelist_id(self, cr, uid, ids, name, args, context=None):
res = {}
- pricelist = self.get_current_pricelist(cr, uid, context=context)
for data in self.browse(cr, uid, ids, context=context):
+ pricelist = self.get_current_pricelist(cr, uid, context=dict(context, website_id=data.id))
res[data.id] = pricelist.id
return res
@@ -198,11 +198,18 @@ class website(orm.Model):
:returns: pricelist recordset
"""
+ website = request.website
+ if not request.website:
+ if context.get('website_id'):
+ website_id = context['website_id']
+ else:
+ website_id = self.search(cr, uid, [], context=context)
+ website = self.browse(cr, uid, website_id, context=context)
isocountry = request.session.geoip and request.session.geoip.get('country_code') or False
pl_ids = self._get_pl(cr, uid, isocountry, show_visible,
- request.website.user_id.sudo().partner_id.property_product_pricelist.id,
+ website.user_id.sudo().partner_id.property_product_pricelist.id,
request.session.get('website_sale_current_pl'),
- request.website.website_pricelist_ids)
+ website.website_pricelist_ids)
return self.pool['product.pricelist'].browse(cr, uid, pl_ids, context=context)
def is_pricelist_available(self, cr, uid, pl_id, context=None):