There's more...

It is also possible to pass a dictionary to with_context(). In this case, the dictionary is used as the new context, which overwrites the current one. So, step 5 can also be written as follows:

new_context = self.env.context.copy() 
new_context.update({'avoid_deactivate': True}) 
book_with_different_context = self.book_id.with_context(new_context)
book_with_different_context.make_lost()

Using with_context() involves creating a new Environment instance. This environment will have an initially-empty recordset cache, which will evolve independently of the cache of self.env. This can cause spurious database queries. In any case, you should avoid creating new environments inside loops and try to move these environment creations to the outermost-possible scope.

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

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