1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# This module Copyright (C) 2012 OpenUpgrade community
6
# https://launchpad.net/~openupgrade-committers
9
# Therp BV <http://therp.nl>
11
# This program is free software: you can redistribute it and/or modify
12
# it under the terms of the GNU Affero General Public License as
13
# published by the Free Software Foundation, either version 3 of the
14
# License, or (at your option) any later version.
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU Affero General Public License for more details.
21
# You should have received a copy of the GNU Affero General Public License
22
# along with this program. If not, see <http://www.gnu.org/licenses/>.
24
##############################################################################
26
from osv import osv, fields
28
# Cannot use forward references in 6.0
29
class openupgrade_record(osv.osv):
30
_name = 'openupgrade.record'
33
class openupgrade_attribute(osv.osv):
34
_name = 'openupgrade.attribute'
35
_rec_name = 'attribute_id'
46
'record_id': fields.many2one(
47
'openupgrade.record', ondelete='CASCADE',
51
openupgrade_attribute()
53
class openupgrade_record(osv.osv):
54
_inherit = 'openupgrade.record'
57
'name': fields.char('Name', size=256, readonly=True),
58
'module': fields.char('Module', size=128, readonly=True),
59
'model': fields.char('Model', size=128, readonly=True),
60
'field': fields.char('Field', size=128, readonly=True),
61
'mode': fields.selection(
62
[('create', 'Create'), ('modify', 'Modify')],
64
help='Set to Create if a field is newly created '
65
'in this module. If this module modifies an attribute of an '
66
'exting field, set to Modify.',
69
'type': fields.selection(
70
[('field', 'Field'), ('xmlid', 'XML ID')],
74
'attribute_ids': fields.one2many(
75
'openupgrade.attribute', 'record_id', 'Attributes',
79
def field_dump(self, cr, uid, context=None):
94
template = dict([(x, False) for x in keys])
95
ids = self.search(cr, uid, [('type', '=', 'field')], context=context)
96
records = self.browse(cr, uid, ids, context=context)
98
for record in records:
99
repr = template.copy()
101
'module': record.module,
102
'model': record.model,
103
'field': record.field,
107
dict([(x.name, x.value) for x in record.attribute_ids]))