Merge lp:~openerp-dev/openobject-addons/6.1-opw-576076-bth into lp:openobject-addons/6.1

Proposed by Bhumi Thakkar (Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-576076-bth
Merge into: lp:openobject-addons/6.1
Diff against target: 110 lines (+71/-6)
1 file modified
board/board.py (+71/-6)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-576076-bth
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+113916@code.launchpad.net

Description of the change

Hello,

     Add to dashboard filter not translated when language is changed.

1. Create new database select english language.
2. Laod an official translation, language for ex: dutch.
3. Select language Dutch from setting => user.
4. Sales => Sale => Lead => From filter select Add to dashboard.
5. Click on menu sale.

Observed: 'Added action is in dutch and existed actions are in english. when click on reset then actions are in current language. If i changed language than also new created actions are not translated it is in from which language is created. It will not translated.'
Expected: 'Added action and existed actions should displayed in current language and when reset at that time should also displayed in current language and when changed the language at that time should displayed in changed language.'

when select add to dashboard from filter existed actions and new created actions are stored with context which contains current language in ir.ui.view.custom model and when retrieve records from that model have translate in current language and parsing xml architecture than return.
Same as doing in fields_view_get from server side for while calling in board.py file in fields_view_get for ir.ui.view model for that it is done and return architecture in current language and parsed. But then after browse record from ir.ui.view.custom model and return arch but not return in current language and also architecture is not parsed.

Thanks.

To post a comment you must log in.
6882. By Bhumi Thakkar (Open ERP)

[FIX] Remove unnecessary code.

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello,

This bug was qualified as Confirmed on Trunk (means still existing and reproducible). A Merge Proposal for trunk was created to fix it. Here is the link to follow the MP on Launchpad https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-576076-port-cha/+merge/138910 and be informed once it's been merged in trunk: ... If this Merge Proposal could not be merged in v6.1 at the release of v7.0, it will be closed.

Thanks,
Naresh Soni

Unmerged revisions

6882. By Bhumi Thakkar (Open ERP)

[FIX] Remove unnecessary code.

6881. By Bhumi Thakkar (Open ERP)

[FIX] Add Translation and xml parsing for ir.ui.view.custom model.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'board/board.py'
--- board/board.py 2012-02-08 01:27:26 +0000
+++ board/board.py 2012-07-11 10:14:38 +0000
@@ -22,6 +22,7 @@
22from osv import fields, osv22from osv import fields, osv
23import time23import time
24import tools24import tools
25from lxml import etree
2526
26class board_board(osv.osv):27class board_board(osv.osv):
27 """28 """
@@ -119,19 +120,29 @@
119 res = {}120 res = {}
120 res = super(board_board, self).fields_view_get(cr, user, view_id, view_type,\121 res = super(board_board, self).fields_view_get(cr, user, view_id, view_type,\
121 context, toolbar=toolbar, submenu=submenu)122 context, toolbar=toolbar, submenu=submenu)
122
123 vids = self.pool.get('ir.ui.view.custom').search(cr, user,\123 vids = self.pool.get('ir.ui.view.custom').search(cr, user,\
124 [('user_id', '=', user), ('ref_id' ,'=', view_id)])124 [('user_id', '=', user), ('ref_id' ,'=', view_id)])
125 def encode(s):
126 if isinstance(s, unicode):
127 return s.encode('utf8')
128 return s
129
125 if vids:130 if vids:
126 view_id = vids[0]131 view_id = vids[0]
127 arch = self.pool.get('ir.ui.view.custom').browse(cr, user, view_id, context=context)132 arch = self.pool.get('ir.ui.view.custom').browse(cr, user, view_id, context=context)
133
134 fields = self.fields_get(cr, user, None, context)
135 xarch = etree.fromstring(encode(arch.arch))
136 fields_def = self.__view_look_dom(cr, user, xarch, view_id, False, fields, context=context)
137 arch = etree.tostring(xarch, encoding="utf-8").replace('\t', '')
128 res['custom_view_id'] = view_id138 res['custom_view_id'] = view_id
129 res['arch'] = arch.arch139 res['arch'] = arch
130 res['arch'] = self._arch_preprocessing(cr, user, res['arch'], context=context)140 else:
141 res['arch'] = self._arch_preprocessing(cr, user, res['arch'], context=context)
142
131 res['toolbar'] = {'print': [], 'action': [], 'relate': []}143 res['toolbar'] = {'print': [], 'action': [], 'relate': []}
132 return res144 return res
133145
134
135 def _arch_preprocessing(self, cr, user, arch, context=None):146 def _arch_preprocessing(self, cr, user, arch, context=None):
136 from lxml import etree147 from lxml import etree
137 def remove_unauthorized_children(node):148 def remove_unauthorized_children(node):
@@ -150,8 +161,62 @@
150 archnode = etree.fromstring(encode(arch))161 archnode = etree.fromstring(encode(arch))
151 return etree.tostring(remove_unauthorized_children(archnode),pretty_print=True)162 return etree.tostring(remove_unauthorized_children(archnode),pretty_print=True)
152163
153164 def __view_look_dom(self, cr, user, node, view_id, in_tree_view, model_fields, context=None):
154165 """ Return the description of the fields in the node.
166
167 In a normal call to this method, node is a complete view architecture
168 but it is actually possible to give some sub-node (this is used so
169 that the method can call itself recursively).
170
171 Originally, the field descriptions are drawn from the node itself.
172 But there is now some code calling fields_get() in order to merge some
173 of those information in the architecture.
174
175 """
176 if context is None:
177 context = {}
178 result = False
179 fields = {}
180 children = True
181
182 if node.tag in ('form', 'tree'):
183 result = self.view_header_get(cr, user, False, node.tag, context)
184 if result:
185 node.set('string', result)
186 in_tree_view = node.tag == 'tree'
187
188 # translate view
189 if 'lang' in context:
190 if node.get('string') and not result:
191 trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('string'))
192 if trans == node.get('string') and ('base_model_name' in context):
193 # If translation is same as source, perhaps we'd have more luck with the alternative model name
194 # (in case we are in a mixed situation, such as an inherited view where parent_view.model != model
195 trans = self.pool.get('ir.translation')._get_source(cr, user, context['base_model_name'], 'view', context['lang'], node.get('string'))
196 if trans:
197 node.set('string', trans)
198 if node.get('confirm'):
199 trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('confirm'))
200 if trans:
201 node.set('confirm', trans)
202 if node.get('sum'):
203 trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('sum'))
204 if trans:
205 node.set('sum', trans)
206 if node.get('avg'):
207 trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('avg'))
208 if trans:
209 node.set('avg', trans)
210 if node.get('help'):
211 trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('help'))
212 if trans:
213 node.set('help', trans)
214
215 for f in node:
216 if children or (node.tag == 'field' and f.tag in ('filter','separator')):
217 fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
218
219 return fields
155220
156 _columns = {221 _columns = {
157 'name': fields.char('Dashboard', size=64, required=True),222 'name': fields.char('Dashboard', size=64, required=True),