[Merge] Merge with trunk addons
[odoo/odoo.git] / bin / addons / base / ir / ir_values.py
index b2eb1aa..97f6f75 100644 (file)
@@ -1,22 +1,21 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
-#
-#    OpenERP, Open Source Management Solution  
-#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
-#    $Id$
+#    
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
 #
 ##############################################################################
 
@@ -76,8 +75,13 @@ class ir_values(osv.osv):
             method=True, type='text', string='Value'),
         'object': fields.boolean('Is Object'),
         'key': fields.selection([('action','Action'),('default','Default')], 'Type', size=128),
-        'key2': fields.char('Event Type', size=256,
-            help="The kind of action or button in the client side that will trigger the action."),
+        'key2' : fields.selection([('client_action_multi', 'client_action_multi'),
+                                   ('client_action_relate', 'client_action_relate'),
+                                   ('tree_but_open', 'tree_but_open'),
+                                   ('tree_but_action', 'tree_but_action'),
+                                   ('client_print_multi', 'client_print_multi')],
+                                  'Event Type',
+                                  help="The kind of action or button in the client side that will trigger the action."),
         'meta': fields.text('Meta Datas'),
         'meta_unpickle': fields.function(_value_unpickle, fnct_inv=_value_pickle,
             method=True, type='text', string='Metadata'),
@@ -197,8 +201,9 @@ class ir_values(osv.osv):
                 for rec in cr.fetchall():
                     if rec[0] in result_ids:
                         continue
-                    result.append(rec)
-                    result_ids[rec[0]] = True
+                    if rec[2]:                    
+                        result.append(rec)
+                        result_ids[rec[0]] = True
                 if len(where_opt):
                     where_opt.pop()
                 else:
@@ -235,7 +240,7 @@ class ir_values(osv.osv):
                     #ir_del(cr, uid, x[0])
                     return False
             else:
-                datas = pickle.loads(str(x[2]))
+                datas = pickle.loads(str(x[2].encode('utf-8')))
             if meta:
                 meta2 = pickle.loads(x[4])
                 return (x[0],x[1],datas,meta2)
@@ -249,8 +254,7 @@ class ir_values(osv.osv):
                     if r[2].has_key('groups_id'):
                         groups = r[2]['groups_id']
                         if len(groups) > 0:
-                            group_ids = ','.join([ str(x) for x in r[2]['groups_id']])
-                            cr.execute("select count(*) from res_groups_users_rel where gid in (%s) and uid='%s'" % (group_ids, uid))
+                            cr.execute("SELECT count(*) FROM res_groups_users_rel WHERE gid = ANY(%s) AND uid=%s",(groups, uid))
                             gr_ids = cr.fetchall()
                             if not gr_ids[0][0] > 0:
                                 res2.remove(r)