[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
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user