Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

how make zip and city mandatory on res.partner view ?

By
Laurent33
on 4/9/13, 12:54 PM 3,155 views

how do I do to make the zip code and city mandatory on view base.view_partner_form in a personal app ? (just on view, not in database)

2
Christophe HANON
On 9/29/13, 7:55 AM

Indeed the fields_view_get_address() function in res_partner.py breaks the standard way of changing the view. This code is designed to support country related layouts.

As a quick fix the following python code will help removing this view changes making the standard view inherit works.

class crm_sale_order_line(osv.osv):
    _name = "res.partner"
    _inherit ="res.partner"

    def fields_view_get_address(self, cr, uid, arch, context={}):
         return arch
3

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 4/9/13, 12:59 PM

Inherit the original partner form and replace the original field with this:

<field name="zip" position="attributes">
    <attribute name="required">True</attribute>
</field>
<field name="city" position="attributes">
    <attribute name="required">True</attribute>
</field>

thanks.... i've tried but... see next answer

Laurent33
on 4/9/13, 1:52 PM
1
Laurent33
On 4/9/13, 1:24 PM

that's what i've tried but xml is overwritten in function fields_view_get_address() in res.partner.py.

i've tried to inherit this function and modify as well :

...
    layouts = {
        '%(city)s %(state_code)s\n%(zip)s': """
            <div class="address_format">
                <field name="city" required="1" placeholder="City mandatory" style="width: 50%%" />
                <field name="state_id" class="oe_no_button" placeholder="State" style="width: 47%%" options='{"no_open": true}'/>
                <br/>
                <field name="zip" required="1" placeholder="ZIP mandatory" />
            </div>
        """,
        '%(zip)s %(city)s': """
            <div class="address_format">
                <field name="zip" required="1" placeholder="ZIP mandatory" style="width: 40%%" />
                <field name="city" required="1" placeholder="city mandatory" style="width: 57%%" />
                <br/>
                <field name="state_id" class="oe_no_button" placeholder="State" options='{"no_open": true}'/>
            </div>
        """,
        '%(city)s\n%(state_name)s\n%(zip)s': """
            <div class="address_format">
                <field name="city" required="1" placeholder="City mandatory" />
                <field name="state_id" class="oe_no_button" placeholder="State" options='{"no_open": true}'/>
                <field name="zip" required="1" placeholder="ZIP mandatory" />
            </div>
        """
    }

...

but it seems that required="1" is unrecognized

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/9/13, 12:54 PM
Seen: 3155 times
Last updated: 3/16/15, 8:10 AM