1
##############################################################################
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
29
from osv import osv,fields
31
# -------------------------------------------------------------------------
33
# -------------------------------------------------------------------------
35
def _models_get2(self, cr, uid, context={}):
36
obj = self.pool.get('ir.model.fields')
37
ids = obj.search(cr, uid, [('view_load','=',1)])
40
for o in obj.browse(cr, uid, ids, context=context):
41
if o.relation not in done:
42
res.append( [o.relation, o.relation])
43
done[o.relation] = True
46
def _models_get(self, cr, uid, context={}):
47
obj = self.pool.get('ir.model.fields')
48
ids = obj.search(cr, uid, [('view_load','=',1)])
51
for o in obj.browse(cr, uid, ids, context=context):
52
if o.model_id.id not in done:
53
res.append( [o.model_id.model, o.model_id.name])
54
done[o.model_id.id] = True
57
class ir_property(osv.osv):
60
'name': fields.char('Name', size=128),
61
'value': fields.reference('Value', selection=_models_get2, size=128),
62
'res_id': fields.reference('Resource', selection=_models_get, size=128),
63
'company_id': fields.many2one('res.company', 'Company'),
64
'fields_id': fields.many2one('ir.model.fields', 'Fields', ondelete='cascade', required=True)
66
def get(self, cr, uid, name, model, res_id=False, context={}):
67
cr.execute('select id from ir_model_fields where name=%s and model=%s', (name, model))
70
nid = self.search(cr, uid, [('fields_id','=',res[0]),('res_id','=',res_id)])
72
d = self.browse(cr, uid, nid[0], context).value
73
return (d and int(d.split(',')[1])) or False