Merge lp:~openerp-dev/openobject-server/7.0-opw-586924-dhs into lp:openobject-server/7.0

Proposed by Dhruti Shastri(OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-server/7.0-opw-586924-dhs
Merge into: lp:openobject-server/7.0
Diff against target: 60 lines (+22/-14)
1 file modified
openerp/addons/base/res/res_partner.py (+22/-14)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/7.0-opw-586924-dhs
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) Needs Fixing
Naresh(OpenERP) Pending
Review via email: mp+156759@code.launchpad.net

Description of the change

It is not possible to translate res.partner in inherited view.

To post a comment you must log in.
4919. By Purnendu Singh (OpenERP)

[FIX] merge with main server

4920. By Purnendu Singh (OpenERP)

[FIX] partner address traslation doesn't translated for few contries, improve the code

Revision history for this message
Purnendu Singh (OpenERP) (purnendu-singh) wrote :

hello,

1) Improved the code as it was not possible to create new db with suggested patch.
2) Improve the view arch same as it is in view file, like call of on_change_state and attrs were missing.
3) Improve the fields view method for all address_format

Regards,

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

We should not be doing the job of fields_view_get() a second time, translating the UI is its job. We must find a way to let the system do it automatically or we should simply remove this original code that tries to implement dynamic layouts.

Maybe this layout patch could be done by modifying the XML structure programmatically and moving nodes around instead of replacing the XML source brutally?

review: Needs Fixing

Unmerged revisions

4920. By Purnendu Singh (OpenERP)

[FIX] partner address traslation doesn't translated for few contries, improve the code

4919. By Purnendu Singh (OpenERP)

[FIX] merge with main server

4918. By Dhruti Shastri(OpenERP)

[translation]:res.partner, translation not workign for field zip,city,state(Case:586924)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openerp/addons/base/res/res_partner.py'
--- openerp/addons/base/res/res_partner.py 2013-04-25 17:12:38 +0000
+++ openerp/addons/base/res/res_partner.py 2013-05-15 08:06:26 +0000
@@ -33,34 +33,42 @@
33from openerp.tools.yaml_import import is_comment33from openerp.tools.yaml_import import is_comment
3434
35class format_address(object):35class format_address(object):
36 def fields_view_get_address(self, cr, uid, arch, context={}):36 def fields_view_get_address(self, cr, uid, arch, context=None):
37 if context is None: context={}
37 user_obj = self.pool.get('res.users')38 user_obj = self.pool.get('res.users')
38 fmt = user_obj.browse(cr, SUPERUSER_ID, uid, context).company_id.country_id39 translation_pool = self.pool.get('ir.translation')
40
41 fmt = user_obj.browse(cr, SUPERUSER_ID, uid, context=context).company_id.country_id
39 fmt = fmt and fmt.address_format42 fmt = fmt and fmt.address_format
43 lang = context.get('lang', False)
44 city = translation_pool._get_source(cr, uid, self._name, 'view', lang, 'City')
45 zip = translation_pool._get_source(cr, uid, self._name, 'view', lang, 'ZIP')
46 state = translation_pool._get_source(cr, uid, self._name, 'view', lang, 'State')
47
40 layouts = {48 layouts = {
41 '%(city)s %(state_code)s\n%(zip)s': """49 '%(city)s %(state_code)s\n%(zip)s': """
42 <div class="address_format">50 <div class="address_format">
43 <field name="city" placeholder="City" style="width: 50%%"/>51 <field name="city" placeholder="%s" style="width: 50%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
44 <field name="state_id" class="oe_no_button" placeholder="State" style="width: 47%%" options='{"no_open": true}'/>52 <field name="state_id" class="oe_no_button" placeholder="%s" style="width: 47%%" options='{"no_open": true}' on_change="onchange_state(state_id)" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
45 <br/>53 <br/>
46 <field name="zip" placeholder="ZIP"/>54 <field name="zip" placeholder="%s" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
47 </div>55 </div>
48 """,56 """%(city,state,zip),
49 '%(zip)s %(city)s': """57 '%(zip)s %(city)s': """
50 <div class="address_format">58 <div class="address_format">
51 <field name="zip" placeholder="ZIP" style="width: 40%%"/>59 <field name="zip" placeholder="%s" style="width: 40%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
52 <field name="city" placeholder="City" style="width: 57%%"/>60 <field name="city" placeholder="%s" style="width: 57%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
53 <br/>61 <br/>
54 <field name="state_id" class="oe_no_button" placeholder="State" options='{"no_open": true}'/>62 <field name="state_id" class="oe_no_button" placeholder="%s" options='{"no_open": true}' on_change="onchange_state(state_id)" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
55 </div>63 </div>
56 """,64 """%(zip,city,state),
57 '%(city)s\n%(state_name)s\n%(zip)s': """65 '%(city)s\n%(state_name)s\n%(zip)s': """
58 <div class="address_format">66 <div class="address_format">
59 <field name="city" placeholder="City"/>67 <field name="city" placeholder="%s" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
60 <field name="state_id" class="oe_no_button" placeholder="State" options='{"no_open": true}'/>68 <field name="state_id" class="oe_no_button" placeholder="%s" options='{"no_open": true}' on_change="onchange_state(state_id)" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
61 <field name="zip" placeholder="ZIP"/>69 <field name="zip" placeholder="%s" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
62 </div>70 </div>
63 """71 """%(city,state,zip)
64 }72 }
65 for k,v in layouts.items():73 for k,v in layouts.items():
66 if fmt and (k in fmt):74 if fmt and (k in fmt):