~therp-nl/openobject-server/6.0-cust4

« back to all changes in this revision

Viewing changes to bin/addons/base/ir/ir_values.py

  • Committer: stefan at therp
  • Date: 2012-08-17 16:18:37 UTC
  • mfrom: (3368.13.197 openobject-server)
  • Revision ID: stefan@therp.nl-20120817161837-689f7pz6r9r4jq1h
[MRG] Merged with lp:openobject-server/6.0 rev. 3632

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
            value = pickle.dumps(value)
107
107
        if meta:
108
108
            meta = pickle.dumps(meta)
 
109
        assert isinstance(models, (list, tuple)), models
 
110
        assert not company or isinstance(company, int), "Parameter 'company' must be an integer (company ID)!"
 
111
        if company and company is True:
 
112
            current_user_obj = self.pool.get('res.users').browse(cr, uid, uid, context={})
 
113
            company = current_user_obj.company_id.id
 
114
            
109
115
        ids_res = []
110
116
        for model in models:
111
117
            if isinstance(model, (list, tuple)):
118
124
                    ('key2', '=', key2),
119
125
                    ('model', '=', model),
120
126
                    ('res_id', '=', res_id),
121
 
                    ('user_id', '=', preserve_user and uid)
 
127
                    ('user_id', '=', preserve_user and uid),
 
128
                    ('company_id' ,'=', company)
 
129
                    
122
130
                ]
123
131
                if key in ('meta', 'default'):
124
132
                    search_criteria.append(('name', '=', name))
135
143
                'key2': key2 and key2[:200],
136
144
                'meta': meta,
137
145
                'user_id': preserve_user and uid,
 
146
                'company_id':company
138
147
            }
139
 
            if company:
140
 
                cid = self.pool.get('res.users').browse(cr, uid, uid, context={}).company_id.id
141
 
                vals['company_id']=cid
142
148
            if res_id:
143
 
                vals['res_id']= res_id
 
149
                vals['res_id'] = res_id
144
150
            ids_res.append(self.create(cr, uid, vals))
145
151
        return ids_res
146
152
 
173
179
                    where.append('res_id=%s')
174
180
                    params.append(res_id)
175
181
 
176
 
            where.append('(user_id=%s or (user_id IS NULL)) order by id')
177
 
            params.append(uid)
 
182
            order = 'id, company_id'
 
183
            where.append('''(user_id=%s or (user_id IS NULL))
 
184
                and (company_id is null or
 
185
                company_id = (SELECT company_id FROM res_users WHERE id = %s)) order by '''+ order)
 
186
            params += [uid, uid]
178
187
            clause = ' and '.join(where)
179
188
            cr.execute('select id,name,value,object,meta, key from ir_values where ' + clause, params)
180
189
            result = cr.fetchall()