[Fix,IMP]:xsl:sml reports for comment node and when there is no type attribute in...
authorNaresh Choksy <nch@tinyerp.com>
Tue, 25 Aug 2009 07:29:34 +0000 (12:59 +0530)
committerNaresh Choksy <nch@tinyerp.com>
Tue, 25 Aug 2009 07:29:34 +0000 (12:59 +0530)
bzr revid: nch@tinyerp.com-20090825072934-ugwcxnl30gx0sdzs

bin/addons/base/report/corporate_defaults.xsl
bin/report/print_xml.py

index de2ef8e..4140714 100644 (file)
                <fill color="black"/>
                <stroke color="black"/>
                <drawString x="1cm" y="27.6cm"><xsl:value-of select="//corporate-header/corporation/name"/></drawString>
-               <lines>1cm 25.4cm 20cm 25.4cm</lines>
-<!--           <lines>1cm 25.7cm 7cm 25.7cm</lines>-->
+               <lines>1cm 28.4cm 20cm 28.4cm</lines>
+               <lines>1cm 25.4cm 7cm 25.4cm</lines>
 
                <setFont name="Helvetica" size="10"/>
-               <drawRightString x="1cm" y="27.5cm"><xsl:value-of select="//corporate-header/corporation/rml_header1"/></drawRightString>
+               <drawRightString x="20cm" y="28.5cm"><xsl:value-of select="//corporate-header/corporation/rml_header1"/></drawRightString>
                <drawString x="1cm" y="27cm"><xsl:value-of select="//corporate-header/corporation/address/street"/></drawString>
                <drawString x="1cm" y="26.5cm">
                        <xsl:value-of select="//corporate-header/corporation/address/zip"/>
                <drawRightString x="7cm" y="26cm"><xsl:value-of select="//corporate-header/corporation/address/phone"/></drawRightString>
                <drawString x="1cm" y="25.5cm">Mail:</drawString>
                <drawRightString x="7cm" y="25.5cm"><xsl:value-of select="//corporate-header/corporation/address/email"/></drawRightString>
+
 
                <!--page bottom-->
-               
-               <lines>1.5cm 1.2cm 19.9cm 1.2cm</lines>
+
+               <lines>1.5cm 2.2cm 19.9cm 2.2cm</lines>
                <drawCentredString x="10.5cm" y="1.7cm"><xsl:value-of select="//corporate-header/corporation/rml_footer1"/></drawCentredString>
                <drawCentredString x="10.5cm" y="1.25cm"><xsl:value-of select="//corporate-header/corporation/rml_footer2"/></drawCentredString>
                <drawCentredString x="10.5cm" y="0.8cm">Your contact : <xsl:value-of select="//corporate-header/user/name"/></drawCentredString>
-       
+
        </xsl:template>
-       
+
 
        <xsl:template name="other_pages_graphics_corporation">
                <!--logo-->
@@ -71,7 +71,7 @@
                <drawRightString x="7cm" y="25.5cm"><xsl:value-of select="//corporate-header/corporation/address/email"/></drawRightString>
 
                <!--page bottom-->
-               
+
                <lines>1.5cm 1.2cm 19.9cm 1.2cm</lines>
                <drawCentredString x="10.5cm" y="1.7cm"><xsl:value-of select="//corporate-header/corporation/rml_footer1"/></drawCentredString>
                <drawCentredString x="10.5cm" y="1.25cm"><xsl:value-of select="//corporate-header/corporation/rml_footer2"/></drawCentredString>
index 63b3424..912fdad 100644 (file)
@@ -209,7 +209,6 @@ class document(object):
                         args = [self.eval(browser, arg) for arg in attrs['args'].split(',')]
                     else:
                         args = []
-
                     # get the object
                     if attrs.has_key('model'):
                         obj = self.pool.get(attrs['model'])
@@ -232,6 +231,7 @@ class document(object):
                     newdatas = getattr(obj, attrs['name'])(self.cr, self.uid, ids, *args)
 
                     def parse_result_tree(node, parent, datas):
+                        if not node.tag == etree.Comment:
                             el = etree.Element(node.tag)
                             parent.append(el)
                             atr = self.node_attrs_get(node)
@@ -251,7 +251,6 @@ class document(object):
 
                 elif attrs['type']=='zoom':
                     value = self.get_value(browser, attrs['name'])
-
                     if value:
                         if not isinstance(value, list):
                             v_list = [value]
@@ -264,12 +263,16 @@ class document(object):
                                 self.parse_node(el_cld, el, v)
             else:
                 # if there is no "type" attribute in the node, copy it to the xml data and parse its childs
-                for el_cld in node:
-                    self.parse_node(el_cld, parent, browser)
-
+                if not node.tag == etree.Comment:
+                    if node.tag == parent.tag:
+                        el = parent
+                    else:
+                        el = etree.Element(node.tag)
+                        parent.append(el)
+                    for el_cld in node:
+                        self.parse_node(el_cld,el, browser)
     def xml_get(self):
-        #return self.doc.toxml('utf-8')
-        return etree.tostring(self.doc,encoding="utf-8",xml_declaration=True)
+        return etree.tostring(self.doc,encoding="utf-8",xml_declaration=True,pretty_print=True)
 
     def parse_tree(self, ids, model, context=None):
         if not context:
@@ -282,7 +285,6 @@ class document(object):
             context={}
         # parses the xml template to memory
         self.dom = etree.XML(xml)
-
         # create the xml data from the xml template
         self.parse_tree(ids, model, context)