This question has been flagged
2 Replies
16661 Views

I want to make address fields(street, city, state, zip) required, I used the following 3 type of codes but none of them work for me 

1) <field name="zip" placeholder="ZIP" required="1"/>

2) <field name="zip" placeholder="ZIP" use="required" />

3) <field name="zip" placeholder="ZIP" use="required"><attribute name="required">True</attribute></field>

Source Code

<group>
<field name="parent_id" invisible="1"/>
<field name="seller" invisible="1"/>
<group>
<label for="street" string="Address"/>
<div>
<field name="street" placeholder="Street"/>
<field name="street2"/>
<div class="address_format">
<field name="city" placeholder="City"/>
<field name="state_id" class="oe_no_button" placeholder="State" options="{"no_open": True, "no_create": True}"/>
<field name="zip" placeholder="ZIP"/>
</div>
<field name="country_id" placeholder="Country" class="oe_no_button" options="{"no_open": True, "no_create": True}"/>
</div>
<field name="website" widget="url" placeholder="e.g. www.odoo.com"/>
</group>
<group>
<field name="phone" placeholder="e.g. +32.81.81.37.00"/>
<field name="mobile"/>
<field name="user_ids" invisible="1"/>
<field name="email" widget="email" attrs="{'required': [('user_ids','!=', [])]}" readonly="1"/>
<field name="title" options="{"no_open": True,"no_create": True}"/>
</group>
</group>


Avatar
Discard
Author Best Answer

@Haresh Kansara , Thank you! 

This was an inherited form. I just use required="1" and it's working fine for me

Avatar
Discard
Best Answer

Hi Muhammad Arslan,

I have just analyse your issue for field require,

To set required field you just need to set attribute required="1" and you have added perfectly in point-1.

Make sure, if you have inherited form, then perfectly added code or is there any other inherited form that block your feature, because you have added perfectly.

Also i have found that the source form that you have mention above is not exist in odoo. Is this, this one form from the module: l10_mx_edi 

l10_mx_edi.mx_partner_address_form

Avatar
Discard