improve code
bzr revid: apa@tinyerp.com-20101007095127-1bjuobow1bt1sjcd
This commit is contained in:
@@ -70,7 +70,7 @@ class report_rml(report_int):
|
||||
def __init__(self, name, table, tmpl, xsl):
|
||||
super(report_rml, self).__init__(name)
|
||||
self.table = table
|
||||
self.pageCount=True
|
||||
self.internal_header=False
|
||||
self.tmpl = tmpl
|
||||
self.xsl = xsl
|
||||
self.bin_datas = {}
|
||||
@@ -111,6 +111,7 @@ class report_rml(report_int):
|
||||
return self.post_process_xml_data(cr, uid, xml, context)
|
||||
|
||||
def post_process_xml_data(self, cr, uid, xml, context=None):
|
||||
|
||||
if not context:
|
||||
context={}
|
||||
# find the position of the 3rd tag
|
||||
@@ -137,6 +138,8 @@ class report_rml(report_int):
|
||||
# TODO: The translation doesn't work for "<tag t="1">textext<tag> tex</tag>text</tag>"
|
||||
#
|
||||
def create_rml(self, cr, xml, uid, context=None):
|
||||
if self.tmpl=='' and not self.internal_header:
|
||||
self.internal_header=True
|
||||
if not context:
|
||||
context={}
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
@@ -176,13 +179,8 @@ class report_rml(report_int):
|
||||
|
||||
def create_pdf(self, rml, localcontext = None, logo=None, title=None):
|
||||
if not localcontext:
|
||||
localcontext={}
|
||||
if self.tmpl=='' and not self.pageCount:
|
||||
self.pageCount=True
|
||||
else:
|
||||
self.pageCount=False
|
||||
localcontext.update({'header':self.pageCount})
|
||||
|
||||
localcontext={}
|
||||
localcontext.update({'internal_header':self.internal_header})
|
||||
if logo:
|
||||
self.bin_datas['logo'] = logo
|
||||
else:
|
||||
@@ -190,7 +188,6 @@ class report_rml(report_int):
|
||||
del self.bin_datas['logo']
|
||||
obj = render.rml(rml, localcontext, self.bin_datas, tools.config['root_path'],title)
|
||||
obj.render()
|
||||
self.pageCount=True
|
||||
return obj.get()
|
||||
|
||||
def create_html(self, rml, localcontext = None, logo=None, title=None):
|
||||
|
||||
@@ -820,9 +820,7 @@ class TinyDocTemplate(platypus.BaseDocTemplate):
|
||||
class _rml_template(object):
|
||||
def __init__(self, localcontext, out, node, doc, images={}, path='.', title=None):
|
||||
if not localcontext:
|
||||
localcontext={'header':'internal'}
|
||||
if not localcontext.get('header',True):
|
||||
localcontext.update({'header':'internal'})
|
||||
localcontext={'internal_header':True}
|
||||
self.localcontext = localcontext
|
||||
self.images= images
|
||||
self.path = path
|
||||
@@ -871,16 +869,12 @@ class _rml_template(object):
|
||||
fis += r.render(node_story)
|
||||
# Reset Page Number with new story tag
|
||||
fis.append(PageReset())
|
||||
if self.localcontext and self.localcontext.get('header',False) and \
|
||||
(self.localcontext['header']=='internal' or self.localcontext['header']=='internal landscape'):
|
||||
self.doc_tmpl.afterFlowable(fis)
|
||||
story_cnt += 1
|
||||
if self.localcontext:
|
||||
fis.append(PageCount())
|
||||
if self.localcontext and self.localcontext.get('header',False) and \
|
||||
(self.localcontext['header']=='internal' or self.localcontext['header']=='internal landscape'):
|
||||
if self.localcontext and self.localcontext.get('internal_header',False):
|
||||
self.doc_tmpl.afterFlowable(fis)
|
||||
self.doc_tmpl.build(fis,canvasmaker=NumberedCanvas)
|
||||
else:
|
||||
fis.append(PageCount())
|
||||
self.doc_tmpl.build(fis)
|
||||
|
||||
def parseNode(rml, localcontext = {},fout=None, images={}, path='.',title=None):
|
||||
|
||||
@@ -364,13 +364,17 @@ class report_sxw(report_rml, preprocess.report):
|
||||
self.parser = parser
|
||||
self.header = header
|
||||
self.store = store
|
||||
self.internal_header=False
|
||||
if header=='internal' or header=='internal landscape':
|
||||
self.internal_header=True
|
||||
|
||||
def getObjects(self, cr, uid, ids, context):
|
||||
table_obj = pooler.get_pool(cr.dbname).get(self.table)
|
||||
return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context, fields_process=_fields_process)
|
||||
|
||||
def create(self, cr, uid, ids, data, context=None):
|
||||
context.update({'header':self.header})
|
||||
if self.internal_header:
|
||||
context.update({'internal_header':self.internal_header})
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ir_obj = pool.get('ir.actions.report.xml')
|
||||
report_xml_ids = ir_obj.search(cr, uid,
|
||||
|
||||
Reference in New Issue
Block a user