How to do it...

We will use the same my_library module from the previous recipe. We already have an ALC rule that gives read-only read to the normal user. We will add a new field with security groups so that only the librarian has access to it. After that, we will modify the field value by the normal user. Follow these steps to achieve this:

  1. Add the new field in the library.book model:
 report_missing = fields.Text(
string="Book is missing",
groups='my_library.group_library_librarian')
  1. Add the field in the form view:
<field name="report_missing"/>
  1. Add the report_missing_book() method in the library.book model:
    def report_missing_book(self):
self.ensure_one()
message = "Book is missing (Reported by: %s)" % self.env.user.name
self.sudo().write({
'report_missing': message
})
  1. Add the button in the form view to trigger this method from the user interface:
<button name="report_missing_book"
string="Report Missing Book"
type="object"/>

Restart the server and update the module to apply these changes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset