How it works...

In the first step, we have imported a few required functions. The slug is used to generate a clean, user-friendly URL, based on a record name. The sitemap_qs2dom is used to generate a domain based on route and query strings.

In step 2, we have created a Python generator function sitemap_books(). This function will be called whenever a sitemap is generated. During the call, it will receive three arguments—the env Odoo environment, the rule route rule, and the qs query string. In the function, we have generated a domain with sitemap_qs2dom. Then, we used the generated domain to search the book records, which are used to generate the location through the slug() method. With slug, you will get a user-friendly URL, like /books/odoo-12-development-cookbook-1 instead of books/1.

In step 3, we have passed the sitemap_books() function reference to the route with a keyword sitemap.

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

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