Skip to Content
Menu
This question has been flagged
1 Reply
5566 Views

Hi all,

self.env['res.users'].sudo().search([('id''='self.user_id.id)])

returns an empty recordset if the user.active and user.partner_id.active are set to false. Is there anyway to retrieve the inactive recordset for the given id (which is still correct?)

Regards,

Matthias

Avatar
Discard
Best Answer

Hi,

it is because the ORM 'search' method by default adds the condition to work with active records only. It is quite useful, since in the most cases archived documents should not be shown. E.g. when you open the 'customers' menu, you most probably do not want to see archived partners.

To avoid that explicitly add that you search inactive records. In your example:

self.env['res.users'].sudo().search([
    ('id', '=', self.user_id.id),
    "|",
        ("active", "=", True),
        ("active", "=", False),
])
Avatar
Discard

Thanks, it perfectly worked for me

Related Posts Replies Views Activity
1
Oct 24
280
2
Jul 24
471
1
Oct 23
1607
0
May 23
1039
9
Dec 23
31746