Example #1
0
 def create_xml(self, cr, uid, ids, datas, context=None):
     if not context:
         context={}
     doc = print_xml.document(cr, uid, datas, {})
     self.bin_datas.update( doc.bin_datas  or {})
     doc.parse(self.tmpl, ids, self.table, context)
     xml = doc.xml_get()
     doc.close()
     return self.post_process_xml_data(cr, uid, xml, context)
Example #2
0
 def create_xml(self, cr, uid, ids, datas, context=None):
     if not context:
         context = {}
     doc = print_xml.document(cr, uid, datas, {})
     self.bin_datas.update(doc.bin_datas or {})
     doc.parse(self.tmpl, ids, self.table, context)
     xml = doc.xml_get()
     doc.close()
     return self.post_process_xml_data(cr, uid, xml, context)
Example #3
0
    def post_process_xml_data(self, cr, uid, xml, context=None):
        if not context:
            context={}
        # find the position of the 3rd tag
        # (skip the <?xml ...?> and the "root" tag)
        iter = re.finditer('<[^>]*>', xml)
        i = iter.next()
        i = iter.next()
        pos_xml = i.end()

        doc = print_xml.document(cr, uid, {}, {})
        tmpl_path = addons.get_module_resource('base', 'report', 'corporate_defaults.xml')
        doc.parse(tmpl_path, [uid], 'res.users', context)
        corporate_header = doc.xml_get()
        doc.close()

        # find the position of the tag after the <?xml ...?> tag
        iter = re.finditer('<[^>]*>', corporate_header)
        i = iter.next()
        pos_header = i.end()

        return xml[:pos_xml] + corporate_header[pos_header:] + xml[pos_xml:]
Example #4
0
    def post_process_xml_data(self, cr, uid, xml, context=None):

        if not context:
            context={}
        # find the position of the 3rd tag
        # (skip the <?xml ...?> and the "root" tag)
        iter = re.finditer('<[^>]*>', xml)
        i = iter.next()
        i = iter.next()
        pos_xml = i.end()

        doc = print_xml.document(cr, uid, {}, {})
        tmpl_path = addons.get_module_resource('base', 'report', 'corporate_defaults.xml')
        doc.parse(tmpl_path, [uid], 'res.users', context)
        corporate_header = doc.xml_get()
        doc.close()

        # find the position of the tag after the <?xml ...?> tag
        iter = re.finditer('<[^>]*>', corporate_header)
        i = iter.next()
        pos_header = i.end()

        return xml[:pos_xml] + corporate_header[pos_header:] + xml[pos_xml:]