summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMantavya Gajjar <mga@tinyerp.com>2008-06-25 09:20:52 +0000
committerMantavya Gajjar <mga@tinyerp.com>2008-06-25 09:20:52 +0000
commitaa7fcf5188159cd1427c9d4a0c8bd3ffca9eed65 (patch)
treea71a9d61d7b056b9bde99e03405a294af43cdb7d /bin
parent0766e9ba4119ab48795779b761d5244a3e3abd7f (diff)
Change fields_view_get definition to get the View According to the user changes
bzr revid: mga@tinyerp.com-7ac7ff91c33e92e88dd63c0b05298c6c6956db27
Diffstat (limited to 'bin')
-rw-r--r--bin/osv/orm.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/bin/osv/orm.py b/bin/osv/orm.py
index c8e11da544b..67716225bc8 100644
--- a/bin/osv/orm.py
+++ b/bin/osv/orm.py
@@ -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,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:
- 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()
+ 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)