':returns: The current pricelist record'

def get_current_pricelist(self):

    available_pricelists = self.get_pricelist_available()
    pl = None
    partner = self.env.user.partner_id
    if (request and request.session.get('website_sale_current_pl')):
        pl = self.env['product.pricelist'].browse(request.session['website_sale_current_pl'])
        if (pl not in available_pricelists):
            pl = None
            request.session.pop('website_sale_current_pl')
    if (not pl):
        pl = ((partner.last_website_so_id.state == 'draft') and partner.last_website_so_id.pricelist_id)
        if (not pl):
            pl = partner.property_product_pricelist
        if (available_pricelists and (pl not in available_pricelists)):
            pl = available_pricelists[0]
    if (not pl):
        _logger.error('Fail    to    find    pricelist    for    partner    "%s"    (id    %s)', partner.name, partner.id)
    return pl
