There's more...

As seen in the preceding section, inheritance with controllers works slightly differently than model inheritance; you actually need a reference to the base class and to use Python inheritance on it.

Don't forget to decorate your new handler with the @http.route decorator; Odoo uses it as a marker for which methods are exposed to the network layer. If you omit the decorator, you actually make the handler's path inaccessible.

The @http.route decorator itself behaves similar to field declarations: every value you don't set will be derived from the decorator of the function you're overriding, so we don't have to repeat values we don't want to change.

After receiving a response object from the function you override, you can do a lot more than just change the QWeb context:

  • You can add or remove HTTP headers by manipulating response.headers
  • If you want to render an entirely different template, you can overwrite response.template
  • To detect whether a response is based on QWeb in the first place, query response.is_qweb
  • The resulting HTML code is available by calling response.render()
..................Content has been hidden....................

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