# -*- coding: utf-8 -*- from openerp.http import request as r _MODEL = 'product.pricelist' def get_pricelists(type='sale'): domain = [ ('type', '=', type), ('active', '=', True) ] return [ { 'id': p.id, 'name': p.display_name, 'type': p.type, 'versions': [ { 'id': v.id, 'name': v.display_name, 'companyId': v.company_id.id or None, 'items': [ { 'id': i.id, 'name': i.display_name, 'base': i.base, 'basePricelistId': i.base_pricelist_id.id or None, 'minQuantity': i.min_quantity, 'priceDiscount': i.price_discount, 'priceMaxMargin': i.price_max_margin, 'priceMinMargin': i.price_min_margin, 'priceRound': i.price_round, 'priceSurcharge': i.price_surcharge, 'productId': i.product_id.id or None, 'productTmplId': i.product_tmpl_id.id or None, 'categoryId': i.categ_id or None, 'companyId': i.company_id.id or None } for i in v.items_id ], } for v in p.version_id ] } for p in r.env[_MODEL].search(domain) ]