[MERGE] Sync with trunk

bzr revid: jam@tinyerp.com-20121019042856-w7u49cd295i2ilvi
This commit is contained in:
Jigar Amin 2012-10-19 09:58:56 +05:30
commit a1cb39e65c
4 changed files with 20 additions and 5 deletions

View File

@ -396,7 +396,7 @@
assert res_8 == [1]
assert res_9 == []
# get the companies referenced by some currency (this is normally the main company)
# get the companies referenced by some currency (this is normally the main company) using a weird negative domain
res_10 = self.search(cr, uid, [('currency_ids', 'not like', 'probably_unexisting_name')])
res_11 = self.search(cr, uid, [('currency_ids', 'not in', [max_currency_id + 1])])
res_12 = self.search(cr, uid, [('currency_ids', '!=', False)])
@ -408,6 +408,20 @@
assert res_10 == res_11
assert res_10 == res_12
assert res_10 == res_13
# try testing real subsets with IN/NOT IN
res_partner = self.pool.get('res.partner')
res_users = self.pool.get('res.users')
p1, _ = res_partner.name_create(cr, uid, "Dédé Boitaclou")
p2, _ = res_partner.name_create(cr, uid, "Raoulette Pizza O'poil")
u1a = res_users.create(cr, uid, {'login': 'dbo', 'partner_id': p1})
u1b = res_users.create(cr, uid, {'login': 'dbo2', 'partner_id': p1})
u2 = res_users.create(cr, uid, {'login': 'rpo', 'partner_id': p2})
assert [p1] == res_partner.search(cr, uid, [('user_ids', 'in', u1a)]), "o2m IN accept single int on right side"
assert [p1,p2] == res_partner.search(cr, uid, [('user_ids', 'in', [u1a,u2])]), "o2m IN matches any on the right side"
all_partners = res_partner.search(cr, uid, [])
assert (set(all_partners) - set([p1])) == set(res_partner.search(cr, uid, [('user_ids', 'not in', u1a)])), "o2m NOT IN matches none on the right side"
assert (set(all_partners) - set([p1,p2])) == set(res_partner.search(cr, uid, [('user_ids', 'not in', [u1b, u2])])), "o2m NOT IN matches none on the right side"
# child_of x returns x and its children (direct or not).
company = self.browse(cr, uid, ref('ymltest_company3'))

View File

@ -540,7 +540,8 @@ class expression(object):
ids2 = select_from_where(cr, field._fields_id, field_obj._table, 'id', ids2, operator)
if ids2:
call_null = False
self.__exp[i] = ('id', 'in', ids2)
o2m_op = 'not in' if operator in NEGATIVE_TERM_OPERATORS else 'in'
self.__exp[i] = ('id', o2m_op, ids2)
if call_null:
o2m_op = 'in' if operator in NEGATIVE_TERM_OPERATORS else 'not in'

View File

@ -43,7 +43,7 @@ class ormcache(object):
return r
except KeyError:
self.stat_miss += 1
value = d[args] = self.method(self2, cr, *args)
value = d[key] = self.method(self2, cr, *args)
return value
except TypeError:
self.stat_err += 1

View File

@ -46,7 +46,7 @@ _ALLOWED_MODULES = ['_strptime', 'time']
_CONST_OPCODES = set(opmap[x] for x in [
'POP_TOP', 'ROT_TWO', 'ROT_THREE', 'ROT_FOUR', 'DUP_TOP', 'DUP_TOPX',
'POP_BLOCK','SETUP_LOOP', 'BUILD_LIST', 'BUILD_MAP', 'BUILD_TUPLE',
'LOAD_CONST', 'RETURN_VALUE', 'STORE_SUBSCR'] if x in opmap)
'LOAD_CONST', 'RETURN_VALUE', 'STORE_SUBSCR', 'STORE_MAP'] if x in opmap)
_EXPR_OPCODES = _CONST_OPCODES.union(set(opmap[x] for x in [
'UNARY_POSITIVE', 'UNARY_NEGATIVE', 'UNARY_NOT',
@ -61,7 +61,7 @@ _EXPR_OPCODES = _CONST_OPCODES.union(set(opmap[x] for x in [
] if x in opmap))
_SAFE_OPCODES = _EXPR_OPCODES.union(set(opmap[x] for x in [
'STORE_MAP', 'LOAD_NAME', 'CALL_FUNCTION', 'COMPARE_OP', 'LOAD_ATTR',
'LOAD_NAME', 'CALL_FUNCTION', 'COMPARE_OP', 'LOAD_ATTR',
'STORE_NAME', 'GET_ITER', 'FOR_ITER', 'LIST_APPEND', 'DELETE_NAME',
'JUMP_FORWARD', 'JUMP_IF_TRUE', 'JUMP_IF_FALSE', 'JUMP_ABSOLUTE',
'MAKE_FUNCTION', 'SLICE+0', 'SLICE+1', 'SLICE+2', 'SLICE+3',