Odoo 10 - QWeb报告小部件联系人 - 缺少state_id

时间:2018-02-15 10:38:08

标签: odoo odoo-10 qweb

我使用widget联系人有以下字段。

<div t-field="o.partner_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"/>

这不显示state_id,我该如何包含它?

3 个答案:

答案 0 :(得分:0)

您可以继承base.contact模板以添加state_id字段。

<template id="contact" inherit_id="base.contact">
    <xpath expr="//address/div[2]/div[2]" position="after">
        <div t-if="object.state_id and 'state_id' in fields" 
           class='css_editable_mode_hidden'>
            <div itemprop="state_id" t-esc="object.state_id.name" 
                 style="margin-bottom:4px;font-size:14px;"/>
        </div>
    </xpath>
</template>

然后要在QWEB报告中使用它,只需在state_id属性中指定fields字段即可。

<address t-field="o.partner_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;, &quot;state_id&quot;], &quot;no_marker&quot;: true}"/>  

我使用div[2]/div[2]在国家/地区之后添加state_id。

答案 1 :(得分:0)

我终于发现这是一个配置设置。默认情况下,Odoo不包括大多数国家/地区的state_id。这是在settings->localization->country

中配置的

答案 2 :(得分:-1)

您可以传递t-field-options参数中的选项,如下所示。

<div t-field="o.partner_id" 
t-fields-options='{"widgets": "contact", "fields": ["address", "name", "phone", "email"], "no_marker": true }'
/>

字段“地址”包含合作伙伴的整个地址,包括state_id