Use the txt report in the OpenObject server
Activate that report type, so that the server can use it. bzr revid: p_christ@hol.gr-20081212231618-fkk5wd7bja0dih45
This commit is contained in:
parent
09866d0444
commit
a52ccd2c3f
|
@ -119,6 +119,7 @@ class report_xml(osv.osv):
|
|||
('html', 'html'),
|
||||
('raw', 'raw'),
|
||||
('sxw', 'sxw'),
|
||||
('txt', 'txt'),
|
||||
], string='Type', required=True),
|
||||
'groups_id': fields.many2many('res.groups', 'res_groups_report_rel', 'uid', 'gid', 'Groups'),
|
||||
'attachment': fields.char('Save As Attachment Prefix', size=32, help='This is the prefix of the file name the print will be saved as attachement. Keep empty to not save the printed reports')
|
||||
|
|
|
@ -81,15 +81,16 @@ class report_rml(report_int):
|
|||
'html': self.create_html,
|
||||
'raw': self.create_raw,
|
||||
'sxw': self.create_sxw,
|
||||
'txt': self.create_txt,
|
||||
}
|
||||
|
||||
def create(self, cr, uid, ids, datas, context):
|
||||
xml = self.create_xml(cr, uid, ids, datas, context)
|
||||
# file('/tmp/terp.xml','wb+').write(xml)
|
||||
#file('/tmp/terp.xml','wb+').write(xml)
|
||||
if datas.get('report_type', 'pdf') == 'raw':
|
||||
return xml
|
||||
rml = self.create_rml(cr, xml, uid, context)
|
||||
# file('/tmp/terp.rml','wb+').write(rml)
|
||||
#file('/tmp/terp.rml','wb+').write(rml)
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ir_actions_report_xml_obj = pool.get('ir.actions.report.xml')
|
||||
try:
|
||||
|
@ -208,6 +209,11 @@ class report_rml(report_int):
|
|||
obj.render()
|
||||
return obj.get()
|
||||
|
||||
def create_txt(self, xml, logo=None, title=None):
|
||||
obj = render.rml2txt(xml, self.bin_datas)
|
||||
obj.render()
|
||||
return obj.get().encode('utf-8')
|
||||
|
||||
def create_raw(self, xml, logo=None, title=None):
|
||||
return xml
|
||||
|
||||
|
@ -235,4 +241,3 @@ def register_all(db):
|
|||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
##############################################################################
|
||||
|
||||
from simple import simple
|
||||
from rml import rml, rml2html
|
||||
from rml import rml, rml2html, rml2txt
|
||||
|
||||
from render import render
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
import render
|
||||
import rml2pdf
|
||||
import rml2html as htmlizer
|
||||
import rml2txt as txtizer
|
||||
|
||||
class rml(render.render):
|
||||
def __init__(self, xml, datas={}, path='.',title=None):
|
||||
|
@ -44,5 +45,14 @@ class rml2html(render.render):
|
|||
def _render(self):
|
||||
return htmlizer.parseString(self.xml)
|
||||
|
||||
class rml2txt(render.render):
|
||||
def __init__(self, xml, datas={}):
|
||||
super(rml2txt, self).__init__(datas)
|
||||
self.xml = xml
|
||||
self.output_type = 'txt'
|
||||
|
||||
def _render(self):
|
||||
return txtizer.parseString(self.xml)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
Loading…
Reference in New Issue