12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- # -*- 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,
- 'pricelistId': customer.property_product_pricelist.id or None
- } for customer in request.env['res.partner'].search(domain)
- ]
- '''
- Create and get customer
- '''
- def create_customer(values):
- customer = request.env[_MODEL].sudo().create({
- 'name': values.get('name'),
- 'ruc': values.get('ruc'),
- 'mobile': values.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
- }
|