# -*- coding: utf-8 -*- from openerp.http import request as r def get_pricelist_id(currency_id): if not currency_id: return None domain = [ ('active', '=', True), ('type', '=', 'sale') ] pricelist = r.env['product.pricelist'].search(domain) if not True in pricelist.mapped(lambda p: p.currency_id.id == currency_id): pricelist = pricelist[0].copy() pricelist.write({ 'currency_id': currency_id }) else: pricelist = pricelist.filtered(lambda p: p.currency_id.id == currency_id) if len(pricelist) > 1: pricelist = pricelist[0] # lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist_purchase.id return pricelist.id