Merge lp:~sylvain-legal/server-env-tools/7.0-flake8 into lp:~server-env-tools-core-editors/server-env-tools/7.0
- 7.0-flake8
- Merge into 7.0
Status: | Merged |
---|---|
Approved by: | Yannick Vaucher @ Camptocamp |
Approved revision: | 81 |
Merged at revision: | 80 |
Proposed branch: | lp:~sylvain-legal/server-env-tools/7.0-flake8 |
Merge into: | lp:~server-env-tools-core-editors/server-env-tools/7.0 |
Diff against target: |
556 lines (+237/-121) 5 files modified
auth_admin_passkey/tests/test_auth_admin_passkey.py (+1/-1) disable_openerp_online/__openerp__.py (+10/-9) mass_editing/__openerp__.py (+17/-11) mass_editing/mass_editing.py (+66/-46) mass_editing/wizard/mass_editing_wizard.py (+143/-54) |
To merge this branch: | bzr merge lp:~sylvain-legal/server-env-tools/7.0-flake8 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Leonardo Pistone | Approve | ||
Yannick Vaucher @ Camptocamp | code review, no test | Approve | |
Review via email: mp+225456@code.launchpad.net |
Commit message
[REF] flake8 for 'mass_editing', 'auth_admin_
Description of the change
Flake8 for 3 modules:
- mass_editing, auth_admin_passkey, disable_
Sylvain LE GAL (GRAP) (sylvain-legal) wrote : | # |
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
l.330 you need to be sure context is a dict before using get
l.536 you can use dict setter
dict['split_key'] = [(3, id) for id
Thaught this wasn't the target here.
I'll approve already as we want those change to enable travis on github when migrated
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
s/Thaught/Though
Sylvain LE GAL (GRAP) (sylvain-legal) wrote : | # |
Hi, Yannick, Thanks for the review. About you're comment, I agree but I'm not sure that is a good MP to do this kind of change. My MP is just "make 3 modules pep8 compliant". I thought that we have to do distinct MP for distinct work. Don't you think ?
Regards.
Leonardo Pistone (lepistone) wrote : | # |
Hi,
I agree with a lint-only MP like that one (as soon as it doesn't introduce new problems).
Thanks!
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Completely agree that's why you always have my approval.
Preview Diff
1 | === modified file 'auth_admin_passkey/tests/test_auth_admin_passkey.py' |
2 | --- auth_admin_passkey/tests/test_auth_admin_passkey.py 2014-05-14 13:32:27 +0000 |
3 | +++ auth_admin_passkey/tests/test_auth_admin_passkey.py 2014-07-03 11:02:18 +0000 |
4 | @@ -91,7 +91,7 @@ |
5 | Test the correct behaviour of login with 'bad_login' / 'admin'""" |
6 | exception_raised = False |
7 | try: |
8 | - res = self.ru_obj.authenticate(self.db, 'bad_login', 'admin', {}) |
9 | + self.ru_obj.authenticate(self.db, 'bad_login', 'admin', {}) |
10 | except: |
11 | exception_raised = True |
12 | self.assertEqual( |
13 | |
14 | === modified file 'disable_openerp_online/__openerp__.py' |
15 | --- disable_openerp_online/__openerp__.py 2013-12-21 14:01:48 +0000 |
16 | +++ disable_openerp_online/__openerp__.py 2014-07-03 11:02:18 +0000 |
17 | @@ -19,9 +19,9 @@ |
18 | # |
19 | ############################################################################## |
20 | { |
21 | - "name" : "Remove openerp.com bindings", |
22 | - "version" : "1.1", |
23 | - "author" : "Therp BV", |
24 | + "name": "Remove openerp.com bindings", |
25 | + "version": "1.1", |
26 | + "author": "Therp BV", |
27 | "complexity": "normal", |
28 | "description": """ |
29 | This module deactivates all bindings to openerp.com that |
30 | @@ -30,14 +30,15 @@ |
31 | * update notifier code is deactivated and the function is overwritten |
32 | * apps and updates menu items in settings are removed |
33 | * help and account menu items in user menu are removed |
34 | -* prevent lookup of OPW for current database uuid and resulting 'unsupported' warning |
35 | +* prevent lookup of OPW for current database uuid and resulting""" |
36 | + """ 'unsupported' warning |
37 | """, |
38 | - "category" : "", |
39 | - "depends" : [ |
40 | + "category": "", |
41 | + "depends": [ |
42 | 'base', |
43 | 'mail', |
44 | ], |
45 | - "data" : [ |
46 | + "data": [ |
47 | 'data/ir_ui_menu.xml', |
48 | 'data/ir_cron.xml', |
49 | ], |
50 | @@ -51,7 +52,7 @@ |
51 | ], |
52 | "auto_install": False, |
53 | "installable": True, |
54 | - "external_dependencies" : { |
55 | - 'python' : [], |
56 | + "external_dependencies": { |
57 | + 'python': [], |
58 | }, |
59 | } |
60 | |
61 | === modified file 'mass_editing/__openerp__.py' |
62 | --- mass_editing/__openerp__.py 2013-04-12 12:38:39 +0000 |
63 | +++ mass_editing/__openerp__.py 2014-07-03 11:02:18 +0000 |
64 | @@ -2,7 +2,8 @@ |
65 | ############################################################################## |
66 | # |
67 | # This module uses OpenERP, Open Source Management Solution Framework. |
68 | -# Copyright (C) 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>) |
69 | +# Copyright (C): |
70 | +# 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>) |
71 | # |
72 | # This program is free software: you can redistribute it and/or modify |
73 | # it under the terms of the GNU General Public License as published by |
74 | @@ -19,16 +20,21 @@ |
75 | # |
76 | ############################################################################## |
77 | { |
78 | - "name" : "Mass Editing", |
79 | - "version" : "1.3", |
80 | - "author" : "Serpent Consulting Services", |
81 | - "category" : "Tools", |
82 | - "website" : "http://www.serpentcs.com", |
83 | - "description": """This module provides the functionality to add, update or remove the values of more than one records on the fly at the same time. |
84 | - You can configure mass editing for any OpenERP model. |
85 | - The video explaining the features and how-to for OpenERP Version 6 is here http://t.co/wukYMx1A |
86 | - The video explaining the features and how-to for OpenERP Version 7 is here : http://www.youtube.com/watch?v=9BH0o74A748&feature=youtu.be |
87 | - For more details/customization/feedback contact us on contact@serpentcs.com. |
88 | + "name": "Mass Editing", |
89 | + "version": "1.3", |
90 | + "author": "Serpent Consulting Services", |
91 | + "category": "Tools", |
92 | + "website": "http://www.serpentcs.com", |
93 | + "description": """ |
94 | +This module provides the functionality to add, update or remove the values""" |
95 | + """of more than one records on the fly at the same time. |
96 | + You can configure mass editing for any OpenERP model. |
97 | + The video explaining the features and how-to for OpenERP Version 6""" |
98 | + """ is here http://t.co/wukYMx1A |
99 | + The video explaining the features and how-to for OpenERP Version 7 is""" |
100 | + """ here : http://www.youtube.com/watch?v=9BH0o74A748&feature=youtu.be |
101 | + For more details/customization/feedback contact us on""" |
102 | + """ contact@serpentcs.com. |
103 | """, |
104 | 'depends': ['base'], |
105 | 'data': [ |
106 | |
107 | === modified file 'mass_editing/mass_editing.py' |
108 | --- mass_editing/mass_editing.py 2013-05-08 12:41:12 +0000 |
109 | +++ mass_editing/mass_editing.py 2014-07-03 11:02:18 +0000 |
110 | @@ -2,7 +2,8 @@ |
111 | ############################################################################## |
112 | # |
113 | # This module uses OpenERP, Open Source Management Solution Framework. |
114 | -# Copyright (C) 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>) |
115 | +# Copyright (C): |
116 | +# 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>) |
117 | # |
118 | # This program is free software: you can redistribute it and/or modify |
119 | # it under the terms of the GNU General Public License as published by |
120 | @@ -19,37 +20,48 @@ |
121 | # |
122 | ############################################################################## |
123 | |
124 | -from openerp.osv import orm, fields |
125 | -import openerp.tools |
126 | +from openerp.osv import orm, fields, osv |
127 | from openerp.tools.translate import _ |
128 | -from lxml import etree |
129 | + |
130 | |
131 | class ir_model_fields(orm.Model): |
132 | _inherit = 'ir.model.fields' |
133 | - |
134 | - def search(self, cr, uid, args, offset=0, limit=0, order=None, context=None, count=False): |
135 | + |
136 | + def search( |
137 | + self, cr, uid, args, offset=0, limit=0, order=None, context=None, |
138 | + count=False): |
139 | model_domain = [] |
140 | for domain in args: |
141 | - if domain[0] == 'model_id' and domain[2] and type(domain[2]) != list: |
142 | - model_domain += [('model_id', 'in', map(int, domain[2][1:-1].split(',')))] |
143 | + if domain[0] == 'model_id' and domain[2]\ |
144 | + and type(domain[2]) != list: |
145 | + model_domain += [( |
146 | + 'model_id', 'in', map(int, domain[2][1:-1].split(',')))] |
147 | else: |
148 | model_domain.append(domain) |
149 | - return super(ir_model_fields, self).search(cr, uid, model_domain, offset=offset, limit=limit, order=order, context=context, count=count) |
150 | + return super(ir_model_fields, self).search( |
151 | + cr, uid, model_domain, offset=offset, limit=limit, order=order, |
152 | + context=context, count=count) |
153 | |
154 | ir_model_fields() |
155 | |
156 | + |
157 | class mass_object(orm.Model): |
158 | _name = "mass.object" |
159 | |
160 | _columns = { |
161 | - 'name' : fields.char("Name", size=64, required=True, select=1), |
162 | - 'model_id' : fields.many2one('ir.model', 'Model', required=True, select=1), |
163 | - 'field_ids' : fields.many2many('ir.model.fields', 'mass_field_rel', 'mass_id', 'field_id', 'Fields'), |
164 | - 'ref_ir_act_window':fields.many2one('ir.actions.act_window', 'Sidebar Action', readonly=True, |
165 | - help="Sidebar action to make this template available on records \ |
166 | - of the related document model"), |
167 | - 'ref_ir_value':fields.many2one('ir.values', 'Sidebar Button', readonly=True, |
168 | - help="Sidebar button to open the sidebar action"), |
169 | + 'name': fields.char("Name", size=64, required=True, select=1), |
170 | + 'model_id': fields.many2one( |
171 | + 'ir.model', 'Model', required=True, select=1), |
172 | + 'field_ids': fields.many2many( |
173 | + 'ir.model.fields', 'mass_field_rel', 'mass_id', 'field_id', |
174 | + 'Fields'), |
175 | + 'ref_ir_act_window': fields.many2one( |
176 | + 'ir.actions.act_window', 'Sidebar Action', readonly=True, |
177 | + help="Sidebar action to make this template available on records \ |
178 | + of the related document model"), |
179 | + 'ref_ir_value': fields.many2one( |
180 | + 'ir.values', 'Sidebar Button', readonly=True, |
181 | + help="Sidebar button to open the sidebar action"), |
182 | 'model_ids': fields.many2many('ir.model', string='Model List') |
183 | } |
184 | |
185 | @@ -58,60 +70,68 @@ |
186 | ] |
187 | |
188 | def onchange_model(self, cr, uid, ids, model_id, context=None): |
189 | - if context is None: context = {} |
190 | + if context is None: |
191 | + context = {} |
192 | if not model_id: |
193 | return {'value': {'model_ids': [(6, 0, [])]}} |
194 | model_ids = [model_id] |
195 | model_obj = self.pool.get('ir.model') |
196 | - active_model_obj = self.pool.get(model_obj.browse(cr, uid, model_id).model) |
197 | + active_model_obj = self.pool.get(model_obj.browse( |
198 | + cr, uid, model_id).model) |
199 | if active_model_obj._inherits: |
200 | for key, val in active_model_obj._inherits.items(): |
201 | - found_model_ids = model_obj.search(cr, uid, [('model', '=', key)], context=context) |
202 | + found_model_ids = model_obj.search( |
203 | + cr, uid, [('model', '=', key)], context=context) |
204 | model_ids += found_model_ids |
205 | return {'value': {'model_ids': [(6, 0, model_ids)]}} |
206 | |
207 | def create_action(self, cr, uid, ids, context=None): |
208 | vals = {} |
209 | action_obj = self.pool.get('ir.actions.act_window') |
210 | - data_obj = self.pool.get('ir.model.data') |
211 | ir_values_obj = self.pool.get('ir.values') |
212 | for data in self.browse(cr, uid, ids, context=context): |
213 | src_obj = data.model_id.model |
214 | button_name = _('Mass Editing (%s)') % data.name |
215 | vals['ref_ir_act_window'] = action_obj.create(cr, uid, { |
216 | - 'name': button_name, |
217 | - 'type': 'ir.actions.act_window', |
218 | - 'res_model': 'mass.editing.wizard', |
219 | - 'src_model': src_obj, |
220 | - 'view_type': 'form', |
221 | - 'context': "{'mass_editing_object' : %d}" % (data.id), |
222 | - 'view_mode':'form,tree', |
223 | - 'target': 'new', |
224 | - 'auto_refresh':1 |
225 | - }, context) |
226 | + 'name': button_name, |
227 | + 'type': 'ir.actions.act_window', |
228 | + 'res_model': 'mass.editing.wizard', |
229 | + 'src_model': src_obj, |
230 | + 'view_type': 'form', |
231 | + 'context': "{'mass_editing_object' : %d}" % (data.id), |
232 | + 'view_mode': 'form,tree', |
233 | + 'target': 'new', |
234 | + 'auto_refresh': 1, |
235 | + }, context) |
236 | vals['ref_ir_value'] = ir_values_obj.create(cr, uid, { |
237 | - 'name': button_name, |
238 | - 'model': src_obj, |
239 | - 'key2': 'client_action_multi', |
240 | - 'value': "ir.actions.act_window," + str(vals['ref_ir_act_window']), |
241 | - 'object': True, |
242 | - }, context) |
243 | + 'name': button_name, |
244 | + 'model': src_obj, |
245 | + 'key2': 'client_action_multi', |
246 | + 'value': ( |
247 | + "ir.actions.act_window," |
248 | + + str(vals['ref_ir_act_window'])), |
249 | + 'object': True, |
250 | + }, context) |
251 | self.write(cr, uid, ids, { |
252 | - 'ref_ir_act_window': vals.get('ref_ir_act_window', False), |
253 | - 'ref_ir_value': vals.get('ref_ir_value', False), |
254 | - }, context) |
255 | + 'ref_ir_act_window': vals.get('ref_ir_act_window', False), |
256 | + 'ref_ir_value': vals.get('ref_ir_value', False), |
257 | + }, context) |
258 | return True |
259 | |
260 | def unlink_action(self, cr, uid, ids, context=None): |
261 | for template in self.browse(cr, uid, ids, context=context): |
262 | try: |
263 | if template.ref_ir_act_window: |
264 | - self.pool.get('ir.actions.act_window').unlink(cr, uid, template.ref_ir_act_window.id, context) |
265 | + self.pool.get('ir.actions.act_window').unlink( |
266 | + cr, uid, template.ref_ir_act_window.id, context) |
267 | if template.ref_ir_value: |
268 | ir_values_obj = self.pool.get('ir.values') |
269 | - ir_values_obj.unlink(cr, uid, template.ref_ir_value.id, context) |
270 | + ir_values_obj.unlink( |
271 | + cr, uid, template.ref_ir_value.id, context) |
272 | except: |
273 | - raise osv.except_osv(_("Warning"), _("Deletion of the action record failed.")) |
274 | + raise osv.except_osv( |
275 | + _("Warning"), |
276 | + _("Deletion of the action record failed.")) |
277 | return True |
278 | |
279 | def unlink(self, cr, uid, ids, context=None): |
280 | @@ -121,9 +141,9 @@ |
281 | def copy(self, cr, uid, record_id, default=None, context=None): |
282 | if default is None: |
283 | default = {} |
284 | - |
285 | - default.update({'name':'','field_ids': []}) |
286 | - return super(mass_object, self).copy(cr, uid, record_id, default, context) |
287 | + default.update({'name': '', 'field_ids': []}) |
288 | + return super(mass_object, self).copy( |
289 | + cr, uid, record_id, default, context) |
290 | |
291 | mass_object() |
292 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
293 | |
294 | === modified file 'mass_editing/wizard/mass_editing_wizard.py' |
295 | --- mass_editing/wizard/mass_editing_wizard.py 2013-06-13 04:17:19 +0000 |
296 | +++ mass_editing/wizard/mass_editing_wizard.py 2014-07-03 11:02:18 +0000 |
297 | @@ -2,7 +2,8 @@ |
298 | ############################################################################## |
299 | # |
300 | # This module uses OpenERP, Open Source Management Solution Framework. |
301 | -# Copyright (C) 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>) |
302 | +# Copyright (C): |
303 | +# 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>) |
304 | # |
305 | # This program is free software: you can redistribute it and/or modify |
306 | # it under the terms of the GNU General Public License as published by |
307 | @@ -19,80 +20,165 @@ |
308 | # |
309 | ############################################################################## |
310 | |
311 | -from openerp.osv import orm, fields |
312 | +from openerp.osv import orm |
313 | import openerp.tools as tools |
314 | from lxml import etree |
315 | |
316 | + |
317 | class mass_editing_wizard(orm.TransientModel): |
318 | _name = 'mass.editing.wizard' |
319 | |
320 | _columns = { |
321 | } |
322 | |
323 | - def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): |
324 | - result = super(mass_editing_wizard, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu) |
325 | + def fields_view_get( |
326 | + self, cr, uid, view_id=None, view_type='form', context=None, |
327 | + toolbar=False, submenu=False): |
328 | + result = super(mass_editing_wizard, self).fields_view_get( |
329 | + cr, uid, view_id, view_type, context, toolbar, submenu) |
330 | if context.get('mass_editing_object'): |
331 | - mass_object = self.pool.get('mass.object') |
332 | - editing_data = mass_object.browse(cr, uid, context.get('mass_editing_object'), context) |
333 | + mass_object = self.pool.get('mass.object') |
334 | + editing_data = mass_object.browse( |
335 | + cr, uid, context.get('mass_editing_object'), context) |
336 | all_fields = {} |
337 | - xml_form = etree.Element('form', {'string': tools.ustr(editing_data.name), 'version':'7.0'}) |
338 | + xml_form = etree.Element('form', { |
339 | + 'string': tools.ustr(editing_data.name), 'version': '7.0'}) |
340 | xml_group = etree.SubElement(xml_form, 'group', {'colspan': '4'}) |
341 | - etree.SubElement(xml_group, 'label', {'string': '', 'colspan': '2'}) |
342 | + etree.SubElement(xml_group, 'label', { |
343 | + 'string': '', 'colspan': '2'}) |
344 | xml_group = etree.SubElement(xml_form, 'group', {'colspan': '4'}) |
345 | model_obj = self.pool.get(context.get('active_model')) |
346 | field_info = model_obj.fields_get(cr, uid, [], context) |
347 | for field in editing_data.field_ids: |
348 | if field.ttype == "many2many": |
349 | - all_fields[field.name] = field_info[field.name] |
350 | - all_fields["selection__" + field.name] = {'type':'selection', 'string': field_info[field.name]['string'], 'selection':[('set', 'Set'), ('remove_m2m', 'Remove'), ('add', 'Add')]} |
351 | - xml_group = etree.SubElement(xml_group, 'group', {'colspan': '4'}) |
352 | - etree.SubElement(xml_group, 'separator', {'string': field_info[field.name]['string'], 'colspan': '2'}) |
353 | - etree.SubElement(xml_group, 'field', {'name': "selection__" + field.name, 'colspan': '2', 'nolabel':'1'}) |
354 | - etree.SubElement(xml_group, 'field', {'name': field.name, 'colspan':'4', 'nolabel':'1', 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove_m2m')]}"}) |
355 | + all_fields[field.name] = field_info[field.name] |
356 | + all_fields["selection__" + field.name] = { |
357 | + 'type': 'selection', |
358 | + 'string': field_info[field.name]['string'], |
359 | + 'selection': [ |
360 | + ('set', 'Set'), ('remove_m2m', 'Remove'), |
361 | + ('add', 'Add')]} |
362 | + xml_group = etree.SubElement(xml_group, 'group', { |
363 | + 'colspan': '4'}) |
364 | + etree.SubElement(xml_group, 'separator', { |
365 | + 'string': field_info[field.name]['string'], |
366 | + 'colspan': '2'}) |
367 | + etree.SubElement(xml_group, 'field', { |
368 | + 'name': "selection__" + field.name, |
369 | + 'colspan': '2', 'nolabel': '1'}) |
370 | + etree.SubElement(xml_group, 'field', { |
371 | + 'name': field.name, 'colspan': '4', 'nolabel': '1', |
372 | + 'attrs': ( |
373 | + "{'invisible':[('selection__" |
374 | + + field.name + "','=','remove_m2m')]}")}) |
375 | elif field.ttype == "one2many": |
376 | - all_fields["selection__" + field.name] = {'type':'selection', |
377 | - 'string': field_info[field.name]['string'], |
378 | - 'selection':[('set', 'Set'), |
379 | - ('remove', 'Remove')]} |
380 | - all_fields[field.name] = {'type':field.ttype, |
381 | - 'string': field.field_description, |
382 | - 'relation': field.relation} |
383 | - etree.SubElement(xml_group, 'field', |
384 | - {'name': "selection__" + field.name, 'colspan':'2'}) |
385 | - etree.SubElement(xml_group, 'field', |
386 | - {'name': field.name, 'colspan':'4', 'nolabel':'1', |
387 | - 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove_o2m')]}"}) |
388 | + all_fields["selection__" + field.name] = { |
389 | + 'type': 'selection', |
390 | + 'string': field_info[field.name]['string'], |
391 | + 'selection': [('set', 'Set'), ('remove', 'Remove')]} |
392 | + all_fields[field.name] = { |
393 | + 'type': field.ttype, 'string': field.field_description, |
394 | + 'relation': field.relation} |
395 | + etree.SubElement(xml_group, 'field', { |
396 | + 'name': "selection__" + field.name, 'colspan': '2'}) |
397 | + etree.SubElement(xml_group, 'field', { |
398 | + 'name': field.name, 'colspan': '4', 'nolabel': '1', |
399 | + 'attrs': ( |
400 | + "{'invisible':[('selection__" |
401 | + + field.name + "','=','remove_o2m')]}")}) |
402 | elif field.ttype == "many2one": |
403 | - all_fields["selection__" + field.name] = {'type':'selection', 'string': field_info[field.name]['string'], 'selection':[('set', 'Set'), ('remove', 'Remove')]} |
404 | - all_fields[field.name] = {'type':field.ttype, 'string': field.field_description, 'relation': field.relation} |
405 | - etree.SubElement(xml_group, 'field', {'name': "selection__" + field.name, 'colspan':'2'}) |
406 | - etree.SubElement(xml_group, 'field', {'name': field.name, 'nolabel':'1', 'colspan':'2', 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove')]}"}) |
407 | + all_fields["selection__" + field.name] = { |
408 | + 'type': 'selection', |
409 | + 'string': field_info[field.name]['string'], |
410 | + 'selection': [('set', 'Set'), ('remove', 'Remove')]} |
411 | + all_fields[field.name] = { |
412 | + 'type': field.ttype, 'string': field.field_description, |
413 | + 'relation': field.relation} |
414 | + etree.SubElement(xml_group, 'field', { |
415 | + 'name': "selection__" + field.name, 'colspan': '2'}) |
416 | + etree.SubElement(xml_group, 'field', { |
417 | + 'name': field.name, 'nolabel': '1', 'colspan': '2', |
418 | + 'attrs': ( |
419 | + "{'invisible':[('selection__" |
420 | + + field.name + "','=','remove')]}")}) |
421 | elif field.ttype == "char": |
422 | - all_fields["selection__" + field.name] = {'type':'selection', 'string': field_info[field.name]['string'], 'selection':[('set', 'Set'), ('remove', 'Remove')]} |
423 | - all_fields[field.name] = {'type':field.ttype, 'string': field.field_description, 'size': field.size or 256} |
424 | - etree.SubElement(xml_group, 'field', {'name': "selection__" + field.name, 'colspan':'2', 'colspan':'2'}) |
425 | - etree.SubElement(xml_group, 'field', {'name': field.name, 'nolabel':'1', 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove')]}", 'colspan':'2'}) |
426 | + all_fields["selection__" + field.name] = { |
427 | + 'type': 'selection', |
428 | + 'string': field_info[field.name]['string'], |
429 | + 'selection': [('set', 'Set'), ('remove', 'Remove')]} |
430 | + all_fields[field.name] = { |
431 | + 'type': field.ttype, 'string': field.field_description, |
432 | + 'size': field.size or 256} |
433 | + etree.SubElement(xml_group, 'field', { |
434 | + 'name': "selection__" + field.name, |
435 | + 'colspan': '2', |
436 | + 'colspan': '2'}) |
437 | + etree.SubElement(xml_group, 'field', { |
438 | + 'name': field.name, 'nolabel': '1', |
439 | + 'attrs': ( |
440 | + "{'invisible':[('selection__" |
441 | + + field.name + "','=','remove')]}"), |
442 | + 'colspan': '2'}) |
443 | elif field.ttype == 'selection': |
444 | - all_fields["selection__" + field.name] = {'type':'selection', 'string': field_info[field.name]['string'], 'selection':[('set', 'Set'), ('remove', 'Remove')]} |
445 | - etree.SubElement(xml_group, 'field', {'name': "selection__" + field.name, 'colspan':'2'}) |
446 | - etree.SubElement(xml_group, 'field', {'name': field.name, 'nolabel':'1', 'colspan':'2', 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove')]}"}) |
447 | - all_fields[field.name] = {'type':field.ttype, 'string': field.field_description, 'selection': field_info[field.name]['selection']} |
448 | + all_fields["selection__" + field.name] = { |
449 | + 'type': 'selection', |
450 | + 'string': field_info[field.name]['string'], |
451 | + 'selection': [('set', 'Set'), ('remove', 'Remove')]} |
452 | + etree.SubElement(xml_group, 'field', { |
453 | + 'name': "selection__" + field.name, 'colspan': '2'}) |
454 | + etree.SubElement(xml_group, 'field', { |
455 | + 'name': field.name, 'nolabel': '1', 'colspan': '2', |
456 | + 'attrs': ( |
457 | + "{'invisible':[('selection__" |
458 | + + field.name + "','=','remove')]}")}) |
459 | + all_fields[field.name] = { |
460 | + 'type': field.ttype, |
461 | + 'string': field.field_description, |
462 | + 'selection': field_info[field.name]['selection']} |
463 | else: |
464 | - all_fields[field.name] = {'type':field.ttype, 'string': field.field_description} |
465 | - all_fields["selection__" + field.name] = {'type':'selection', 'string': field_info[field.name]['string'], 'selection':[('set', 'Set'), ('remove', 'Remove')]} |
466 | + all_fields[field.name] = { |
467 | + 'type': field.ttype, 'string': field.field_description} |
468 | + all_fields["selection__" + field.name] = { |
469 | + 'type': 'selection', |
470 | + 'string': field_info[field.name]['string'], |
471 | + 'selection': [('set', 'Set'), ('remove', 'Remove')]} |
472 | if field.ttype == 'text': |
473 | - xml_group = etree.SubElement(xml_group, 'group', {'colspan': '6'}) |
474 | - etree.SubElement(xml_group, 'separator', {'string': all_fields[field.name]['string'], 'colspan': '2'}) |
475 | - etree.SubElement(xml_group, 'field', {'name': "selection__" + field.name, 'colspan': '2', 'nolabel':'1'}) |
476 | - etree.SubElement(xml_group, 'field', {'name': field.name, 'colspan':'4', 'nolabel':'1', 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove')]}"}) |
477 | + xml_group = etree.SubElement(xml_group, 'group', { |
478 | + 'colspan': '6'}) |
479 | + etree.SubElement(xml_group, 'separator', { |
480 | + 'string': all_fields[field.name]['string'], |
481 | + 'colspan': '2'}) |
482 | + etree.SubElement(xml_group, 'field', { |
483 | + 'name': "selection__" + field.name, |
484 | + 'colspan': '2', 'nolabel': '1'}) |
485 | + etree.SubElement(xml_group, 'field', { |
486 | + 'name': field.name, 'colspan': '4', 'nolabel': '1', |
487 | + 'attrs': ( |
488 | + "{'invisible':[('selection__" |
489 | + + field.name + "','=','remove')]}")}) |
490 | else: |
491 | - all_fields["selection__" + field.name] = {'type':'selection', 'string': field_info[field.name]['string'], 'selection':[('set', 'Set'), ('remove', 'Remove')]} |
492 | - etree.SubElement(xml_group, 'field', {'name': "selection__" + field.name, 'colspan': '2', }) |
493 | - etree.SubElement(xml_group, 'field', {'name': field.name, 'nolabel':'1', 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove')]}", 'colspan': '2', }) |
494 | - etree.SubElement(xml_form, 'separator', {'string' : '', 'colspan': '4'}) |
495 | + all_fields["selection__" + field.name] = { |
496 | + 'type': 'selection', |
497 | + 'string': field_info[field.name]['string'], |
498 | + 'selection': [( |
499 | + 'set', 'Set'), ('remove', 'Remove')]} |
500 | + etree.SubElement(xml_group, 'field', { |
501 | + 'name': "selection__" + field.name, |
502 | + 'colspan': '2', }) |
503 | + etree.SubElement(xml_group, 'field', { |
504 | + 'name': field.name, 'nolabel': '1', |
505 | + 'attrs': ( |
506 | + "{'invisible':[('selection__" |
507 | + + field.name + "','=','remove')]}"), |
508 | + 'colspan': '2', }) |
509 | + etree.SubElement( |
510 | + xml_form, 'separator', {'string': '', 'colspan': '4'}) |
511 | xml_group3 = etree.SubElement(xml_form, 'footer', {}) |
512 | - etree.SubElement(xml_group3, 'button', {'string' :'Close', 'icon': "gtk-close", 'special' :'cancel'}) |
513 | - etree.SubElement(xml_group3, 'button', {'string' :'Apply', 'icon': "gtk-execute", 'type' :'object', 'name':"action_apply"}) |
514 | + etree.SubElement(xml_group3, 'button', { |
515 | + 'string': 'Close', 'icon': "gtk-close", 'special': 'cancel'}) |
516 | + etree.SubElement(xml_group3, 'button', { |
517 | + 'string': 'Apply', 'icon': "gtk-execute", |
518 | + 'type': 'object', 'name': "action_apply"}) |
519 | root = xml_form.getroottree() |
520 | result['arch'] = etree.tostring(root) |
521 | result['fields'] = all_fields |
522 | @@ -102,7 +188,7 @@ |
523 | if context.get('active_model') and context.get('active_ids'): |
524 | model_obj = self.pool.get(context.get('active_model')) |
525 | dict = {} |
526 | - for key , val in vals.items(): |
527 | + for key, val in vals.items(): |
528 | if key.startswith('selection__'): |
529 | split_key = key.split('__', 1)[1] |
530 | if val == 'set': |
531 | @@ -110,19 +196,22 @@ |
532 | elif val == 'remove': |
533 | dict.update({split_key: False}) |
534 | elif val == 'remove_m2m': |
535 | - dict.update({split_key: [(3, id) for id in vals.get(split_key, False)[0][2]]}) |
536 | + dict.update({split_key: [ |
537 | + (3, id) for id in vals.get( |
538 | + split_key, False)[0][2]]}) |
539 | elif val == 'add': |
540 | m2m_list = [] |
541 | for m2m_id in vals.get(split_key, False)[0][2]: |
542 | m2m_list.append((4, m2m_id)) |
543 | dict.update({split_key: m2m_list}) |
544 | if dict: |
545 | - model_obj.write(cr, uid, context.get('active_ids'), dict, context) |
546 | + model_obj.write( |
547 | + cr, uid, context.get('active_ids'), dict, context) |
548 | result = super(mass_editing_wizard, self).create(cr, uid, {}, context) |
549 | return result |
550 | |
551 | def action_apply(self, cr, uid, ids, context=None): |
552 | - return {'type': 'ir.actions.act_window_close'} |
553 | + return {'type': 'ir.actions.act_window_close'} |
554 | |
555 | mass_editing_wizard() |
556 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
If you want to review this MP, better bzr branch locally this branch and use a meld-like tools to see the differencies, because the diff tools of launchpad is not very good for that.
Regards.