From 9fa12bafaa9cd78c43490be36fcb76b3d197b7ea Mon Sep 17 00:00:00 2001 From: Naresh Choksy Date: Tue, 12 May 2009 16:49:55 +0530 Subject: [PATCH 1/5] Bugfix:setTag bzr revid: nch@tinyerp.com-20090512111955-x70z0zu770k0qq8x --- bin/report/render/rml2pdf/trml2pdf.py | 6 +++--- bin/report/render/rml2pdf/utils.py | 14 +++++++++++++- bin/report/report_sxw.py | 12 ++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/bin/report/render/rml2pdf/trml2pdf.py b/bin/report/render/rml2pdf/trml2pdf.py index efde722f0ed..a7741e9b76e 100644 --- a/bin/report/render/rml2pdf/trml2pdf.py +++ b/bin/report/render/rml2pdf/trml2pdf.py @@ -453,7 +453,7 @@ class _rml_flowable(object): return rc1 def _table(self, node): - childs = utils._child_get(node,self,'tr') + childs = list(utils._child_get(node,self,'tr')) if not childs: return None length = 0 @@ -474,7 +474,7 @@ class _rml_flowable(object): paraStyle = self.styles.styles[tr.get('paraStyle')] data2 = [] posx = 0 - for td in utils._child_get(tr, self,'td'): + for td in list(utils._child_get(tr, self,'td')): if td.get('style'): st = copy.deepcopy(self.styles.table_styles[td.get('style')]) for s in st._cmds: @@ -489,7 +489,7 @@ class _rml_flowable(object): posx += 1 flow = [] - for n in utils._child_get(td, self): + for n in list(utils._child_get(td, self)): fl = self._flowable(n, extra_style=paraStyle) if isinstance(fl,list): flow += fl 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 426b738f338..9d2ca509470 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -199,11 +199,7 @@ class rml_parse(object): def set_html_image(self,attach_id): try : att_id = int(attach_id) - print att_id attachment = self.pool.get('ir.attachment').browse(self.cr,self.uid,att_id) - print attachment - print attachment.datas - return attachment.datas except : return '' @@ -498,17 +494,17 @@ 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 + context['parents'] = html_parents rml = report_xml.report_rml_content rml_parser = self.parser(cr, uid, self.name2, context) rml_parser.parents = html_parents - rml_parser.tag = sxw_tag + rml_parser.tag = sxw_tag objs = self.getObjects(cr, uid, ids, context) rml_parser.set_context(objs, data, ids, report_type) @@ -518,6 +514,6 @@ class report_sxw(report_rml, preprocess.report): html = etree.tostring(create_doc(rml_dom, rml_parser.localcontext)) return (html, report_type) - + From 5e6345539230ac2e52cc7f2f751dcc06dfbce18c Mon Sep 17 00:00:00 2001 From: Naresh Choksy Date: Tue, 12 May 2009 17:56:31 +0530 Subject: [PATCH 2/5] bugfixes: bzr revid: nch@tinyerp.com-20090512122631-fqjlde9ktiowkn7t --- bin/report/render/rml2pdf/trml2pdf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/report/render/rml2pdf/trml2pdf.py b/bin/report/render/rml2pdf/trml2pdf.py index a7741e9b76e..efde722f0ed 100644 --- a/bin/report/render/rml2pdf/trml2pdf.py +++ b/bin/report/render/rml2pdf/trml2pdf.py @@ -453,7 +453,7 @@ class _rml_flowable(object): return rc1 def _table(self, node): - childs = list(utils._child_get(node,self,'tr')) + childs = utils._child_get(node,self,'tr') if not childs: return None length = 0 @@ -474,7 +474,7 @@ class _rml_flowable(object): paraStyle = self.styles.styles[tr.get('paraStyle')] data2 = [] posx = 0 - for td in list(utils._child_get(tr, self,'td')): + for td in utils._child_get(tr, self,'td'): if td.get('style'): st = copy.deepcopy(self.styles.table_styles[td.get('style')]) for s in st._cmds: @@ -489,7 +489,7 @@ class _rml_flowable(object): posx += 1 flow = [] - for n in list(utils._child_get(td, self)): + for n in utils._child_get(td, self): fl = self._flowable(n, extra_style=paraStyle) if isinstance(fl,list): flow += fl From d14399558f767602eb1d8d8c77d9db76a6860c03 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Wed, 13 May 2009 10:48:46 +0530 Subject: [PATCH 3/5] Expression checking corrected bzr revid: jvo@tinyerp.com-20090513051846-7qt47z4iwqhfs07a --- bin/osv/expression.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/osv/expression.py b/bin/osv/expression.py index 9cad5137387..c7817cfb637 100644 --- a/bin/osv/expression.py +++ b/bin/osv/expression.py @@ -254,11 +254,12 @@ 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 == '='): + + 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 ['<>', '!=']): + 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) From 5766b3cd04c17dc51d9d76047eaff6dc21e4f2d3 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Wed, 13 May 2009 14:43:03 +0530 Subject: [PATCH 4/5] [FIX] DB will save False Valuesfor booleans bzr revid: jvo@tinyerp.com-20090513091303-tyoe0u8bx6v8mgtt --- bin/osv/orm.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 + '"' From 4a966c47e13d409b6b05994cd08ac6d23b1a8c73 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Wed, 13 May 2009 17:40:04 +0530 Subject: [PATCH 5/5] [FIX] Expression : query handling problem bzr revid: jvo@tinyerp.com-20090513121004-kkb3wcqzhk2vyg21 --- bin/osv/expression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/osv/expression.py b/bin/osv/expression.py index c7817cfb637..7aa3b6aae57 100644 --- a/bin/osv/expression.py +++ b/bin/osv/expression.py @@ -256,11 +256,11 @@ class expression(object): params = [] 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) + 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 (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) + 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: