Merge lp:~therp-nl/openupgrade-server/8.0-openupgrade_records_style into lp:~openupgrade-committers/openupgrade-server/8.0

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 5145
Proposed branch: lp:~therp-nl/openupgrade-server/8.0-openupgrade_records_style
Merge into: lp:~openupgrade-committers/openupgrade-server/8.0
Diff against target: 670 lines (+142/-102)
10 files modified
openerp/addons/openupgrade_records/__openerp__.py (+3/-3)
openerp/addons/openupgrade_records/__terp__.py (+3/-3)
openerp/addons/openupgrade_records/lib/apriori.py (+0/-5)
openerp/addons/openupgrade_records/lib/compare.py (+28/-20)
openerp/addons/openupgrade_records/model/__init__.py (+0/-1)
openerp/addons/openupgrade_records/model/analysis_wizard.py (+18/-12)
openerp/addons/openupgrade_records/model/comparison_config.py (+24/-16)
openerp/addons/openupgrade_records/model/generate_records_wizard.py (+15/-11)
openerp/addons/openupgrade_records/model/install_all_wizard.py (+31/-20)
openerp/addons/openupgrade_records/model/openupgrade_record.py (+20/-11)
To merge this branch: bzr merge lp:~therp-nl/openupgrade-server/8.0-openupgrade_records_style
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Review via email: mp+218278@code.launchpad.net

Description of the change

- Try not to import deprecated API: osv.osv and friends
- Reset apriori knowledge for the 8.0 edition
- Flake8

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/openupgrade_records/__openerp__.py'
2--- openerp/addons/openupgrade_records/__openerp__.py 2014-04-08 10:54:25 +0000
3+++ openerp/addons/openupgrade_records/__openerp__.py 2014-05-05 12:51:20 +0000
4@@ -2,7 +2,7 @@
5 ##############################################################################
6 #
7 # OpenERP, Open Source Management Solution
8-# This module Copyright (C) 2012 OpenUpgrade community
9+# This module Copyright (C) 2012-2014 OpenUpgrade community
10 # https://launchpad.net/~openupgrade-committers
11 #
12 # Contributors:
13@@ -28,7 +28,7 @@
14 'name': 'OpenUpgrade Records',
15 'version': '0.2',
16 'category': 'Normal',
17- 'description': """Allow OpenUpgrade records to be
18+ 'description': """Allow OpenUpgrade records to be
19 stored in the database and compare with other servers.
20
21 This module depends on OpenERP client lib:
22@@ -57,7 +57,7 @@
23 'installable': True,
24 'auto_install': False,
25 'external_dependencies': {
26- 'python' : ['openerplib'],
27+ 'python': ['openerplib'],
28 },
29 }
30 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
31
32=== modified file 'openerp/addons/openupgrade_records/__terp__.py'
33--- openerp/addons/openupgrade_records/__terp__.py 2014-04-08 10:54:25 +0000
34+++ openerp/addons/openupgrade_records/__terp__.py 2014-05-05 12:51:20 +0000
35@@ -2,7 +2,7 @@
36 ##############################################################################
37 #
38 # OpenERP, Open Source Management Solution
39-# This module Copyright (C) 2012 OpenUpgrade community
40+# This module Copyright (C) 2012-2014 OpenUpgrade community
41 # https://launchpad.net/~openupgrade-committers
42 #
43 # Contributors:
44@@ -28,7 +28,7 @@
45 'name': 'OpenUpgrade Records',
46 'version': '0.2',
47 'category': 'Normal',
48- 'description': """Allow OpenUpgrade records to be
49+ 'description': """Allow OpenUpgrade records to be
50 stored in the database and compare with other servers.
51
52 This module depends on OpenERP client lib:
53@@ -57,7 +57,7 @@
54 'installable': True,
55 'auto_install': False,
56 'external_dependencies': {
57- 'python' : ['openerplib'],
58+ 'python': ['openerplib'],
59 },
60 }
61 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
62
63=== modified file 'openerp/addons/openupgrade_records/lib/apriori.py'
64--- openerp/addons/openupgrade_records/lib/apriori.py 2014-04-08 10:54:25 +0000
65+++ openerp/addons/openupgrade_records/lib/apriori.py 2014-05-05 12:51:20 +0000
66@@ -3,11 +3,6 @@
67 """
68
69 renamed_modules = {
70- 'account_coda': 'l10n_be_coda',
71- 'base_crypt': 'auth_crypt',
72- 'mrp_subproduct': 'mrp_byproduct',
73- 'users_ldap': 'auth_ldap',
74- 'wiki': 'document_page',
75 }
76
77 renamed_models = {
78
79=== modified file 'openerp/addons/openupgrade_records/lib/compare.py'
80--- openerp/addons/openupgrade_records/lib/compare.py 2014-04-08 10:54:25 +0000
81+++ openerp/addons/openupgrade_records/lib/compare.py 2014-05-05 12:51:20 +0000
82@@ -45,10 +45,12 @@
83 'inherits',
84 ]
85
86+
87 def module_map(module):
88 return apriori.renamed_modules.get(
89 module, module)
90
91+
92 def compare_records(dict_old, dict_new, fields):
93 """
94 Check equivalence of two OpenUpgrade field representations
95@@ -70,6 +72,7 @@
96 return False
97 return True
98
99+
100 def search(item, item_list, fields):
101 """
102 Find a match of a dictionary in a list of similar dictionaries
103@@ -82,6 +85,7 @@
104 return i
105 return None
106
107+
108 def fieldprint(old, new, field, text, reprs):
109 fieldrepr = "%s (%s)" % (old['field'], old['type'])
110 repr = '%s / %s / %s' % (
111@@ -94,6 +98,7 @@
112 "%s: %s is now \'%s\' ('%s')" % (
113 repr, field, new[field], old[field]))
114
115+
116 def report_generic(new, old, attrs, reprs):
117 for attr in attrs:
118 if attr == 'required':
119@@ -113,6 +118,7 @@
120 if old[attr] != new[attr]:
121 fieldprint(old, new, attr, None, reprs)
122
123+
124 def compare_sets(old_records, new_records):
125 """
126 Compare a set of OpenUpgrade field representations.
127@@ -126,15 +132,15 @@
128 for record in old_records + new_records:
129 record['matched'] = False
130 origlen = len(old_records)
131- new_models = set([ column['model'] for column in new_records ])
132- old_models = set([ column['model'] for column in old_records ])
133+ new_models = set([column['model'] for column in new_records])
134+ old_models = set([column['model'] for column in old_records])
135
136 matched_direct = 0
137 matched_other_module = 0
138 matched_other_type = 0
139 matched_other_name = 0
140 in_obsolete_models = 0
141-
142+
143 obsolete_models = []
144 for model in old_models:
145 if model not in new_models:
146@@ -149,7 +155,7 @@
147 for model in new_models:
148 if model not in old_models:
149 reprs['general'].append('new model %s' % model)
150-
151+
152 def match(match_fields, report_fields, warn=False):
153 count = 0
154 for column in copy.copy(old_records):
155@@ -166,17 +172,20 @@
156
157 matched_direct = match(
158 ['module', 'mode', 'model', 'field'],
159- ['relation', 'type', 'selection_keys', 'inherits', 'isfunction', 'required'])
160+ ['relation', 'type', 'selection_keys', 'inherits',
161+ 'isfunction', 'required'])
162
163 # other module, same type and operation
164 matched_other_module = match(
165 ['mode', 'model', 'field', 'type'],
166- ['module', 'relation', 'selection_keys', 'inherits', 'isfunction', 'required'])
167+ ['module', 'relation', 'selection_keys', 'inherits',
168+ 'isfunction', 'required'])
169
170 # other module, same operation, other type
171 matched_other_type = match(
172 ['mode', 'model', 'field'],
173- ['relation', 'type', 'selection_keys', 'inherits', 'isfunction', 'required'])
174+ ['relation', 'type', 'selection_keys', 'inherits',
175+ 'isfunction', 'required'])
176
177 # fields with other names
178 #matched_other_name = match(
179@@ -209,18 +218,19 @@
180 ), reprs)
181
182 for line in [
183- "# %d fields matched," % (origlen - len(old_records)),
184- "# Direct match: %d" % matched_direct,
185- "# Found in other module: %d" % matched_other_module,
186- "# Found with different type: %d" % matched_other_type,
187- "# Found with different name: %d" % matched_other_name,
188- "# In obsolete models: %d" % in_obsolete_models,
189- "# Not matched: %d" % len(old_records),
190- "# New columns: %d" % len(new_records),
191- ]:
192+ "# %d fields matched," % (origlen - len(old_records)),
193+ "# Direct match: %d" % matched_direct,
194+ "# Found in other module: %d" % matched_other_module,
195+ "# Found with different type: %d" % matched_other_type,
196+ "# Found with different name: %d" % matched_other_name,
197+ "# In obsolete models: %d" % in_obsolete_models,
198+ "# Not matched: %d" % len(old_records),
199+ "# New columns: %d" % len(new_records)
200+ ]:
201 reprs['general'].append(line)
202 return reprs
203
204+
205 def compare_xml_sets(old_records, new_records):
206 reprs = {}
207 match_fields = ['module', 'model', 'name']
208@@ -241,10 +251,8 @@
209 )
210 for entry in sorted_records:
211 if 'old' in entry:
212- content = 'DEL %s: %s' % (entry['model'],
213- entry['name'])
214+ content = 'DEL %s: %s' % (entry['model'], entry['name'])
215 elif 'new' in entry:
216- content = 'NEW %s: %s' % (entry['model'],
217- entry['name'])
218+ content = 'NEW %s: %s' % (entry['model'], entry['name'])
219 reprs.setdefault(module_map(entry['module']), []).append(content)
220 return reprs
221
222=== modified file 'openerp/addons/openupgrade_records/model/__init__.py'
223--- openerp/addons/openupgrade_records/model/__init__.py 2014-04-08 10:54:25 +0000
224+++ openerp/addons/openupgrade_records/model/__init__.py 2014-05-05 12:51:20 +0000
225@@ -3,4 +3,3 @@
226 import analysis_wizard
227 import generate_records_wizard
228 import install_all_wizard
229-
230
231=== modified file 'openerp/addons/openupgrade_records/model/analysis_wizard.py'
232--- openerp/addons/openupgrade_records/model/analysis_wizard.py 2014-04-08 10:54:25 +0000
233+++ openerp/addons/openupgrade_records/model/analysis_wizard.py 2014-05-05 12:51:20 +0000
234@@ -2,7 +2,7 @@
235 ##############################################################################
236 #
237 # OpenERP, Open Source Management Solution
238-# This module Copyright (C) 2012 OpenUpgrade community
239+# This module Copyright (C) 2012-2014 OpenUpgrade community
240 # https://launchpad.net/~openupgrade-committers
241 #
242 # Contributors:
243@@ -24,18 +24,20 @@
244 ##############################################################################
245
246 import os
247-from openerp.osv import osv, fields
248
249 try:
250+ from openerp.osv.orm import TransientModel
251+ from openerp.osv import fields
252 from openerp.addons.openupgrade_records.lib import compare
253- from openerp.addons.openupgrade_records.lib import apriori
254 from openerp.addons import get_module_path
255 except ImportError:
256+ from osv.osv import osv_memory as TransientModel
257+ from osv import fields
258 from openupgrade_records.lib import compare
259- from openupgrade_records.lib import apriori
260 from addons import get_module_path
261
262-class openupgrade_analysis_wizard(osv.osv_memory):
263+
264+class openupgrade_analysis_wizard(TransientModel):
265 _name = 'openupgrade.analysis.wizard'
266 _description = 'OpenUpgrade Analysis Wizard'
267 _columns = {
268@@ -62,8 +64,8 @@
269 perform the comparison and register the resulting
270 change set
271 """
272- def write_file(
273- module, version, contents, filename='openupgrade_analysis.txt'):
274+ def write_file(module, version, contents,
275+ filename='openupgrade_analysis.txt'):
276 module_path = get_module_path(module)
277 if not module_path:
278 return "ERROR: could not find module path:\n"
279@@ -94,7 +96,8 @@
280 # Retrieve field representations and compare
281 remote_records = remote_record_obj.field_dump(context)
282 local_records = local_record_obj.field_dump(cr, uid, context)
283- modules_record = set([record['module'] for record in remote_records + local_records])
284+ modules_record = set([record['module']
285+ for record in remote_records + local_records])
286 res = compare.compare_sets(remote_records, local_records)
287
288 # Retrieve xml id representations and compare
289@@ -113,7 +116,9 @@
290 for x in remote_record_obj.read(
291 remote_xml_record_ids, fields)
292 ]
293- modules_xml_records = set([record['module'] for record in remote_xml_records + local_xml_records])
294+ modules_xml_records = set(
295+ [record['module']
296+ for record in remote_xml_records + local_xml_records])
297 res_xml = compare.compare_xml_sets(
298 remote_xml_records, local_xml_records)
299
300@@ -122,12 +127,14 @@
301 module_obj = self.pool.get('ir.module.module')
302 module_ids = module_obj.search(
303 cr, uid, [('state', '=', 'installed')])
304- modules = dict([(x['name'], x) for x in module_obj.read(cr, uid, module_ids)])
305+ modules = dict(
306+ [(x['name'], x) for x in module_obj.read(cr, uid, module_ids)])
307 general = ''
308 for key in keys:
309 contents = "---Fields in module '%s'---\n" % key
310 if key in res:
311- contents += '\n'.join([unicode(line) for line in sorted(res[key])])
312+ contents += '\n'.join(
313+ [unicode(line) for line in sorted(res[key])])
314 if res[key]:
315 contents += '\n'
316 contents += "---XML records in module '%s'---\n" % key
317@@ -178,4 +185,3 @@
318 return result
319
320 openupgrade_analysis_wizard()
321-
322
323=== modified file 'openerp/addons/openupgrade_records/model/comparison_config.py'
324--- openerp/addons/openupgrade_records/model/comparison_config.py 2014-04-08 10:54:25 +0000
325+++ openerp/addons/openupgrade_records/model/comparison_config.py 2014-05-05 12:51:20 +0000
326@@ -2,7 +2,7 @@
327 ##############################################################################
328 #
329 # OpenERP, Open Source Management Solution
330-# This module Copyright (C) 2012 OpenUpgrade community
331+# This module Copyright (C) 2012-2014 OpenUpgrade community
332 # https://launchpad.net/~openupgrade-committers
333 #
334 # Contributors:
335@@ -23,11 +23,18 @@
336 #
337 ##############################################################################
338
339-from openerp.osv import osv, fields
340 import openerplib
341-from openerp.tools.translate import _
342-
343-class openupgrade_comparison_config(osv.osv):
344+try:
345+ from openerp.osv.orm import Model, except_orm
346+ from openerp.osv import fields
347+ from openerp.tools.translate import _
348+except ImportError:
349+ from osv.osv import osv as Model, except_osv as except_orm
350+ from osv import fields
351+ from tools.translate import _
352+
353+
354+class openupgrade_comparison_config(Model):
355 _name = 'openupgrade.comparison.config'
356 _columns = {
357 'name': fields.char('Name', size=64),
358@@ -39,7 +46,8 @@
359 'Protocol', required=True),
360 'database': fields.char('Database', size=64, required=True),
361 'username': fields.char('Username', size=24, required=True),
362- 'password': fields.char('Password', size=24, required=True, password=True),
363+ 'password': fields.char('Password', size=24, required=True,
364+ password=True),
365 'last_log': fields.text('Last log'),
366 }
367 _defaults = {
368@@ -49,16 +57,16 @@
369
370 def get_connection(self, cr, uid, ids, context=None):
371 if not ids:
372- raise osv.except_osv(
373+ raise except_orm(
374 _("Cannot connect"), _("Invalid id passed."))
375 conf = self.read(cr, uid, ids[0], context=None)
376 return openerplib.get_connection(
377- hostname=conf['server'],
378- database=conf['database'],
379- login=conf['username'],
380- password=conf['password'],
381- port=conf['port'],
382- )
383+ hostname=conf['server'],
384+ database=conf['database'],
385+ login=conf['username'],
386+ password=conf['password'],
387+ port=conf['port'],
388+ )
389
390 def test_connection(self, cr, uid, ids, context=None):
391 try:
392@@ -67,13 +75,13 @@
393 ids = user_model.search([("login", "=", "admin")])
394 user_info = user_model.read(ids[0], ["name"])
395 except Exception, e:
396- raise osv.except_osv(
397+ raise except_orm(
398 _("Connection failed."), unicode(e))
399- raise osv.except_osv(
400+ raise except_orm(
401 _("Connection succesful."),
402 _("%s is connected.") % user_info["name"]
403 )
404-
405+
406 def analyze(self, cr, uid, ids, context=None):
407 """
408 Run the analysis wizard
409
410=== modified file 'openerp/addons/openupgrade_records/model/generate_records_wizard.py'
411--- openerp/addons/openupgrade_records/model/generate_records_wizard.py 2014-04-08 10:54:25 +0000
412+++ openerp/addons/openupgrade_records/model/generate_records_wizard.py 2014-05-05 12:51:20 +0000
413@@ -2,7 +2,7 @@
414 ##############################################################################
415 #
416 # OpenERP, Open Source Management Solution
417-# This module Copyright (C) 2012 OpenUpgrade community
418+# This module Copyright (C) 2012-2014 OpenUpgrade community
419 # https://launchpad.net/~openupgrade-committers
420 #
421 # Contributors:
422@@ -23,19 +23,24 @@
423 #
424 ##############################################################################
425
426-import os
427-from openerp.osv import osv, fields
428-from openerp import pooler
429 try:
430+ from openerp.osv.orm import TransientModel, except_orm
431+ from openerp.osv import fields
432 from openerp.openupgrade import openupgrade_tools
433+ from openerp import pooler
434 except ImportError:
435+ from osv.osv import osv_memory as TransientModel, except_osv as except_orm
436+ from osv import fields
437 from openupgrade import openupgrade_tools
438-
439-class generate_records_wizard(osv.osv_memory):
440+ import pooler
441+
442+
443+class generate_records_wizard(TransientModel):
444 _name = 'openupgrade.generate.records.wizard'
445 _description = 'OpenUpgrade Generate Records Wizard'
446 _columns = {
447- 'state': fields.selection([('init', 'init'), ('ready', 'ready')], 'State'),
448+ 'state': fields.selection(
449+ [('init', 'init'), ('ready', 'ready')], 'State'),
450 }
451 _defaults = {
452 'state': lambda *a: 'init',
453@@ -53,7 +58,7 @@
454 """
455 # Truncate the records table
456 if (openupgrade_tools.table_exists(cr, 'openupgrade_attribute') and
457- openupgrade_tools.table_exists(cr, 'openupgrade_record')):
458+ openupgrade_tools.table_exists(cr, 'openupgrade_record')):
459 cr.execute(
460 'TRUNCATE openupgrade_attribute, openupgrade_record;'
461 )
462@@ -71,8 +76,8 @@
463 if module_ids:
464 modules = module_obj.read(
465 cr, uid, module_ids, ['name'], context=context)
466- raise except_osv(
467- "Cannot reliably generate records",
468+ raise except_orm(
469+ "Cannot reliably generate records",
470 ("Cannot seem to install or upgrade modules " +
471 ', '.join([x['name'] for x in modules])))
472 # Now reinitialize all installed modules
473@@ -87,4 +92,3 @@
474 return True
475
476 generate_records_wizard()
477-
478
479=== modified file 'openerp/addons/openupgrade_records/model/install_all_wizard.py'
480--- openerp/addons/openupgrade_records/model/install_all_wizard.py 2014-04-08 10:54:25 +0000
481+++ openerp/addons/openupgrade_records/model/install_all_wizard.py 2014-05-05 12:51:20 +0000
482@@ -2,7 +2,7 @@
483 ##############################################################################
484 #
485 # OpenERP, Open Source Management Solution
486-# This module Copyright (C) 2012 OpenUpgrade community
487+# This module Copyright (C) 2012-2014 OpenUpgrade community
488 # https://launchpad.net/~openupgrade-committers
489 #
490 # Contributors:
491@@ -24,22 +24,29 @@
492 ##############################################################################
493
494 import time
495-import os
496-from openerp.osv import osv, fields
497-from openerp import pooler
498-
499-class install_all_wizard(osv.osv_memory):
500+try:
501+ from openerp.osv.orm import TransientModel
502+ from openerp.osv import fields
503+ from openerp import pooler
504+except ImportError:
505+ from osv.osv import osv_memory as TransientModel
506+ from osv import fields
507+ import pooler
508+
509+
510+class install_all_wizard(TransientModel):
511 _name = 'openupgrade.install.all.wizard'
512 _description = 'OpenUpgrade Install All Wizard'
513 _columns = {
514- 'state': fields.selection([('init', 'init'), ('ready', 'ready')], 'State', readonly=True),
515- 'to_install': fields.integer('Number of modules to install', readonly=True),
516+ 'state': fields.selection(
517+ [('init', 'init'), ('ready', 'ready')], 'State', readonly=True),
518+ 'to_install': fields.integer(
519+ 'Number of modules to install', readonly=True),
520 }
521 _defaults = {
522 'state': lambda *a: 'init',
523 }
524
525-
526 def default_get(self, cr, uid, fields, context=None):
527 """
528 Update module list and retrieve the number
529@@ -51,18 +58,21 @@
530 update, add = module_obj.update_list(cr, uid,)
531 print "%s modules added" % add
532 module_ids = module_obj.search(
533- cr, uid, [('state', 'not in', ['installed', 'uninstallable', 'unknown'])])
534+ cr, uid, [
535+ ('state', 'not in',
536+ ['installed', 'uninstallable', 'unknown'])
537+ ])
538 res.update(
539 {'to_install': module_ids and len(module_ids) or False}
540 )
541 return res
542
543 def quirk_fiscalyear(self, cr, uid, ids, context=None):
544- """
545+ """
546 Install account module first and create a fiscal year,
547 in order to prevent "No fiscal year defined" exception
548 during an upgrade or reinstallation of the account module.
549-
550+
551 Refer to account_fiscalyear.find(), which is called as
552 a default function by the orm upon module upgrade.
553 """
554@@ -87,12 +97,12 @@
555 fy_obj = pool.get('account.fiscalyear')
556 if not fy_obj.find(cr, uid, False, exception=False, context=context):
557 fy_obj.create(cr, uid, {
558- 'name': time.strftime('%Y'),
559- 'code': time.strftime('%Y'),
560- 'date_start': "%s-01-01" % time.strftime('%Y'),
561- 'date_stop': "%s-12-31" % time.strftime('%Y'),
562- })
563-
564+ 'name': time.strftime('%Y'),
565+ 'code': time.strftime('%Y'),
566+ 'date_start': "%s-01-01" % time.strftime('%Y'),
567+ 'date_stop': "%s-12-31" % time.strftime('%Y'),
568+ })
569+
570 def install_all(self, cr, uid, ids, context=None):
571 """
572 Main wizard step. Set all installable modules to install
573@@ -100,7 +110,9 @@
574 """
575 module_obj = self.pool.get('ir.module.module')
576 module_ids = module_obj.search(
577- cr, uid, [('state', 'not in', ['installed', 'uninstallable', 'unknown'])])
578+ cr, uid, [
579+ ('state', 'not in',
580+ ['installed', 'uninstallable', 'unknown'])])
581 if module_ids:
582 module_obj.write(
583 cr, uid, module_ids, {'state': 'to install'})
584@@ -110,4 +122,3 @@
585 return True
586
587 install_all_wizard()
588-
589
590=== modified file 'openerp/addons/openupgrade_records/model/openupgrade_record.py'
591--- openerp/addons/openupgrade_records/model/openupgrade_record.py 2014-04-08 10:54:25 +0000
592+++ openerp/addons/openupgrade_records/model/openupgrade_record.py 2014-05-05 12:51:20 +0000
593@@ -2,7 +2,7 @@
594 ##############################################################################
595 #
596 # OpenERP, Open Source Management Solution
597-# This module Copyright (C) 2012 OpenUpgrade community
598+# This module Copyright (C) 2012-2014 OpenUpgrade community
599 # https://launchpad.net/~openupgrade-committers
600 #
601 # Contributors:
602@@ -23,14 +23,21 @@
603 #
604 ##############################################################################
605
606-from openerp.osv import osv, fields
607+try:
608+ from openerp.osv.orm import Model
609+ from openerp.osv import fields
610+except ImportError:
611+ from osv.osv import osv as Model
612+ from osv import fields
613+
614
615 # Cannot use forward references in 6.0
616-class openupgrade_record(osv.osv):
617+class openupgrade_record(Model):
618 _name = 'openupgrade.record'
619 openupgrade_record()
620
621-class openupgrade_attribute(osv.osv):
622+
623+class openupgrade_attribute(Model):
624 _name = 'openupgrade.attribute'
625 _rec_name = 'name'
626 _columns = {
627@@ -50,7 +57,8 @@
628 }
629 openupgrade_attribute()
630
631-class openupgrade_record(osv.osv):
632+
633+class openupgrade_record(Model):
634 _inherit = 'openupgrade.record'
635
636 _columns = {
637@@ -65,7 +73,7 @@
638 'in this module. If this module modifies an attribute of an '
639 'exting field, set to Modify.',
640 readonly=True,
641- ),
642+ ),
643 'type': fields.selection(
644 [('field', 'Field'), ('xmlid', 'XML ID')],
645 'Type',
646@@ -76,6 +84,7 @@
647 readonly=True,
648 ),
649 }
650+
651 def field_dump(self, cr, uid, context=None):
652 keys = [
653 'module',
654@@ -98,11 +107,11 @@
655 for record in records:
656 repr = template.copy()
657 repr.update({
658- 'module': record.module,
659- 'model': record.model,
660- 'field': record.field,
661- 'mode': record.mode,
662- })
663+ 'module': record.module,
664+ 'model': record.model,
665+ 'field': record.field,
666+ 'mode': record.mode,
667+ })
668 repr.update(
669 dict([(x.name, x.value) for x in record.attribute_ids]))
670 data.append(repr)

Subscribers

People subscribed via source and target branches

to all changes: