0
votes

I have the following field using widget contact.

<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}"/>

This does not display the state_id, how can I include it?

3

3 Answers

0
votes

You can inherit base.contact template to add state_id field.

<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>

Then to use it in a QWEB report just specify state_id field in fields attribute.

<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}"/>  

I used div[2]/div[2] to add state_id just after country.

0
votes

I finally found it was a configuration setup. Odoo by default does not include state_id for most countries. This is configured in settings->localization->country

-1
votes

You can pass in the option inside t-field-options param as below.

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

Field "address" contains whole address of partner including state_id.