[IMP]: Make Report to another way
bzr revid: ksa@tinyerp.co.in-20110413123657-ph4b3qdhhdcghn5x
This commit is contained in:
parent
383bf53a44
commit
ac1086ffe4
|
@ -25,12 +25,13 @@ import os
|
||||||
import tools
|
import tools
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
from tools.safe_eval import safe_eval as eval
|
from tools.safe_eval import safe_eval as eval
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
import pooler
|
import pooler
|
||||||
import netsvc
|
import netsvc
|
||||||
from report.interface import report_rml
|
from report.interface import report_rml
|
||||||
from tools import to_xml
|
from tools import to_xml
|
||||||
|
from report import report_sxw
|
||||||
|
|
||||||
class multi_company_default(osv.osv):
|
class multi_company_default(osv.osv):
|
||||||
"""
|
"""
|
||||||
|
@ -282,58 +283,27 @@ class res_company(osv.osv):
|
||||||
(osv.osv._check_recursion, 'Error! You can not create recursive companies.', ['parent_id'])
|
(osv.osv._check_recursion, 'Error! You can not create recursive companies.', ['parent_id'])
|
||||||
]
|
]
|
||||||
|
|
||||||
def createReport(self, cr, uid, report, ids, name=False):
|
def createReport(self, cr, uid, ids, context=None):
|
||||||
files = []
|
company = self.browse(cr, uid, ids)[0]
|
||||||
from report import report_sxw
|
rml = etree.XML(company.rml_header)
|
||||||
myreport = report_sxw.report_sxw('report.my.test', 'base','','')
|
rml = rml.getchildren()[0]
|
||||||
user_obj = pooler.get_pool(cr.dbname).get('res.users')
|
header_xml = """<document filename="Preview Report.pdf">
|
||||||
user_name = user_obj.browse(cr, uid, [uid])[0]
|
<template pageSize="(595.0,842.0)" title="Preview Report" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20">""" + etree.tostring(rml) + """
|
||||||
company = user_obj.browse(cr,uid,[uid])[0].company_id
|
</template>
|
||||||
|
</document>
|
||||||
for id in ids:
|
"""
|
||||||
header_xml = """<document filename="Preview Report.pdf">
|
tmppath= '/tmp/previews.rml'
|
||||||
<template pageSize="(595.0,842.0)" title="Preview Report" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20">
|
fp = open(tmppath, 'wb+')
|
||||||
<pageTemplate>
|
fp.write(header_xml)
|
||||||
<frame id="first" x1="1.3cm" y1="28.1cm" width="18.4cm" height="26.5cm"/>
|
fp.close()
|
||||||
<pageGraphics>
|
if not netsvc.Service._services.get('report.comapany.report'):
|
||||||
<setFont name="DejaVu Sans" size="8"/>
|
myreport = report_sxw.report_sxw('report.comapany.report', 'res.company', tmppath, header=False)
|
||||||
<image x="1.3cm" y="28cm" height="40.0" >"""+ to_xml(company.logo or removeParentNode('image')) +"""</image>
|
return {
|
||||||
<drawString x="16.3cm" y="28.3cm">"""+ to_xml(company.rml_header1) +"""</drawString>
|
'type': 'ir.actions.report.xml',
|
||||||
<fill color="black"/>
|
'report_name': 'comapany.report',
|
||||||
<stroke color="black"/>
|
'datas': {'ids': ids, 'model': 'res.company'},
|
||||||
<lines>1.3cm 28.1cm 20cm 28.1cm</lines>
|
'nodestroy': True
|
||||||
<drawString x="1.3cm" y="27.0cm">"""+ to_xml(company.name) +"""</drawString>
|
}
|
||||||
<drawString x="1.3cm" y="27.5cm">"""+ to_xml(company.partner_id.name) +"""</drawString>
|
|
||||||
<drawString x="1.3cm" y="26.6cm">"""+ to_xml(company.partner_id.address and company.partner_id.address[0].street or '') +"""</drawString>
|
|
||||||
<drawString x="1.3cm" y="26.2cm">"""+ to_xml(company.partner_id.address and company.partner_id.address[0].zip or '') + """</drawString>
|
|
||||||
<drawString x="2.2cm" y="26.2cm">"""+ to_xml(company.partner_id.address and company.partner_id.address[0].city or '') + """</drawString>
|
|
||||||
<drawString x="4.1cm" y="26.2cm">"""+ to_xml("-") + """</drawString>
|
|
||||||
<drawString x="4.4cm" y="26.2cm">"""+ to_xml(company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name or '') + """</drawString>
|
|
||||||
<drawString x="1.3cm" y="25.8cm">Phone:</drawString>
|
|
||||||
<drawString x="4.8cm" y="25.8cm">"""+ to_xml(company.partner_id.address and company.partner_id.address[0].phone or '' ) + """</drawString>
|
|
||||||
<drawString x="1.3cm" y="25.4cm">Mail:</drawString>
|
|
||||||
<drawString x="4.8cm" y="25.4cm">"""+ to_xml( company.partner_id.address and company.partner_id.address[0].email or '' ) + """</drawString>
|
|
||||||
<fill color="black"/>
|
|
||||||
<lines>1.3cm 25.2cm 7.8cm 25.2cm</lines>
|
|
||||||
<fill color="black"/>
|
|
||||||
<lines>1.3cm 2.0cm 20cm 2.0cm</lines>
|
|
||||||
<drawCentredString x="10.5cm" y="1.4cm">"""+ to_xml(company.rml_footer1)+""" </drawCentredString>
|
|
||||||
<drawCentredString x="10.5cm" y="1.0cm">"""+ to_xml(company.rml_footer2)+"""</drawCentredString>
|
|
||||||
<drawString x="7.9cm" y="0.5cm">Contact :</drawString>
|
|
||||||
<drawCentredString x="10.6cm" y="0.5cm">"""+ to_xml(user_name.name)+"""</drawCentredString>
|
|
||||||
<drawCentredString x="12.0cm" y="0.5cm">"""+ to_xml("-")+"""</drawCentredString>
|
|
||||||
<drawCentredString x="12.8cm" y="0.5cm">Page: <pageNumber/></drawCentredString>
|
|
||||||
</pageGraphics>
|
|
||||||
</pageTemplate>
|
|
||||||
</template>
|
|
||||||
</document>
|
|
||||||
"""
|
|
||||||
report_type = 'pdf'
|
|
||||||
pdf = myreport.create_pdf(header_xml)
|
|
||||||
fp = open('/home/ksa/Desktop/test.pdf','wb+')
|
|
||||||
fp.write(pdf);
|
|
||||||
fp.close();
|
|
||||||
return True
|
|
||||||
|
|
||||||
res_company()
|
res_company()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue