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.

5

Why translation not working for ZIP, State and City in openerp7?

By
Omal Bastin
on 4/24/13, 11:28 AM 1,906 views

I have tried to translated the placeholders in res.partner, placeholder values like name, country etc are translated to dutch. But city, state and zip are not translating.

2

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 11/20/13, 11:50 AM

The reason for that is in located in the method fields_view_get_address in /addons/base/res/res_partner.py.

The partner views are dynamically changed based on the country of the current company. The tag <div class="address_format"> is replaced by one of the following values (depending on the address_format of the country):

    layouts = {
        '%(city)s %(state_code)s\n%(zip)s': """
            <div class="address_format">
                <field name="city" placeholder="City" style="width: 50%%"/>
                <field name="state_id" class="oe_no_button" placeholder="State" style="width: 47%%" options='{"no_open": true}'/>
                <br/>
                <field name="zip" placeholder="ZIP"/>
            </div>
        """,
        '%(zip)s %(city)s': """
            <div class="address_format">
                <field name="zip" placeholder="ZIP" style="width: 40%%"/>
                <field name="city" placeholder="City" 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" placeholder="City"/>
                <field name="state_id" class="oe_no_button" placeholder="State" options='{"no_open": true}'/>
                <field name="zip" placeholder="ZIP"/>
            </div>
        """
    }

I suggest to disable this "feature" by applying one of the following methods:

  1. Override the function fields_view_get_address:

    class res_partner(osv.osv):
       _inherit ='res.partner'
       def fields_view_get_address(self, cr, uid, arch, context={}):
            return arch
    res_partner()
    
  2. Update the address_format in the country of your company:

    Goto menu "Sales/Configuration/Address Book/Localisation/Countries" and open the country of your company. Then you have to assure that the addess_format does not match one of the above formats. E.g. for Austria you can replace

    %(street)s
    %(street2)s
    %(city)s %(state_code)s %(zip)s
    %(country_name)s
    

with

    %(street)s
    %(street2)s
    %(city)s XXX %(state_code)s %(zip)s
    %(country_name)s

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

2 follower(s)

Stats

Asked: 4/24/13, 11:28 AM
Seen: 1906 times
Last updated: 3/16/15, 8:10 AM