Reputation: 21
In the form view in Odoo 16, I have 2 times the same field, one to display only the name of the partner, and in another, I have the name and address.
In both cases, it displays the name and address. It seems that I can't have 2 types of display for the same field?
xml
<group>
<group>
<field name="partner_shipping_id" />
</group>
<group>
<field name="partner_shipping_id" context="{'show_address': 1}" options="{'always_reload': True, 'no_open':true}" readonly="1"/>
</group>
</group>
Any Idea ?
Upvotes: 2
Views: 60
Reputation: 14776
What you can try to do is to create the field twice, but without having it in database twice:
partner_shipping_id2 = fields.Many2one(
related="partner_shipping_id",
readonly=True,
)
Now, simply define the new field in the form to ensure that it appears as intended. For example like:
<group>
<group>
<field name="partner_shipping_id2" />
</group>
<group>
<field name="partner_shipping_id" context="{'show_address': 1}" options="{'always_reload': True, 'no_open':true}" readonly="1"/>
</group>
</group>
Upvotes: 1
Reputation: 198
just try to take the customer name (partner_id.name) from the model and put it in the xml.
<group>
<group>
<field name="partner_id.name" string="Delivery Address" />
</group>
<group>
<field name="partner_shipping_id" context="{'show_address': 1}" options="{'always_reload': True, 'no_open':true}" readonly="1"/>
</group>
</group>
by default, a snippet handles the shipping fields so tricky to customize the field but this way should do for you.
Upvotes: 0