Creating a custom page layout

In the previous example we learned how to modify the website template header to then modify the look of every page on the website. Next we will see how we can create a page that has a specific layout.

Let's say we want to create a unique page for art approval. We know that we want this to have a specific layout and look different than the rest of the site so we can create a specific layout page for it. In this example we will just list a few recommendations for customers when approving the art. You can however extend this with any layout you choose.
We begin by creating a file Pages.xml and paste in the following code:

<odoo>

<record id="services_page" model="website.page">
<field name="name">Art Approval</field>
<field name="website_published">True</field>
<field name="url">/approval</field>
<field name="type">qweb</field>
<field name="key">theme_tutorial.artapproval_page</field>
<field name="arch" type="xml">
<t t-name="theme_tutorial.artapproval_page_template">
<t t-call="website.layout">
<div id="wrap">
<div class="container">
<h1>Art Approval Checklist</h1>
<ul>
<li>Check the spelling of all proofs</li>
<li>Verify your color selections</li>
<li>Provide detailed feedback on any changes</li>
</ul>

<!—- Area for Snippets === -->
<div class="oe_structure" />
</div>
</div>
</t>
</t>
</field>
</record>

</odoo>

Let's talk a bit about some of the specific elements. The record tag uniquely identifies our page. The model attribute is how Odoo knows that this entire record should be handled as a website page. The name element, name to our page and flag it as being published. The url field specifies where the page resides in the site. You will use this to navigate to the page. The type will always be qweb as that is the template language Odoo uses for the pages. We then have a key that is used internally by Odoo.
Looking at the actual content of the page you can see that we use a t element to specify our theme name and the call to website.layout. All of this then drills down to where we finally have the div with our container class. It is within here that we can specify the exact layout and default content for our page. In this case we have put some simple instructions as an example.
Finally, we have a div at the bottom with the class oe_structure. This is where we can now drag and drop blocks in Web Builder to manage the content in the page.
Add the reference to pages.xml in your __mainfest__.py file and upgrade the theme. If you are successful the result should look like this:

This should give you a pretty good start at understanding theme development in Odoo. There is much more to learn for building snippets and your own blocks.

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

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