Merge lp:~unifield-team/unifield-wm/uf-1786 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 1814
Proposed branch: lp:~unifield-team/unifield-wm/uf-1786
Merge into: lp:unifield-wm
Diff against target: 236 lines (+142/-4)
4 files modified
msf_audittrail/audittrail.py (+132/-1)
msf_audittrail/audittrail_view.xml (+2/-2)
msf_audittrail/report/log_line.rml (+1/-1)
msf_profile/i18n/fr_MF.po (+7/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/uf-1786
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+190936@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'msf_audittrail/audittrail.py'
--- msf_audittrail/audittrail.py 2013-09-05 15:26:55 +0000
+++ msf_audittrail/audittrail.py 2013-10-14 12:23:55 +0000
@@ -29,6 +29,7 @@
29import pooler29import pooler
30import time30import time
31import tools31import tools
32import logging
32from tools.safe_eval import safe_eval as eval33from tools.safe_eval import safe_eval as eval
33import logging34import logging
3435
@@ -114,6 +115,63 @@
114115
115account_period()116account_period()
116117
118
119class ir_module(osv.osv):
120 _inherit = 'ir.module.module'
121
122 def update_translations(self, cr, uid, ids, filter_lang=None, context=None):
123 '''
124 Override the lang install to apply the translation on Track changes ir.actions
125 '''
126 res = super(ir_module, self).update_translations(cr, uid, ids, filter_lang=None, context=context)
127
128 msf_profile_id = self.search(cr, uid, [('name', '=', 'msf_profile')], context=context)
129
130 if not msf_profile_id or msf_profile_id[0] not in ids:
131 return res
132
133 tr_obj = self.pool.get('ir.translation')
134 act_obj = self.pool.get('ir.actions.act_window')
135 language_obj = self.browse(cr, uid, ids)[0]
136 src = 'Track changes'
137 if not filter_lang:
138 pool = pooler.get_pool(cr.dbname)
139 lang_obj = pool.get('res.lang')
140 lang_ids = lang_obj.search(cr, uid, [('translatable', '=', True)])
141 filter_lang = [lang.code for lang in lang_obj.browse(cr, uid, lang_ids)]
142 elif not isinstance(filter_lang, (list, tuple)):
143 filter_lang = [filter_lang]
144
145 for lang in filter_lang:
146 trans_ids = tr_obj.search(cr, uid, [('lang', '=', lang),
147 ('xml_id', '=', 'action_audittrail_view_log'),
148 ('module', '=', 'msf_audittrail')], context=context)
149 if trans_ids:
150 logger = logging.getLogger('i18n')
151 logger.info('module msf_profile: loading translation for \'Track changes\' ir.actions.act_window for language %s', lang)
152 trans = tr_obj.browse(cr, uid, trans_ids[0], context=context).value
153 # Search all actions to rename
154 act_ids = act_obj.search(cr, uid, [('name', '=', src)], context=context)
155 for act in act_ids:
156 exist = tr_obj.search(cr, uid, [('lang', '=', lang),
157 ('type', '=', 'model'),
158 ('src', '=', src),
159 ('name', '=', 'ir.actions.act_window,name'),
160 ('value', '=', trans),
161 ('res_id', '=', act)], context=context)
162 if not exist:
163 tr_obj.create(cr, uid, {'lang': lang,
164 'src': src,
165 'name': 'ir.actions.act_window,name',
166 'type': 'model',
167 'value': trans,
168 'res_id': act}, context=context)
169
170 return res
171
172ir_module()
173
174
117class audittrail_log_sequence(osv.osv):175class audittrail_log_sequence(osv.osv):
118 _name = 'audittrail.log.sequence'176 _name = 'audittrail.log.sequence'
119 _rec_name = 'model'177 _rec_name = 'model'
@@ -212,13 +270,14 @@
212 self.write(cr, uid, [thisrule.id], {"state": "draft"})270 self.write(cr, uid, [thisrule.id], {"state": "draft"})
213 search_view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'msf_audittrail', 'view_audittrail_log_line_search')271 search_view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'msf_audittrail', 'view_audittrail_log_line_search')
214 val = {272 val = {
215 "name": 'Track changes',273 "name": _('Track changes'),
216 "res_model": 'audittrail.log.line',274 "res_model": 'audittrail.log.line',
217 "src_model": thisrule.object_id.model,275 "src_model": thisrule.object_id.model,
218 "search_view_id": search_view_id and search_view_id[1] or False,276 "search_view_id": search_view_id and search_view_id[1] or False,
219 "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"277 "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
220278
221 }279 }
280
222 action_id = obj_action.create(cr, uid, val)281 action_id = obj_action.create(cr, uid, val)
223 self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id": action_id})282 self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id": action_id})
224 keyword = 'client_action_relate'283 keyword = 'client_action_relate'
@@ -351,6 +410,77 @@
351 410
352 return res411 return res
353412
413 def _get_field_name(self, cr, uid, ids, field_name, arg, context=None):
414 '''
415 Return the name of the field in the user language
416 '''
417 tr_obj = self.pool.get('ir.translation')
418
419 res = {}
420 lang = self.pool.get('res.users').browse(cr, uid, uid, context=context).context_lang
421
422 for line in self.browse(cr, uid, ids, context=context):
423 res[line.id] = False
424
425 # Translation of field name
426 if line.field_id:
427 field_name = '%s,%s' % (line.object_id.model, line.field_id.name)
428 tr_ids = tr_obj.search(cr, uid, [('name', '=', field_name),
429 ('lang', '=', lang),
430 ('type', '=', 'field'),
431 ('src', '=', line.field_id.field_description)], context=context)
432 if tr_ids:
433 res[line.id] = tr_obj.browse(cr, uid, tr_ids[0], context=context).value
434
435 # Translation of one2many object if any
436 if not res[line.id] and line.fct_object_id:
437 field_name = '%s,%s' % (line.fct_object_id.model, line.field_id.name)
438 tr_ids = tr_obj.search(cr, uid, [('name', '=', field_name),
439 ('lang', '=', lang),
440 ('type', '=', 'field'),
441 ('src', '=', line.field_id.field_description)], context=context)
442 if tr_ids:
443 res[line.id] = tr_obj.browse(cr, uid, tr_ids[0], context=context).value
444
445 # Translation of main object
446 if not res[line.id] and (line.object_id or line.fct_object_id):
447 tr_ids = tr_obj.search(cr, uid, [('name', '=', 'ir.model,name'),
448 ('lang', '=', lang),
449 ('type', '=', 'model'),
450 ('src', '=', line.name)], context=context)
451 if tr_ids:
452 res[line.id] = tr_obj.browse(cr, uid, tr_ids[0], context=context).value
453
454 # No translation
455 if not res[line.id]:
456 res[line.id] = line.field_description
457
458 return res
459
460 def _src_field_name(self, cr, uid, obj, name, args, context=None):
461 '''
462 Search field description with the user lang
463 '''
464 tr_obj = self.pool.get('ir.translation')
465
466 res = []
467 lang = self.pool.get('res.users').browse(cr, uid, uid, context=context).context_lang
468
469 for arg in args:
470 if arg[0] == 'trans_field_description':
471 tr_fields = tr_obj.search(cr, uid, [('lang', '=', lang),
472 ('type', 'in', ['field', 'model']),
473 ('value', arg[1], arg[2])], context=context)
474
475 field_names = []
476 for f in tr_obj.browse(cr, uid, tr_fields, context=context):
477 field_names.append(f.src)
478
479 res = [('field_description', 'in', field_names)]
480
481 return res
482
483
354 _columns = {484 _columns = {
355 'name': fields.char(size=256, string='Description', required=True),485 'name': fields.char(size=256, string='Description', required=True),
356 'object_id': fields.many2one('ir.model', string='Object'),486 'object_id': fields.many2one('ir.model', string='Object'),
@@ -367,6 +497,7 @@
367 'old_value': fields.text("Old Value"),497 'old_value': fields.text("Old Value"),
368 'new_value': fields.text("New Value"),498 'new_value': fields.text("New Value"),
369 'field_description': fields.char('Field Description', size=64),499 'field_description': fields.char('Field Description', size=64),
500 'trans_field_description': fields.function(_get_field_name, fnct_search=_src_field_name, method=True, type='char', size=64, string='Field Description', store=False),
370 'sub_obj_name': fields.char(size=64, string='Order line'),501 'sub_obj_name': fields.char(size=64, string='Order line'),
371# 'sub_obj_name': fields.function(fnct=_get_name_line, fnct_search=_search_name_line, method=True, type='char', string='Order line', store=False),502# 'sub_obj_name': fields.function(fnct=_get_name_line, fnct_search=_search_name_line, method=True, type='char', string='Order line', store=False),
372 # These 3 fields allows the computation of the name of the subobject (sub_obj_name)503 # These 3 fields allows the computation of the name of the subobject (sub_obj_name)
373504
=== modified file 'msf_audittrail/audittrail_view.xml'
--- msf_audittrail/audittrail_view.xml 2012-09-12 14:01:30 +0000
+++ msf_audittrail/audittrail_view.xml 2013-10-14 12:23:55 +0000
@@ -103,7 +103,7 @@
103 <field name="timestamp" />103 <field name="timestamp" />
104 <newline />104 <newline />
105 <field name="sub_obj_name" />105 <field name="sub_obj_name" />
106 <field name="field_description" />106 <field name="trans_field_description" />
107 <field name="old_value_text" />107 <field name="old_value_text" />
108 <field name="new_value_text" />108 <field name="new_value_text" />
109 <field name="user_id" />109 <field name="user_id" />
@@ -122,7 +122,7 @@
122 <field name="timestamp" />122 <field name="timestamp" />
123 <field name="sub_obj_name" />123 <field name="sub_obj_name" />
124 <field name="method" />124 <field name="method" />
125 <field name="field_description" />125 <field name="trans_field_description" />
126 <field name="old_value_fct" string="Old value" />126 <field name="old_value_fct" string="Old value" />
127 <field name="new_value_fct" string="New value" />127 <field name="new_value_fct" string="New value" />
128 <!-- <field name="old_value_text" invisible="1" />128 <!-- <field name="old_value_text" invisible="1" />
129129
=== modified file 'msf_audittrail/report/log_line.rml'
--- msf_audittrail/report/log_line.rml 2012-03-29 08:15:57 +0000
+++ msf_audittrail/report/log_line.rml 2013-10-14 12:23:55 +0000
@@ -105,7 +105,7 @@
105 <para style="P4">[[ get_method(line, 'method') ]]</para>105 <para style="P4">[[ get_method(line, 'method') ]]</para>
106 </td>106 </td>
107 <td>107 <td>
108 <para style="P4left">[[ line.field_description ]]</para>108 <para style="P4left">[[ line.trans_field_description ]]</para>
109 </td>109 </td>
110 <td>110 <td>
111 <para style="P4">[[ line.old_value_fct ]]</para>111 <para style="P4">[[ line.old_value_fct ]]</para>
112112
=== modified file 'msf_profile/i18n/fr_MF.po'
--- msf_profile/i18n/fr_MF.po 2013-09-06 08:05:11 +0000
+++ msf_profile/i18n/fr_MF.po 2013-10-14 12:23:55 +0000
@@ -24521,6 +24521,12 @@
24521msgstr "Message SMS"24521msgstr "Message SMS"
2452224522
24523#. module: msf_audittrail24523#. module: msf_audittrail
24524#: code:addons/msf_audittrail/audittrail.py:214
24525#, python-format
24526msgid "Track changes"
24527msgstr "Suivi des Modifications"
24528
24529#. module: msf_audittrail
24524#: model:ir.actions.act_window,name:msf_audittrail.action_audittrail_view_log24530#: model:ir.actions.act_window,name:msf_audittrail.action_audittrail_view_log
24525msgid "Track changes"24531msgid "Track changes"
24526msgstr "Suivi des Modifications"24532msgstr "Suivi des Modifications"
@@ -27388,6 +27394,7 @@
2738827394
27389#. module: msf_audittrail27395#. module: msf_audittrail
27390#: field:audittrail.log.line,field_description:027396#: field:audittrail.log.line,field_description:0
27397#: field:audittrail.log.line,trans_field_description:0
27391msgid "Field Description"27398msgid "Field Description"
27392msgstr "Description du Champ"27399msgstr "Description du Champ"
2739327400

Subscribers

People subscribed via source and target branches