How it works...

In the first step, we registered post_init_hook in the manifest file with the add_book_hook value. This means that after the installation of the module, Odoo will look for the add_book_hook method in __init__.py. If found, if it's will call the method with the database cursor and registry.

In step 2, we declared the add_book_hook() method, which will be called after the module is installed. We created two records from this method. In real situations, you can write complex business logic here.

In the example, we looked at post_init_hook, but Odoo supports two more hooks:

  • pre_init_hook: This hook will be invoked when you start installing a module. It is the opposite of post_init_hook; it will be invoked before installing the current module.
  • uninstall_hook: This hook will be invoked when you uninstall the module. This is mostly used when your module needs a garbage-collection mechanism.
..................Content has been hidden....................

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