diff --git a/bin/osv/expression.py b/bin/osv/expression.py index 9cad5137387..7aa3b6aae57 100644 --- a/bin/osv/expression.py +++ b/bin/osv/expression.py @@ -254,12 +254,13 @@ class expression(object): query = '(%s OR %s IS NULL)' % (query, left) else: params = [] - if right == False and table._columns[leaf[0]]._type=="boolean" and (operator == '='): - query = '%s.%s IS NULL or %s.%s = false ' % (table._table, left,table._table, left) + + if right == False and (leaf[0] in table._columns) and table._columns[leaf[0]]._type=="boolean" and (operator == '='): + query = '(%s.%s IS NULL or %s.%s = false )' % (table._table, left,table._table, left) elif (((right == False) and (type(right)==bool)) or (right is None)) and (operator == '='): query = '%s.%s IS NULL ' % (table._table, left) - elif right == False and table._columns[leaf[0]]._type=="boolean" and (operator in ['<>', '!=']): - query = '%s.%s IS NOT NULL and %s.%s != false' % (table._table, left,table._table, left) + elif right == False and (leaf[0] in table._columns) and table._columns[leaf[0]]._type=="boolean" and (operator in ['<>', '!=']): + query = '(%s.%s IS NOT NULL and %s.%s != false)' % (table._table, left,table._table, left) elif (((right == False) and (type(right)==bool)) or right is None) and (operator in ['<>', '!=']): query = '%s.%s IS NOT NULL' % (table._table, left) else: diff --git a/bin/osv/orm.py b/bin/osv/orm.py index cfc311102eb..4e51dc454df 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -2405,7 +2405,15 @@ class orm(orm_template): upd0 += ','+self._inherits[table] upd1 += ',%s' upd2.append(id) - + + #Start : Set bool fields to be False if they are not touched(to make search more powerful) + bool_fields = [x for x in self._columns.keys() if self._columns[x]._type=='boolean'] + + for bool_field in bool_fields: + if bool_field not in vals: + vals[bool_field] = False + #End + for field in vals: if self._columns[field]._classic_write: upd0 = upd0 + ',"' + field + '"' diff --git a/bin/report/render/rml2pdf/utils.py b/bin/report/render/rml2pdf/utils.py index 2102912e974..ce54c50a9a5 100644 --- a/bin/report/render/rml2pdf/utils.py +++ b/bin/report/render/rml2pdf/utils.py @@ -40,6 +40,7 @@ import re import reportlab from lxml import etree +import copy _regex = re.compile('\[\[(.+?)\]\]') @@ -47,6 +48,7 @@ def _child_get(node, self=None, tagname=None): for n in node: if self and self.localcontext and n.get('rml_loop', False): oldctx = self.localcontext + for ctx in eval(n.get('rml_loop'),{}, self.localcontext): self.localcontext.update(ctx) if (tagname is None) or (n.tag==tagname): @@ -58,7 +60,7 @@ def _child_get(node, self=None, tagname=None): if n.get('rml_tag'): try: (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) - n2 = copy.copy(n) + n2 = copy.deepcopy(n) n2.tag = tag n2.attrib.update(attr) yield n2 @@ -73,6 +75,16 @@ def _child_get(node, self=None, tagname=None): eval(n.get('rml_except'), {}, self.localcontext) except: continue + if self and self.localcontext and n.get('rml_tag', False): + try: + (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) + n2 = copy.deepcopy(n) + n2.tag = tag + n2.attrib.update(attr) + yield n2 + tagname = '' + except: + pass if (tagname is None) or (n.tag==tagname): yield n diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py index d6f7e343402..19ca17ae1a3 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -495,16 +495,16 @@ class report_sxw(report_rml, preprocess.report): final_op = sxw_io.getvalue() sxw_io.close() return (final_op, report_type) - + def create_single_html2html(self, cr, uid, ids, data, report_xml, context={}): context = context.copy() report_type = 'html' context['parents'] = html_parents - + html = report_xml.report_rml_content html_parser = self.parser(cr, uid, self.name2, context) html_parser.parents = html_parents - html_parser.tag = sxw_tag + html_parser.tag = sxw_tag objs = self.getObjects(cr, uid, ids, context) html_parser.set_context(objs, data, ids, report_type) @@ -515,6 +515,5 @@ class report_sxw(report_rml, preprocess.report): html = etree.tostring(create_doc(html_dom, html_parser.localcontext)) return (html.replace('<', '<').replace('>', '>').replace('
',''), report_type) -