Skip to content Skip to sidebar Skip to footer

How To Include View In Odoo 8

As in the title. How do you include a view file from a view file? If you have a large xml view file with thousand lines would it be great if you can split them into partial view th

Solution 1:

t-call Attribute :

Which is works only in Qweb template but we can not call with the Odoo generic view like tree view, form view, search view and many more. but we can only inherit the existing view with inherit_id Attribute in new inherited custom view.

For Example

<field name="inherit_id"ref="product.product_template_only_form_view"/>

Actually Usage of t-call Attribute: Calling sub-templates

QWeb templates can be used for top-level rendering, but they can also be used from within another template (to avoid duplication or give names to parts of templates) using the t-call directive:

<template id="other-template">
   <div>
     This template was called with content:
  </div>
<template>

This calls the named template with the execution context of the parent, if other_template is defined as:

   <template id="new-template">
    <t t-call="other-template">
      <em>content</em>
     </t>
   </template>

Result :

<div>
    This template was called with content:
    <em>content</em>
</div>

This is possible only with Qweb template view.

I hope my answer may help you


Post a Comment for "How To Include View In Odoo 8"