In this article, you will learn how to restrict users to see only his own records. To achieve this functionality we are going to use the odoo14 read method.

Restrict User from Accessing Differnt Records by Changing ID in URL | Learn OpenERP | Odoo

How to use read() method in Odoo14

We can restrict the user by using record rules, but in this article, I am going to show you how to restrict the user from accessing different records by changing the id in the URL. In Odoo8, to achieve this we can use Server Actions, but in Odoo14 we can't use Server Actions. So here we will use the read() method.


Restrict Users to See Only his Record



rec[0].get('login_id')[0]

This will give us the record of current model, and this record belongs to the current login user 

self.env.uid

This will give us the current logged in user id 

if rec[0].get('login_id')[0] != self.env.uid

It's mean that, user is trying to change id in URL to see another users record