Record rules are conditions that records must satisfy for an operation (create, read, update or delete) to be allowed.
The record rule above will be checked when a user tries to read, create or delete a hospital.patient record. to check the user who created a record use create_uid on the left and use the context value user to get the current user record.
To check if the current user created the record, use the following domain:
<field name="domain_force">[('create_uid', '=', user.id)]</field>
It can't be used to hide the Edit button since access rules are checked after calling the write method
There is an OCA module (Web Access Rules Buttons) that disables the Edit button on the form views if the user cannot edit the current record according to the record access rules.
Usage:
When using Odoo, even if a user has no rights to edit a record, the Edit button is shown. The user can edit the record but won't be able to save his changes. Now, the user won't be able to click on the Edit button.
Now the module is available for version 14.0, but if you update the manifest file like the following, it should work.
Comment the following line:
"views/web_access_rule_buttons.xml",
Add the following entry:
"assets": {'web.assets_backend': ['web_access_rule_buttons/static/src/js/form_controller.js'],},
Try with following record rule:
<record id="hideEdit_rule" model="ir.rule">
<field name="name">Hide Edit</field>
<field name="model_id" ref="model_hospital_patient"/>
<field name="domain_force">[('create_uid', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('om_hospital.hospital_management_pratisyen_doctor'))]"/>
<field name="perm_write" eval="True"/>
</record>