odooodoo-14

Set 'city' field as mandatory base.view_partner_form (Odoo 14)


I'm creating a custom module to set 'city' field as mandatory on base.view_partner_form, in Odoo 14.

I have tried

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="required_city_field" model="ir.ui.view">
            <field name="name">required.city.field</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="arch" type="xml">
            <field name="city" position="attributes">
                    <attribute name="required">1</attribute>
            </field>
            </field>
        </record>
    </data>
</odoo>

But it isn't working, no errors, just nothing happening. With others fields as "zip" it works just fine as it should. I'm guessing there is some modification in other class or inheritance, but can't find it.

I have found a similar discussion here, but even trying what I understand of that solution, I can't set city field as mandatory.

Does anyone know how to aproeach this?


Solution

  • The city field is probably replaced in base_address_city module, you can avoid that by setting no_address_format to True in the action's context.