From f6573abc50d415e7e0607abafd4087ce3ac9add2 Mon Sep 17 00:00:00 2001 From: "dsh (Open ERP)" Date: Wed, 20 May 2009 18:32:45 +0530 Subject: [PATCH] changes for the image in html2html bzr revid: dsh@tinyerp.com-20090520130245-asx882zycp64mytd --- bin/report/render/html2html/html2html.py | 2 ++ bin/report/report_sxw.py | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bin/report/render/html2html/html2html.py b/bin/report/render/html2html/html2html.py index 7894dd78516..28c22f4b10e 100644 --- a/bin/report/render/html2html/html2html.py +++ b/bin/report/render/html2html/html2html.py @@ -49,6 +49,8 @@ class html2html(object): src = utils._process_text(self, new_child.get('name')) if src : new_child.set('src','data:image/gif;base64,%s'%src) + else : + new_child.getparent().remove(new_child) new_child.text = utils._process_text(self, child.text) self._node = copy.deepcopy(self.etree) for n in self._node: diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py index 19ca17ae1a3..22aa6e85f4b 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -196,12 +196,21 @@ class rml_parse(object): def removeParentNode(self, tag=None): raise Exception('Skip') - def set_html_image(self,attach_id): + def set_html_image(self,id,model=None,field=None): + if not id : + return '' + if not model: + model = 'ir.attachment' try : - att_id = int(attach_id) - attachment = self.pool.get('ir.attachment').browse(self.cr,self.uid,att_id) - return attachment.datas - except : + id = int(id) + res = self.pool.get(model).read(self.cr,self.uid,id) + if field : + return res[field] + elif model =='ir.attachment' : + return res['datas'] + else : + return '' + except Exception,e: return '' def setLang(self, lang):