[IMP] reports: support generic report_file field instead of report_xml ; add "file" attribute for <report> ; pending better refactoring after v6.0
bzr revid: odo@openerp.com-20101008142301-0os4ajp8xb9kt3cy
This commit is contained in:
parent
2171202b32
commit
f92f272130
|
@ -433,15 +433,14 @@
|
||||||
|
|
||||||
<field name="report_name" select="1"/>
|
<field name="report_name" select="1"/>
|
||||||
<field name="report_type"/>
|
<field name="report_type"/>
|
||||||
|
<field name="report_file"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<notebook colspan="4">
|
<notebook colspan="4">
|
||||||
<page string="Other Configuration">
|
<page string="Other Configuration">
|
||||||
<group col="2" colspan="2">
|
<group col="2" colspan="2">
|
||||||
<separator string="RML Report" colspan="2"/>
|
<separator string="RML Report" colspan="2"/>
|
||||||
<field name="report_rml"/>
|
|
||||||
<field name="header"/>
|
<field name="header"/>
|
||||||
<field name="auto"/>
|
|
||||||
</group>
|
</group>
|
||||||
<group col="2" colspan="2">
|
<group col="2" colspan="2">
|
||||||
<separator string="XML Report" colspan="2"/>
|
<separator string="XML Report" colspan="2"/>
|
||||||
|
@ -456,6 +455,7 @@
|
||||||
<group col="2" colspan="2">
|
<group col="2" colspan="2">
|
||||||
<separator string="Miscellaneous" colspan="2"/>
|
<separator string="Miscellaneous" colspan="2"/>
|
||||||
<field name="multi"/>
|
<field name="multi"/>
|
||||||
|
<field name="auto"/>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page string="Security">
|
<page string="Security">
|
||||||
|
|
|
@ -114,9 +114,13 @@ class report_xml(osv.osv):
|
||||||
|
|
||||||
'report_xsl': fields.char('XSL path', size=256),
|
'report_xsl': fields.char('XSL path', size=256),
|
||||||
'report_xml': fields.char('XML path', size=256, help=''),
|
'report_xml': fields.char('XML path', size=256, help=''),
|
||||||
'report_rml': fields.char('RML path', size=256, help="The .rml path of the file or NULL if the content is in report_rml_content"),
|
|
||||||
'report_sxw': fields.function(_report_sxw, method=True, type='char', string='SXW path'),
|
|
||||||
|
|
||||||
|
# Pending deprecation... to be replaced by report_file as this object will become the default report object (not so specific to RML anymore)
|
||||||
|
'report_rml': fields.char('Main report file path', size=256, help="The path to the main report file (depending on Report Type) or NULL if the content is in another data field"),
|
||||||
|
# temporary related field as report_rml is pending deprecation - this field will replace report_rml after v6.0
|
||||||
|
'report_file': fields.related('report_rml', type="char", size=256, required=False, readonly=False, string='Report file', help="The path to the main report file (depending on Report Type) or NULL if the content is in another field", store=True),
|
||||||
|
|
||||||
|
'report_sxw': fields.function(_report_sxw, method=True, type='char', string='SXW path'),
|
||||||
'report_sxw_content_data': fields.binary('SXW content'),
|
'report_sxw_content_data': fields.binary('SXW content'),
|
||||||
'report_rml_content_data': fields.binary('RML content'),
|
'report_rml_content_data': fields.binary('RML content'),
|
||||||
'report_sxw_content': fields.function(_report_content, fnct_inv=_report_content_inv, method=True, type='binary', string='SXW content',),
|
'report_sxw_content': fields.function(_report_content, fnct_inv=_report_content_inv, method=True, type='binary', string='SXW content',),
|
||||||
|
|
|
@ -104,7 +104,8 @@
|
||||||
<rng:optional><rng:attribute name="multi"/></rng:optional>
|
<rng:optional><rng:attribute name="multi"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="menu"/></rng:optional>
|
<rng:optional><rng:attribute name="menu"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="keyword"/></rng:optional>
|
<rng:optional><rng:attribute name="keyword"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="rml"/></rng:optional>
|
<rng:optional><rng:attribute name="rml"/></rng:optional><!-- pending deprecation after v6.0 -->
|
||||||
|
<rng:optional><rng:attribute name="file"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="sxw"/></rng:optional>
|
<rng:optional><rng:attribute name="sxw"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="xml"/></rng:optional>
|
<rng:optional><rng:attribute name="xml"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="xsl"/></rng:optional>
|
<rng:optional><rng:attribute name="xsl"/></rng:optional>
|
||||||
|
|
|
@ -19,24 +19,18 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import traceback, sys
|
|
||||||
import StringIO
|
import StringIO
|
||||||
import cStringIO
|
import cStringIO
|
||||||
import base64
|
import base64
|
||||||
import copy
|
|
||||||
import locale
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
from interface import report_rml
|
from interface import report_rml
|
||||||
import preprocess
|
import preprocess
|
||||||
import ir
|
import logging
|
||||||
import netsvc
|
|
||||||
import osv
|
|
||||||
import pooler
|
import pooler
|
||||||
import tools
|
import tools
|
||||||
import warnings
|
|
||||||
import zipfile
|
import zipfile
|
||||||
import common
|
import common
|
||||||
from osv.fields import float as float_class, function as function_class
|
from osv.fields import float as float_class, function as function_class
|
||||||
|
@ -319,7 +313,7 @@ class rml_parse(object):
|
||||||
if not self._transl_regex.match(piece_list[pn]):
|
if not self._transl_regex.match(piece_list[pn]):
|
||||||
source_string = piece_list[pn].replace('\n', ' ').strip()
|
source_string = piece_list[pn].replace('\n', ' ').strip()
|
||||||
if len(source_string):
|
if len(source_string):
|
||||||
translated_string = transl_obj._get_source(self.cr, self.uid, self.name, 'rml', lang, source_string)
|
translated_string = transl_obj._get_source(self.cr, self.uid, self.name, ('report', 'rml'), lang, source_string)
|
||||||
if translated_string:
|
if translated_string:
|
||||||
piece_list[pn] = piece_list[pn].replace(source_string, translated_string)
|
piece_list[pn] = piece_list[pn].replace(source_string, translated_string)
|
||||||
text = ''.join(piece_list)
|
text = ''.join(piece_list)
|
||||||
|
@ -434,8 +428,8 @@ class report_sxw(report_rml, preprocess.report):
|
||||||
result = self.create_single_pdf(cr, uid, [obj.id], data, report_xml, context)
|
result = self.create_single_pdf(cr, uid, [obj.id], data, report_xml, context)
|
||||||
if not result:
|
if not result:
|
||||||
return False
|
return False
|
||||||
try:
|
if aname:
|
||||||
if aname:
|
try:
|
||||||
name = aname+'.'+result[1]
|
name = aname+'.'+result[1]
|
||||||
pool.get('ir.attachment').create(cr, uid, {
|
pool.get('ir.attachment').create(cr, uid, {
|
||||||
'name': aname,
|
'name': aname,
|
||||||
|
@ -445,11 +439,9 @@ class report_sxw(report_rml, preprocess.report):
|
||||||
'res_id': obj.id,
|
'res_id': obj.id,
|
||||||
}, context=context
|
}, context=context
|
||||||
)
|
)
|
||||||
cr.commit()
|
except Exception:
|
||||||
except Exception,e:
|
#TODO: should probably raise a proper osv_except instead, shouldn't we? see LP bug #325632
|
||||||
import traceback, sys
|
logging.getLogger('report').error('Could not create saved report attachment', exc_info=True)
|
||||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
|
||||||
netsvc.Logger().notifyChannel('report', netsvc.LOG_ERROR,str(e))
|
|
||||||
results.append(result)
|
results.append(result)
|
||||||
if results:
|
if results:
|
||||||
if results[0][1]=='pdf':
|
if results[0][1]=='pdf':
|
||||||
|
|
|
@ -300,7 +300,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
for dest,f in (('name','string'),('model','model'),('report_name','name')):
|
for dest,f in (('name','string'),('model','model'),('report_name','name')):
|
||||||
res[dest] = rec.get(f,'').encode('utf8')
|
res[dest] = rec.get(f,'').encode('utf8')
|
||||||
assert res[dest], "Attribute %s of report is empty !" % (f,)
|
assert res[dest], "Attribute %s of report is empty !" % (f,)
|
||||||
for field,dest in (('rml','report_rml'),('xml','report_xml'),('xsl','report_xsl'),('attachment','attachment'),('attachment_use','attachment_use')):
|
for field,dest in (('rml','report_rml'),('file','report_file'),('xml','report_xml'),('xsl','report_xsl'),('attachment','attachment'),('attachment_use','attachment_use')):
|
||||||
if rec.get(field):
|
if rec.get(field):
|
||||||
res[dest] = rec.get(field).encode('utf8')
|
res[dest] = rec.get(field).encode('utf8')
|
||||||
if rec.get('auto'):
|
if rec.get('auto'):
|
||||||
|
|
|
@ -675,7 +675,7 @@ class YamlInterpreter(object):
|
||||||
for dest, f in (('name','string'), ('model','model'), ('report_name','name')):
|
for dest, f in (('name','string'), ('model','model'), ('report_name','name')):
|
||||||
values[dest] = getattr(node, f)
|
values[dest] = getattr(node, f)
|
||||||
assert values[dest], "Attribute %s of report is empty !" % (f,)
|
assert values[dest], "Attribute %s of report is empty !" % (f,)
|
||||||
for field,dest in (('rml','report_rml'),('xml','report_xml'),('xsl','report_xsl'),('attachment','attachment'),('attachment_use','attachment_use')):
|
for field,dest in (('rml','report_rml'),('file','report_file'),('xml','report_xml'),('xsl','report_xsl'),('attachment','attachment'),('attachment_use','attachment_use')):
|
||||||
if getattr(node, field):
|
if getattr(node, field):
|
||||||
values[dest] = getattr(node, field)
|
values[dest] = getattr(node, field)
|
||||||
if node.auto:
|
if node.auto:
|
||||||
|
|
Loading…
Reference in New Issue