Change fields_view_get definition to get the View According to the user changes

bzr revid: mga@tinyerp.com-7ac7ff91c33e92e88dd63c0b05298c6c6956db27
This commit is contained in:
Mantavya Gajjar
2008-06-25 09:20:52 +00:00
parent 0766e9ba41
commit aa7fcf5188
+24 -4
View File
@@ -951,12 +951,26 @@ class orm_template(object):
model = True
sql_res = False
while ok:
sql_res_usr = None
if view_id:
#check for user specific view and get the view according to that
where = (model and (" and model='%s'" % (self._name,))) or ''
cr.execute('SELECT arch,name,field_parent,id,type,inherit_id FROM ir_ui_view WHERE id=%d'+where, (view_id,))
cr.execute('select arch,name,field_parent,ref_id,type,inherit_id from ir_ui_view_user where ref_id=%d and user_id=%d'+where, (view_id, user))
sql_res_usr = cr.fetchone()
if not sql_res_usr:
where = (model and (" and model='%s'" % (self._name,))) or ''
cr.execute('select arch,name,field_parent,id,type,inherit_id from ir_ui_view where id=%d'+where, (view_id,))
else:
cr.execute('SELECT arch,name,field_parent,id,type,inherit_id FROM ir_ui_view WHERE model=%s AND type=%s ORDER BY priority', (self._name,view_type))
sql_res = cr.fetchone()
cr.execute('select arch,name,field_parent,ref_id,type,inherit_id from ir_ui_view_user where model=%s and type=%s and user_id=%d order by priority', (self._name, view_type, user))
sql_res_usr = cr.fetchone()
if not sql_res_usr:
cr.execute('select arch,name,field_parent,id,type,inherit_id from ir_ui_view where model=%s and type=%s order by priority', (self._name,view_type))
if sql_res_usr is None:
sql_res = cr.fetchone()
else:
sql_res = sql_res_usr
if not sql_res:
break
ok = sql_res[5]
@@ -971,8 +985,14 @@ class orm_template(object):
def _inherit_apply_rec(result, inherit_id):
# get all views which inherit from (ie modify) this view
cr.execute('select arch,id from ir_ui_view where inherit_id=%d and model=%s order by priority', (inherit_id, self._name))
cr.execute('select arch,id from ir_ui_view where inherit_id=%s and model=%s and id not in (select ref_id from ir_ui_view_user where inherit_id=%s and model=%s and user_id=%s)' , (inherit_id, self._name, inherit_id, self._name, user))
sql_inherit_part1 = cr.fetchall()
cr.execute('select arch,ref_id from ir_ui_view_user where inherit_id=%d and model=%s and user_id=%d order by priority', (inherit_id, self._name, user))
sql_inherit = cr.fetchall()
sql_inherit = sql_inherit_part1 + sql_inherit
for (inherit,id) in sql_inherit:
result = _inherit_apply(result, inherit)
result = _inherit_apply_rec(result, id)