gpt4 book ai didi

python - 如何在 Odoo 8 中包含 View

转载 作者:太空宇宙 更新时间:2023-11-03 14:49:36 26 4
gpt4 key购买 nike

如标题所示。如何从 View 文件中包含 View 文件?

如果您有一个包含数千行的大型 xml View 文件,如果您可以将它们拆分为部分 View ,然后将它们包含在主视图中,那就太好了。

我尝试过t t-call,但不起作用

<notebook>
<page string="Page 1">
<t t-call="module.page_1"/>
</page>
<page string="Page 2">
<t t-call="module.page_2"/>
</page>
</notebook>

最佳答案

t-call 属性:

这仅适用于 Qweb 模板,但我们无法使用 Odoo 通用 View (如 TreeView 、表单 View 、搜索 View 等)进行调用。但我们只能在新继承的自定义 View 中继承带有inherit_id属性的现有 View 。

例如

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

t-call属性的实际用法:调用子模板

QWeb 模板可用于顶级渲染,但也可以使用 t-call 指令在另一个模板中使用它们(以避免重复或为模板的各个部分命名):

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

如果 other_template 定义为:

,这将使用父级的执行上下文调用命名模板:
   <template id="new-template">
<t t-call="other-template">
<em>content</em>
</t>
</template>

结果:

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

这只能通过 Qweb 模板 View 实现。

希望我的回答对您有帮助

关于python - 如何在 Odoo 8 中包含 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45973115/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com