admin管理员组文章数量:1431935
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 ?
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 ?
Share Improve this question asked Nov 19, 2024 at 2:13 ConsepConsep 211 silver badge1 bronze badge 3- IIRC the fields will get the same "options" in the same view. You can call it Feature or Bug, but that's what i have experienced myself in some similar situations. – CZoellner Commented Nov 19, 2024 at 8:17
- I'm afraid you're right CZoellner – Consep Commented Nov 27, 2024 at 15:57
- @Consep I am facing the same issue. How did you solve? – Neural Commented Feb 28 at 9:28
2 Answers
Reset to default 1What 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>
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.
本文标签: xmlHow to display 2 times an address field in form view Odoo 16Stack Overflow
版权声明:本文标题:xml - How to display 2 times an address field in form view Odoo 16 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745585878a2664902.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论