# -*- coding: utf-8 -*- from openerp.http import request as r def get_users(): domain = [('active', '=', True)] current_user = r.env.user manager_id = None if 'Gerente' not in current_user.groups_id.filtered(lambda g: g.category_id.name == 'Eiru POS').mapped(lambda g: g.name): domain += [('store_id', '=', current_user.store_id.id)] else: manager_id = current_user.id return [ { 'id': u.id, 'name': u.display_name, 'company': { 'id': u.company_id.id, 'name': u.company_id.display_name, 'phone': u.company_id.phone or None, 'city': u.company_id.city or None, 'street': u.company_id.street or None, 'city': u.company_id.city or None, 'country': (u.company_id.country_id and u.company_id.country_id.name) or None, 'currencyId': u.company_id.currency_id.id or None }, 'isManager': u.id == manager_id, 'currentUser': u.id == current_user.id } for u in r.env['res.users'].search(domain) ] def get_current_user(): user = r.env.user return { 'id': user.id, 'name': user.display_name, 'company': { 'id': user.company_id.id, 'name': user.company_id.display_name, 'phone': user.company_id.phone or None, 'city': user.company_id.city or None, 'street': user.company_id.street or None, 'city': user.company_id.city or None, 'country': (user.company_id.country_id and user.company_id.country_id.name) or None, 'currencyId': user.company_id.currency_id.id or None }, 'isManager': 'Gerente' in user.groups_id.filtered(lambda g: g.category_id.name == 'Eiru POS').mapped(lambda g: g.name) }