Speed_improvement
bzr revid: fp@tinyerp.com-20081202081629-bchm1dum0elcs43q
This commit is contained in:
parent
32796a155f
commit
e60d9ff7c5
|
@ -166,14 +166,19 @@ class ir_values(osv.osv):
|
|||
|
||||
result = []
|
||||
ok = True
|
||||
result_ids = {}
|
||||
while ok:
|
||||
if not where_opt:
|
||||
cr.execute('select id from ir_values where ' +\
|
||||
cr.execute('select id,name,value,object,meta, key from ir_values where ' +\
|
||||
' and '.join(where1)+' and user_id is null', where2)
|
||||
else:
|
||||
cr.execute('select id from ir_values where ' +\
|
||||
cr.execute('select id,name,value,object,meta, key from ir_values where ' +\
|
||||
' and '.join(where1+where_opt), where2)
|
||||
result.extend([x[0] for x in cr.fetchall()])
|
||||
for rec in cr.fetchall():
|
||||
if rec[0] in result_ids:
|
||||
continue
|
||||
result.append(rec)
|
||||
result_ids[rec[0]] = True
|
||||
if len(where_opt):
|
||||
where_opt.pop()
|
||||
else:
|
||||
|
@ -184,13 +189,6 @@ class ir_values(osv.osv):
|
|||
|
||||
if not result:
|
||||
return []
|
||||
cid = self.pool.get('res.users').browse(cr, uid, uid, context={}).company_id.id
|
||||
cr.execute('select id,name,value,object,meta, key ' \
|
||||
'from ir_values ' \
|
||||
'where id in ('+','.join(map(str,result))+') ' \
|
||||
'and (company_id is null or company_id = %d) '\
|
||||
'ORDER BY user_id', (cid,))
|
||||
result = cr.fetchall()
|
||||
|
||||
def _result_get(x, keys):
|
||||
if x[1] in keys:
|
||||
|
@ -199,18 +197,19 @@ class ir_values(osv.osv):
|
|||
if x[3]:
|
||||
model,id = x[2].split(',')
|
||||
id = int(id)
|
||||
datas = self.pool.get(model).read(cr, uid, id, False, context)
|
||||
fields = self.pool.get(model).fields_get_keys(cr, uid)
|
||||
pos = 0
|
||||
while pos<len(fields):
|
||||
if fields[pos] in ('report_sxw_content', 'report_rml_content',
|
||||
'report_sxw', 'report_rml', 'report_sxw_content_data',
|
||||
'report_rml_content_data'):
|
||||
del fields[pos]
|
||||
else:
|
||||
pos+=1
|
||||
datas = self.pool.get(model).read(cr, uid, [id], fields, context)[0]
|
||||
if not datas:
|
||||
#ir_del(cr, uid, x[0])
|
||||
return False
|
||||
def clean(x):
|
||||
for key in ('report_sxw_content', 'report_rml_content',
|
||||
'report_sxw', 'report_rml', 'report_sxw_content_data',
|
||||
'report_rml_content_data'):
|
||||
if key in x:
|
||||
del x[key]
|
||||
return x
|
||||
datas = clean(datas)
|
||||
else:
|
||||
datas = pickle.loads(x[2])
|
||||
if meta:
|
||||
|
|
|
@ -103,6 +103,9 @@ res_partner_title()
|
|||
def _contact_title_get(self, cr, uid, context={}):
|
||||
obj = self.pool.get('res.partner.title')
|
||||
ids = obj.search(cr, uid, [('domain', '=', 'contact')])
|
||||
import traceback
|
||||
traceback.print_stack()
|
||||
print 'TITLE GET'
|
||||
res = obj.read(cr, uid, ids, ['shortcut','name'], context)
|
||||
return [(r['shortcut'], r['name']) for r in res]
|
||||
|
||||
|
|
|
@ -719,7 +719,7 @@ class related(function):
|
|||
|
||||
# TODO: call field_get on the object, not in the DB
|
||||
def _field_get(self, cr, uid, obj, model_name, prop):
|
||||
fields = obj.pool.get(model_name).fields_get(cr, uid,)
|
||||
fields = obj.pool.get(model_name).fields_get(cr, uid,[prop])
|
||||
if fields.get(prop, False):
|
||||
return(fields[prop].get('relation', False), fields[prop].get('type', False), fields)
|
||||
else:
|
||||
|
|
|
@ -690,6 +690,14 @@ class orm_template(object):
|
|||
|
||||
# returns the definition of each field in the object
|
||||
# the optional fields parameter can limit the result to some fields
|
||||
def fields_get_keys(self, cr, user, context=None, read_access=True):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = self._columns.keys()
|
||||
for parent in self._inherits:
|
||||
res.extend(self.pool.get(parent).fields_get_keys(cr, user, fields, context))
|
||||
return res
|
||||
|
||||
def fields_get(self, cr, user, fields=None, context=None, read_access=True):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
@ -700,6 +708,8 @@ class orm_template(object):
|
|||
res.update(self.pool.get(parent).fields_get(cr, user, fields,
|
||||
context))
|
||||
for f in self._columns.keys():
|
||||
if fields and f not in fields:
|
||||
continue
|
||||
res[f] = {'type': self._columns[f]._type}
|
||||
for arg in ('string', 'readonly', 'states', 'size', 'required',
|
||||
'change_default', 'translate', 'help', 'select'):
|
||||
|
@ -1773,7 +1783,6 @@ class orm(orm_template):
|
|||
return super(orm, self).fields_get(cr, user, fields, context, read_access)
|
||||
|
||||
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
|
||||
print 'READ', self._name, ids
|
||||
if not context:
|
||||
context = {}
|
||||
self.pool.get('ir.model.access').check(cr, user, self._name, 'read')
|
||||
|
|
Loading…
Reference in New Issue