'Private implementation of search() method, allowing specifying the uid to use for the access right check.
This is useful for example when filling in the selection list for a drop-down and avoiding access rights errors,
by specifying ``access_rights_uid=1`` to bypass access rights check, but not ir.rules!
This is ok at the security level because this method is private and not callable through XML-RPC.
:param access_rights_uid: optional user ID to use when checking access rights
(not for ir.rules, this is only for ir.model.access)
:return: a list of record ids or an integer (if count is True)'

@api.model
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):

    self.sudo((access_rights_uid or self._uid)).check_access_rights('read')
    if (self.is_transient() and self._log_access and (self._uid != SUPERUSER_ID)):
        args = expression.AND(([('create_uid', '=', self._uid)], (args or [])))
    query = self._where_calc(args)
    self._apply_ir_rules(query, 'read')
    order_by = self._generate_order_by(order, query)
    (from_clause, where_clause, where_clause_params) = query.get_sql()
    where_str = ((where_clause and ('    WHERE    %s' % where_clause)) or '')
    if count:
        query_str = (('SELECT    count(1)    FROM    ' + from_clause) + where_str)
        self._cr.execute(query_str, where_clause_params)
        res = self._cr.fetchone()
        return res[0]
    limit_str = ((limit and ('    limit    %d' % limit)) or '')
    offset_str = ((offset and ('    offset    %d' % offset)) or '')
    query_str = (((((('SELECT    "%s".id    FROM    ' % self._table) + from_clause) + where_str) + order_by) + limit_str) + offset_str)
    self._cr.execute(query_str, where_clause_params)
    res = self._cr.fetchall()
    def _uniquify_list(seq):
        seen = set()
        return [x for x in seq if ((x not in seen) and (not seen.add(x)))]
    return _uniquify_list([x[0] for x in res])
