res_partner.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. from openerp import api, fields, models
  2. class ResPartner(models.Model):
  3. _inherit = 'res.partner'
  4. @api.model
  5. def get_customers(self):
  6. domain = [('customer', '=', True), ('is_company', '=', False), ('active', '=', True)]
  7. customers = []
  8. for customer in self.env['res.partner'].search(domain):
  9. categories = []
  10. for category in customer.category_id:
  11. categories.append({
  12. 'id': category.id,
  13. 'name': category.name,
  14. 'display_name': category.display_name
  15. })
  16. customers.append({
  17. 'id': customer.id,
  18. 'name': customer.name,
  19. 'display_name': customer.display_name,
  20. 'ruc': customer.ruc,
  21. 'image_medium': customer.image_medium,
  22. 'phone': customer.phone,
  23. 'mobile': customer.mobile,
  24. 'email': customer.email,
  25. 'credit': customer.credit,
  26. 'credit_limit': customer.credit_limit,
  27. 'categories': categories
  28. })
  29. return customers