# -*- coding: utf-8 -*- from openerp.http import request _MODEL = 'res.partner' ''' ''' def get_customers(image_type='small'): domain = [ ('customer', '=', True), ('active', '=', True) ] return [ { 'id': customer.id, 'name': customer.display_name, 'image': customer.image_small if image_type == 'small' else customer.image_medium, 'ruc': customer.ruc or None, 'phone': customer.phone or None, 'mobile': customer.mobile or None, 'email': customer.email or None } for customer in request.env['res.partner'].search(domain) ] ''' Create and get customer ''' def create_customer(**kw): customer = request.env[_MODEL].create({ 'name': kw.get('name'), 'ruc': kw.get('ruc'), 'mobile': kw.get('mobile'), 'customer': True }) return { 'id': customer.id, 'name': customer.display_name, 'image': customer.image_small, 'ruc': customer.ruc or None, 'phone': customer.phone or None, 'mobile': customer.mobile or None, 'email': customer.email or None }