summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Pinckaers <fp@tinyerp.com>2008-08-16 18:30:06 +0200
committerFabien Pinckaers <fp@tinyerp.com>2008-08-16 18:30:06 +0200
commit61d07d0771a4bf1aad097b3b6091c0f3454fae23 (patch)
tree9ea0060b4568850852a0ef69d2053a87a4141b50
parentd32b4a66f3e88ec5b047af604a16ff96c54ea8df (diff)
Bugfixes
bzr revid: fp@tinyerp.com-20080816163006-aspcc7f5dmv0g4ri
-rw-r--r--bin/addons/base/res/res_company.py4
-rw-r--r--bin/osv/expression.py20
-rw-r--r--bin/osv/orm.py2
-rw-r--r--bin/sql_db.py1
4 files changed, 12 insertions, 15 deletions
diff --git a/bin/addons/base/res/res_company.py b/bin/addons/base/res/res_company.py
index 90cb69185a5..f7e6f94c342 100644
--- a/bin/addons/base/res/res_company.py
+++ b/bin/addons/base/res/res_company.py
@@ -97,9 +97,9 @@ class res_company(osv.osv):
def _get_euro(self, cr, uid, context={}):
try:
- return self.pool.get('res.currency').search(cr, uid, [('rate', '=', 1.0),])[0]
+ return self.pool.get('res.currency').search(cr, uid, [])[0]
except:
- return 1
+ return False
def _check_recursion(self, cr, uid, ids):
level = 100
diff --git a/bin/osv/expression.py b/bin/osv/expression.py
index d04b4cd7f92..842dabf031f 100644
--- a/bin/osv/expression.py
+++ b/bin/osv/expression.py
@@ -35,21 +35,20 @@ class expression(object):
def __init__(self, exp):
-
# check if the expression is valid
if not reduce(lambda acc, val: acc and (self._is_operator(val) or self._is_leaf(val)), exp, True):
- raise ValueError('Bad expression: %r' % (exp,))
-
+ raise ValueError('Bad domain expression: %r' % (exp,))
self.__exp = exp
self.__tables = {} # used to store the table to use for the sql generation. key = index of the leaf
self.__joins = []
self.__main_table = None # 'root' table. set by parse()
-
self.__DUMMY_LEAF = (1, '=', 1) # a dummy leaf that must not be parsed or sql generated
def parse(self, cr, uid, table, context):
""" transform the leafs of the expression """
+ if not self.__exp:
+ return self
def _rec_get(ids, table, parent):
if table._parent_store:
@@ -57,7 +56,7 @@ class expression(object):
for o in table.browse(cr, uid, ids, context=context):
if doms:
doms.insert(0,'|')
- doms.append(['&',('parent_left','<',o.parent_right),('parent_left','>=',o.parent_left)])
+ doms += ['&',('parent_left','<',o.parent_right),('parent_left','>=',o.parent_left)]
return table.search(cr, uid, doms, context=context)
else:
if not ids:
@@ -65,11 +64,8 @@ class expression(object):
ids2 = table.search(cr, uid, [(parent, 'in', ids)], context=context)
return ids + _rec_get(ids2, table, parent)
- if not self.__exp:
- return self
-
self.__main_table = table
-
+
for i, e in enumerate(self.__exp):
if self._is_operator(e) or e == self.__DUMMY_LEAF:
continue
@@ -80,9 +76,9 @@ class expression(object):
working_table = table.pool.get(table._inherit_fields[left][0])
if working_table not in self.__tables.values():
self.__joins.append('%s.%s' % (table._table, table._inherits[working_table._name]))
-
+
self.__tables[i] = working_table
-
+
fargs = left.split('.', 1)
field = working_table._columns.get(fargs[0], False)
if not field:
@@ -90,7 +86,7 @@ class expression(object):
right += _rec_get(right, working_table, working_table._parent_name)
self.__exp[i] = ('id', 'in', right)
continue
-
+
field_obj = table.pool.get(field._obj)
if len(fargs) > 1:
if field._type == 'many2one':
diff --git a/bin/osv/orm.py b/bin/osv/orm.py
index 3fa74f280c3..acb4d4fb025 100644
--- a/bin/osv/orm.py
+++ b/bin/osv/orm.py
@@ -1375,7 +1375,7 @@ class orm(orm_template):
if not default:
cr.execute("UPDATE \"%s\" SET \"%s\"=NULL" % (self._table, k))
else:
- cr.execute("UPDATE \"%s\" SET \"%s\"='%s'" % (self._table, k, default))
+ cr.execute("UPDATE \"%s\" SET \"%s\"=%%s" % (self._table, k), (default,))
if isinstance(f, fields.function):
cr.execute('select id from '+self._table)
ids_lst = map(lambda x: x[0], cr.fetchall())
diff --git a/bin/sql_db.py b/bin/sql_db.py
index 05a5577490c..9da6293cfac 100644
--- a/bin/sql_db.py
+++ b/bin/sql_db.py
@@ -59,6 +59,7 @@ class fake_cursor:
self.dbname = dbname
def execute(self, sql, params=None):
+ print sql, params
if not params:
params=()
def base_string(s):