Merge lp:~unifield-team/unifield-wm/uf-1786 into lp:unifield-wm
- uf-1786
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Dev Team | Pending | ||
Review via email:
|
Commit message
Description of the change
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
1 | === modified file 'msf_audittrail/audittrail.py' | |||
2 | --- msf_audittrail/audittrail.py 2013-09-05 15:26:55 +0000 | |||
3 | +++ msf_audittrail/audittrail.py 2013-10-14 12:23:55 +0000 | |||
4 | @@ -29,6 +29,7 @@ | |||
5 | 29 | import pooler | 29 | import pooler |
6 | 30 | import time | 30 | import time |
7 | 31 | import tools | 31 | import tools |
8 | 32 | import logging | ||
9 | 32 | from tools.safe_eval import safe_eval as eval | 33 | from tools.safe_eval import safe_eval as eval |
10 | 33 | import logging | 34 | import logging |
11 | 34 | 35 | ||
12 | @@ -114,6 +115,63 @@ | |||
13 | 114 | 115 | ||
14 | 115 | account_period() | 116 | account_period() |
15 | 116 | 117 | ||
16 | 118 | |||
17 | 119 | class ir_module(osv.osv): | ||
18 | 120 | _inherit = 'ir.module.module' | ||
19 | 121 | |||
20 | 122 | def update_translations(self, cr, uid, ids, filter_lang=None, context=None): | ||
21 | 123 | ''' | ||
22 | 124 | Override the lang install to apply the translation on Track changes ir.actions | ||
23 | 125 | ''' | ||
24 | 126 | res = super(ir_module, self).update_translations(cr, uid, ids, filter_lang=None, context=context) | ||
25 | 127 | |||
26 | 128 | msf_profile_id = self.search(cr, uid, [('name', '=', 'msf_profile')], context=context) | ||
27 | 129 | |||
28 | 130 | if not msf_profile_id or msf_profile_id[0] not in ids: | ||
29 | 131 | return res | ||
30 | 132 | |||
31 | 133 | tr_obj = self.pool.get('ir.translation') | ||
32 | 134 | act_obj = self.pool.get('ir.actions.act_window') | ||
33 | 135 | language_obj = self.browse(cr, uid, ids)[0] | ||
34 | 136 | src = 'Track changes' | ||
35 | 137 | if not filter_lang: | ||
36 | 138 | pool = pooler.get_pool(cr.dbname) | ||
37 | 139 | lang_obj = pool.get('res.lang') | ||
38 | 140 | lang_ids = lang_obj.search(cr, uid, [('translatable', '=', True)]) | ||
39 | 141 | filter_lang = [lang.code for lang in lang_obj.browse(cr, uid, lang_ids)] | ||
40 | 142 | elif not isinstance(filter_lang, (list, tuple)): | ||
41 | 143 | filter_lang = [filter_lang] | ||
42 | 144 | |||
43 | 145 | for lang in filter_lang: | ||
44 | 146 | trans_ids = tr_obj.search(cr, uid, [('lang', '=', lang), | ||
45 | 147 | ('xml_id', '=', 'action_audittrail_view_log'), | ||
46 | 148 | ('module', '=', 'msf_audittrail')], context=context) | ||
47 | 149 | if trans_ids: | ||
48 | 150 | logger = logging.getLogger('i18n') | ||
49 | 151 | logger.info('module msf_profile: loading translation for \'Track changes\' ir.actions.act_window for language %s', lang) | ||
50 | 152 | trans = tr_obj.browse(cr, uid, trans_ids[0], context=context).value | ||
51 | 153 | # Search all actions to rename | ||
52 | 154 | act_ids = act_obj.search(cr, uid, [('name', '=', src)], context=context) | ||
53 | 155 | for act in act_ids: | ||
54 | 156 | exist = tr_obj.search(cr, uid, [('lang', '=', lang), | ||
55 | 157 | ('type', '=', 'model'), | ||
56 | 158 | ('src', '=', src), | ||
57 | 159 | ('name', '=', 'ir.actions.act_window,name'), | ||
58 | 160 | ('value', '=', trans), | ||
59 | 161 | ('res_id', '=', act)], context=context) | ||
60 | 162 | if not exist: | ||
61 | 163 | tr_obj.create(cr, uid, {'lang': lang, | ||
62 | 164 | 'src': src, | ||
63 | 165 | 'name': 'ir.actions.act_window,name', | ||
64 | 166 | 'type': 'model', | ||
65 | 167 | 'value': trans, | ||
66 | 168 | 'res_id': act}, context=context) | ||
67 | 169 | |||
68 | 170 | return res | ||
69 | 171 | |||
70 | 172 | ir_module() | ||
71 | 173 | |||
72 | 174 | |||
73 | 117 | class audittrail_log_sequence(osv.osv): | 175 | class audittrail_log_sequence(osv.osv): |
74 | 118 | _name = 'audittrail.log.sequence' | 176 | _name = 'audittrail.log.sequence' |
75 | 119 | _rec_name = 'model' | 177 | _rec_name = 'model' |
76 | @@ -212,13 +270,14 @@ | |||
77 | 212 | self.write(cr, uid, [thisrule.id], {"state": "draft"}) | 270 | self.write(cr, uid, [thisrule.id], {"state": "draft"}) |
78 | 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') |
79 | 214 | val = { | 272 | val = { |
81 | 215 | "name": 'Track changes', | 273 | "name": _('Track changes'), |
82 | 216 | "res_model": 'audittrail.log.line', | 274 | "res_model": 'audittrail.log.line', |
83 | 217 | "src_model": thisrule.object_id.model, | 275 | "src_model": thisrule.object_id.model, |
84 | 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, |
85 | 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)]" |
86 | 220 | 278 | ||
87 | 221 | } | 279 | } |
88 | 280 | |||
89 | 222 | action_id = obj_action.create(cr, uid, val) | 281 | action_id = obj_action.create(cr, uid, val) |
90 | 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}) |
91 | 224 | keyword = 'client_action_relate' | 283 | keyword = 'client_action_relate' |
92 | @@ -351,6 +410,77 @@ | |||
93 | 351 | 410 | ||
94 | 352 | return res | 411 | return res |
95 | 353 | 412 | ||
96 | 413 | def _get_field_name(self, cr, uid, ids, field_name, arg, context=None): | ||
97 | 414 | ''' | ||
98 | 415 | Return the name of the field in the user language | ||
99 | 416 | ''' | ||
100 | 417 | tr_obj = self.pool.get('ir.translation') | ||
101 | 418 | |||
102 | 419 | res = {} | ||
103 | 420 | lang = self.pool.get('res.users').browse(cr, uid, uid, context=context).context_lang | ||
104 | 421 | |||
105 | 422 | for line in self.browse(cr, uid, ids, context=context): | ||
106 | 423 | res[line.id] = False | ||
107 | 424 | |||
108 | 425 | # Translation of field name | ||
109 | 426 | if line.field_id: | ||
110 | 427 | field_name = '%s,%s' % (line.object_id.model, line.field_id.name) | ||
111 | 428 | tr_ids = tr_obj.search(cr, uid, [('name', '=', field_name), | ||
112 | 429 | ('lang', '=', lang), | ||
113 | 430 | ('type', '=', 'field'), | ||
114 | 431 | ('src', '=', line.field_id.field_description)], context=context) | ||
115 | 432 | if tr_ids: | ||
116 | 433 | res[line.id] = tr_obj.browse(cr, uid, tr_ids[0], context=context).value | ||
117 | 434 | |||
118 | 435 | # Translation of one2many object if any | ||
119 | 436 | if not res[line.id] and line.fct_object_id: | ||
120 | 437 | field_name = '%s,%s' % (line.fct_object_id.model, line.field_id.name) | ||
121 | 438 | tr_ids = tr_obj.search(cr, uid, [('name', '=', field_name), | ||
122 | 439 | ('lang', '=', lang), | ||
123 | 440 | ('type', '=', 'field'), | ||
124 | 441 | ('src', '=', line.field_id.field_description)], context=context) | ||
125 | 442 | if tr_ids: | ||
126 | 443 | res[line.id] = tr_obj.browse(cr, uid, tr_ids[0], context=context).value | ||
127 | 444 | |||
128 | 445 | # Translation of main object | ||
129 | 446 | if not res[line.id] and (line.object_id or line.fct_object_id): | ||
130 | 447 | tr_ids = tr_obj.search(cr, uid, [('name', '=', 'ir.model,name'), | ||
131 | 448 | ('lang', '=', lang), | ||
132 | 449 | ('type', '=', 'model'), | ||
133 | 450 | ('src', '=', line.name)], context=context) | ||
134 | 451 | if tr_ids: | ||
135 | 452 | res[line.id] = tr_obj.browse(cr, uid, tr_ids[0], context=context).value | ||
136 | 453 | |||
137 | 454 | # No translation | ||
138 | 455 | if not res[line.id]: | ||
139 | 456 | res[line.id] = line.field_description | ||
140 | 457 | |||
141 | 458 | return res | ||
142 | 459 | |||
143 | 460 | def _src_field_name(self, cr, uid, obj, name, args, context=None): | ||
144 | 461 | ''' | ||
145 | 462 | Search field description with the user lang | ||
146 | 463 | ''' | ||
147 | 464 | tr_obj = self.pool.get('ir.translation') | ||
148 | 465 | |||
149 | 466 | res = [] | ||
150 | 467 | lang = self.pool.get('res.users').browse(cr, uid, uid, context=context).context_lang | ||
151 | 468 | |||
152 | 469 | for arg in args: | ||
153 | 470 | if arg[0] == 'trans_field_description': | ||
154 | 471 | tr_fields = tr_obj.search(cr, uid, [('lang', '=', lang), | ||
155 | 472 | ('type', 'in', ['field', 'model']), | ||
156 | 473 | ('value', arg[1], arg[2])], context=context) | ||
157 | 474 | |||
158 | 475 | field_names = [] | ||
159 | 476 | for f in tr_obj.browse(cr, uid, tr_fields, context=context): | ||
160 | 477 | field_names.append(f.src) | ||
161 | 478 | |||
162 | 479 | res = [('field_description', 'in', field_names)] | ||
163 | 480 | |||
164 | 481 | return res | ||
165 | 482 | |||
166 | 483 | |||
167 | 354 | _columns = { | 484 | _columns = { |
168 | 355 | 'name': fields.char(size=256, string='Description', required=True), | 485 | 'name': fields.char(size=256, string='Description', required=True), |
169 | 356 | 'object_id': fields.many2one('ir.model', string='Object'), | 486 | 'object_id': fields.many2one('ir.model', string='Object'), |
170 | @@ -367,6 +497,7 @@ | |||
171 | 367 | 'old_value': fields.text("Old Value"), | 497 | 'old_value': fields.text("Old Value"), |
172 | 368 | 'new_value': fields.text("New Value"), | 498 | 'new_value': fields.text("New Value"), |
173 | 369 | 'field_description': fields.char('Field Description', size=64), | 499 | 'field_description': fields.char('Field Description', size=64), |
174 | 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), | ||
175 | 370 | 'sub_obj_name': fields.char(size=64, string='Order line'), | 501 | 'sub_obj_name': fields.char(size=64, string='Order line'), |
176 | 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), |
177 | 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) |
178 | 373 | 504 | ||
179 | === modified file 'msf_audittrail/audittrail_view.xml' | |||
180 | --- msf_audittrail/audittrail_view.xml 2012-09-12 14:01:30 +0000 | |||
181 | +++ msf_audittrail/audittrail_view.xml 2013-10-14 12:23:55 +0000 | |||
182 | @@ -103,7 +103,7 @@ | |||
183 | 103 | <field name="timestamp" /> | 103 | <field name="timestamp" /> |
184 | 104 | <newline /> | 104 | <newline /> |
185 | 105 | <field name="sub_obj_name" /> | 105 | <field name="sub_obj_name" /> |
187 | 106 | <field name="field_description" /> | 106 | <field name="trans_field_description" /> |
188 | 107 | <field name="old_value_text" /> | 107 | <field name="old_value_text" /> |
189 | 108 | <field name="new_value_text" /> | 108 | <field name="new_value_text" /> |
190 | 109 | <field name="user_id" /> | 109 | <field name="user_id" /> |
191 | @@ -122,7 +122,7 @@ | |||
192 | 122 | <field name="timestamp" /> | 122 | <field name="timestamp" /> |
193 | 123 | <field name="sub_obj_name" /> | 123 | <field name="sub_obj_name" /> |
194 | 124 | <field name="method" /> | 124 | <field name="method" /> |
196 | 125 | <field name="field_description" /> | 125 | <field name="trans_field_description" /> |
197 | 126 | <field name="old_value_fct" string="Old value" /> | 126 | <field name="old_value_fct" string="Old value" /> |
198 | 127 | <field name="new_value_fct" string="New value" /> | 127 | <field name="new_value_fct" string="New value" /> |
199 | 128 | <!-- <field name="old_value_text" invisible="1" /> | 128 | <!-- <field name="old_value_text" invisible="1" /> |
200 | 129 | 129 | ||
201 | === modified file 'msf_audittrail/report/log_line.rml' | |||
202 | --- msf_audittrail/report/log_line.rml 2012-03-29 08:15:57 +0000 | |||
203 | +++ msf_audittrail/report/log_line.rml 2013-10-14 12:23:55 +0000 | |||
204 | @@ -105,7 +105,7 @@ | |||
205 | 105 | <para style="P4">[[ get_method(line, 'method') ]]</para> | 105 | <para style="P4">[[ get_method(line, 'method') ]]</para> |
206 | 106 | </td> | 106 | </td> |
207 | 107 | <td> | 107 | <td> |
209 | 108 | <para style="P4left">[[ line.field_description ]]</para> | 108 | <para style="P4left">[[ line.trans_field_description ]]</para> |
210 | 109 | </td> | 109 | </td> |
211 | 110 | <td> | 110 | <td> |
212 | 111 | <para style="P4">[[ line.old_value_fct ]]</para> | 111 | <para style="P4">[[ line.old_value_fct ]]</para> |
213 | 112 | 112 | ||
214 | === modified file 'msf_profile/i18n/fr_MF.po' | |||
215 | --- msf_profile/i18n/fr_MF.po 2013-09-06 08:05:11 +0000 | |||
216 | +++ msf_profile/i18n/fr_MF.po 2013-10-14 12:23:55 +0000 | |||
217 | @@ -24521,6 +24521,12 @@ | |||
218 | 24521 | msgstr "Message SMS" | 24521 | msgstr "Message SMS" |
219 | 24522 | 24522 | ||
220 | 24523 | #. module: msf_audittrail | 24523 | #. module: msf_audittrail |
221 | 24524 | #: code:addons/msf_audittrail/audittrail.py:214 | ||
222 | 24525 | #, python-format | ||
223 | 24526 | msgid "Track changes" | ||
224 | 24527 | msgstr "Suivi des Modifications" | ||
225 | 24528 | |||
226 | 24529 | #. module: msf_audittrail | ||
227 | 24524 | #: model:ir.actions.act_window,name:msf_audittrail.action_audittrail_view_log | 24530 | #: model:ir.actions.act_window,name:msf_audittrail.action_audittrail_view_log |
228 | 24525 | msgid "Track changes" | 24531 | msgid "Track changes" |
229 | 24526 | msgstr "Suivi des Modifications" | 24532 | msgstr "Suivi des Modifications" |
230 | @@ -27388,6 +27394,7 @@ | |||
231 | 27388 | 27394 | ||
232 | 27389 | #. module: msf_audittrail | 27395 | #. module: msf_audittrail |
233 | 27390 | #: field:audittrail.log.line,field_description:0 | 27396 | #: field:audittrail.log.line,field_description:0 |
234 | 27397 | #: field:audittrail.log.line,trans_field_description:0 | ||
235 | 27391 | msgid "Field Description" | 27398 | msgid "Field Description" |
236 | 27392 | msgstr "Description du Champ" | 27399 | msgstr "Description du Champ" |
237 | 27393 | 27400 |