Fix default values:

- Take all default value not only those for a specific user
- Set transiant correctly to default value window
- Fix default value on many2many
- Put gui.main as default window

bzr revid: ced-55dbc0011ff7a63788309fc51e626ad2d544b67b
This commit is contained in:
ced 2007-10-31 14:14:06 +00:00
parent c24262351f
commit f259e56778
2 changed files with 23 additions and 6 deletions

View File

@ -172,14 +172,14 @@ class ir_values(osv.osv):
result = []
ok = True
while ok and len(result)==0:
while ok:
if not where_opt:
cr.execute('select id from ir_values where ' +\
' and '.join(where1)+' and user_id is null', where2)
else:
cr.execute('select id from ir_values where ' +\
' and '.join(where1+where_opt), where2)
result = [x[0] for x in cr.fetchall()]
result.extend([x[0] for x in cr.fetchall()])
if len(where_opt):
where_opt.pop()
else:
@ -191,10 +191,17 @@ 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 from ir_values where id in ('+','.join(map(str,result))+') and (company_id is null or company_id='+str(cid)+')')
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):
def _result_get(x, keys):
if x[1] in keys:
return False
keys.append(x[1])
if x[3]:
model,id = x[2].split(',')
try:
@ -219,7 +226,8 @@ class ir_values(osv.osv):
meta2 = pickle.loads(x[4])
return (x[0],x[1],datas,meta2)
return (x[0],x[1],datas)
res = filter(bool, map(lambda x: _result_get(x), list(result)))
keys = []
res = filter(bool, map(lambda x: _result_get(x, keys), list(result)))
return res
ir_values()

View File

@ -903,7 +903,16 @@ class orm(object):
obj = self.pool.get(self._columns[field]._obj)
if not obj.search(cr, uid, [('id', '=', field_value)]):
continue
if self._columns[field]._type in ('one2many', 'many2many'):
if self._columns[field]._type in ('many2many'):
obj = self.pool.get(self._columns[field]._obj)
field_value2 = []
for i in range(len(field_value)):
if not obj.search(cr, uid, [('id', '=',
field_value[i])]):
continue
field_value2.append(field_value[i])
field_value = field_value2
if self._columns[field]._type in ('one2many'):
obj = self.pool.get(self._columns[field]._obj)
field_value2 = []
for i in range(len(field_value)):