How it works...

Step 5 calls self.book_id.with_context() with some keyword arguments. This returns a new version of book_id (which is a library.book recordset) with the keys added to the current context. We are adding one key here, avoid_deactivate=True, but you can add multiple keys if you want.

In step 6, we checked whether the context has a positive value for the avoid_deactivate key. We avoid deactivating books, so the librarian can see them even if they are lost.

This is just a simple example of a context, but you can use it anywhere in the ORM, based on your requirements.

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

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