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/ (+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:

Description of the change


     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 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.


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 :


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 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.

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
1=== modified file 'board/'
2--- board/ 2012-02-08 01:27:26 +0000
3+++ board/ 2012-07-11 10:14:38 +0000
4@@ -22,6 +22,7 @@
5 from osv import fields, osv
6 import time
7 import tools
8+from lxml import etree
10 class board_board(osv.osv):
11 """
12@@ -119,19 +120,29 @@
13 res = {}
14 res = super(board_board, self).fields_view_get(cr, user, view_id, view_type,\
15 context, toolbar=toolbar, submenu=submenu)
17 vids = self.pool.get('ir.ui.view.custom').search(cr, user,\
18 [('user_id', '=', user), ('ref_id' ,'=', view_id)])
19+ def encode(s):
20+ if isinstance(s, unicode):
21+ return s.encode('utf8')
22+ return s
24 if vids:
25 view_id = vids[0]
26 arch = self.pool.get('ir.ui.view.custom').browse(cr, user, view_id, context=context)
28+ fields = self.fields_get(cr, user, None, context)
29+ xarch = etree.fromstring(encode(arch.arch))
30+ fields_def = self.__view_look_dom(cr, user, xarch, view_id, False, fields, context=context)
31+ arch = etree.tostring(xarch, encoding="utf-8").replace('\t', '')
32 res['custom_view_id'] = view_id
33- res['arch'] = arch.arch
34- res['arch'] = self._arch_preprocessing(cr, user, res['arch'], context=context)
35+ res['arch'] = arch
36+ else:
37+ res['arch'] = self._arch_preprocessing(cr, user, res['arch'], context=context)
39 res['toolbar'] = {'print': [], 'action': [], 'relate': []}
40 return res
43 def _arch_preprocessing(self, cr, user, arch, context=None):
44 from lxml import etree
45 def remove_unauthorized_children(node):
46@@ -150,8 +161,62 @@
47 archnode = etree.fromstring(encode(arch))
48 return etree.tostring(remove_unauthorized_children(archnode),pretty_print=True)
52+ def __view_look_dom(self, cr, user, node, view_id, in_tree_view, model_fields, context=None):
53+ """ Return the description of the fields in the node.
55+ In a normal call to this method, node is a complete view architecture
56+ but it is actually possible to give some sub-node (this is used so
57+ that the method can call itself recursively).
59+ Originally, the field descriptions are drawn from the node itself.
60+ But there is now some code calling fields_get() in order to merge some
61+ of those information in the architecture.
63+ """
64+ if context is None:
65+ context = {}
66+ result = False
67+ fields = {}
68+ children = True
70+ if node.tag in ('form', 'tree'):
71+ result = self.view_header_get(cr, user, False, node.tag, context)
72+ if result:
73+ node.set('string', result)
74+ in_tree_view = node.tag == 'tree'
76+ # translate view
77+ if 'lang' in context:
78+ if node.get('string') and not result:
79+ trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('string'))
80+ if trans == node.get('string') and ('base_model_name' in context):
81+ # If translation is same as source, perhaps we'd have more luck with the alternative model name
82+ # (in case we are in a mixed situation, such as an inherited view where parent_view.model != model
83+ trans = self.pool.get('ir.translation')._get_source(cr, user, context['base_model_name'], 'view', context['lang'], node.get('string'))
84+ if trans:
85+ node.set('string', trans)
86+ if node.get('confirm'):
87+ trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('confirm'))
88+ if trans:
89+ node.set('confirm', trans)
90+ if node.get('sum'):
91+ trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('sum'))
92+ if trans:
93+ node.set('sum', trans)
94+ if node.get('avg'):
95+ trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('avg'))
96+ if trans:
97+ node.set('avg', trans)
98+ if node.get('help'):
99+ trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('help'))
100+ if trans:
101+ node.set('help', trans)
103+ for f in node:
104+ if children or (node.tag == 'field' and f.tag in ('filter','separator')):
105+ fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
107+ return fields
109 _columns = {
110 'name': fields.char('Dashboard', size=64, required=True),