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

Proposed by Dhruti Shastri(OpenERP) on 2013-04-03
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 on 2013-06-07
Naresh(OpenERP) 2013-04-03 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) on 2013-05-14

[FIX] merge with main server

4920. By Purnendu Singh (OpenERP) on 2013-05-15

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

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,

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) on 2013-05-15

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

4919. By Purnendu Singh (OpenERP) on 2013-05-14

[FIX] merge with main server

4918. By Dhruti Shastri(OpenERP) on 2013-04-03

[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
1=== modified file 'openerp/addons/base/res/res_partner.py'
2--- openerp/addons/base/res/res_partner.py 2013-04-25 17:12:38 +0000
3+++ openerp/addons/base/res/res_partner.py 2013-05-15 08:06:26 +0000
4@@ -33,34 +33,42 @@
5 from openerp.tools.yaml_import import is_comment
6
7 class format_address(object):
8- def fields_view_get_address(self, cr, uid, arch, context={}):
9+ def fields_view_get_address(self, cr, uid, arch, context=None):
10+ if context is None: context={}
11 user_obj = self.pool.get('res.users')
12- fmt = user_obj.browse(cr, SUPERUSER_ID, uid, context).company_id.country_id
13+ translation_pool = self.pool.get('ir.translation')
14+
15+ fmt = user_obj.browse(cr, SUPERUSER_ID, uid, context=context).company_id.country_id
16 fmt = fmt and fmt.address_format
17+ lang = context.get('lang', False)
18+ city = translation_pool._get_source(cr, uid, self._name, 'view', lang, 'City')
19+ zip = translation_pool._get_source(cr, uid, self._name, 'view', lang, 'ZIP')
20+ state = translation_pool._get_source(cr, uid, self._name, 'view', lang, 'State')
21+
22 layouts = {
23 '%(city)s %(state_code)s\n%(zip)s': """
24 <div class="address_format">
25- <field name="city" placeholder="City" style="width: 50%%"/>
26- <field name="state_id" class="oe_no_button" placeholder="State" style="width: 47%%" options='{"no_open": true}'/>
27+ <field name="city" placeholder="%s" style="width: 50%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
28+ <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)]}"/>
29 <br/>
30- <field name="zip" placeholder="ZIP"/>
31+ <field name="zip" placeholder="%s" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
32 </div>
33- """,
34+ """%(city,state,zip),
35 '%(zip)s %(city)s': """
36 <div class="address_format">
37- <field name="zip" placeholder="ZIP" style="width: 40%%"/>
38- <field name="city" placeholder="City" style="width: 57%%"/>
39+ <field name="zip" placeholder="%s" style="width: 40%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
40+ <field name="city" placeholder="%s" style="width: 57%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
41 <br/>
42- <field name="state_id" class="oe_no_button" placeholder="State" options='{"no_open": true}'/>
43+ <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)]}"/>
44 </div>
45- """,
46+ """%(zip,city,state),
47 '%(city)s\n%(state_name)s\n%(zip)s': """
48 <div class="address_format">
49- <field name="city" placeholder="City"/>
50- <field name="state_id" class="oe_no_button" placeholder="State" options='{"no_open": true}'/>
51- <field name="zip" placeholder="ZIP"/>
52+ <field name="city" placeholder="%s" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
53+ <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)]}"/>
54+ <field name="zip" placeholder="%s" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
55 </div>
56- """
57+ """%(city,state,zip)
58 }
59 for k,v in layouts.items():
60 if fmt and (k in fmt):