diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index ecb14b67977..0cb6cbc3243 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -25,12 +25,13 @@ import os
import tools
from tools.translate import _
from tools.safe_eval import safe_eval as eval
-
+from lxml import etree
import pooler
import netsvc
from report.interface import report_rml
from tools import to_xml
+from report import report_sxw
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'])
]
- def createReport(self, cr, uid, report, ids, name=False):
- files = []
- from report import report_sxw
- myreport = report_sxw.report_sxw('report.my.test', 'base','','')
- user_obj = pooler.get_pool(cr.dbname).get('res.users')
- user_name = user_obj.browse(cr, uid, [uid])[0]
- company = user_obj.browse(cr,uid,[uid])[0].company_id
-
- for id in ids:
- header_xml = """
-
-
-
-
-
- """+ to_xml(company.logo or removeParentNode('image')) +"""
- """+ to_xml(company.rml_header1) +"""
-
-
- 1.3cm 28.1cm 20cm 28.1cm
- """+ to_xml(company.name) +"""
- """+ to_xml(company.partner_id.name) +"""
- """+ to_xml(company.partner_id.address and company.partner_id.address[0].street or '') +"""
- """+ to_xml(company.partner_id.address and company.partner_id.address[0].zip or '') + """
- """+ to_xml(company.partner_id.address and company.partner_id.address[0].city or '') + """
- """+ to_xml("-") + """
- """+ to_xml(company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name or '') + """
- Phone:
- """+ to_xml(company.partner_id.address and company.partner_id.address[0].phone or '' ) + """
- Mail:
- """+ to_xml( company.partner_id.address and company.partner_id.address[0].email or '' ) + """
-
- 1.3cm 25.2cm 7.8cm 25.2cm
-
- 1.3cm 2.0cm 20cm 2.0cm
- """+ to_xml(company.rml_footer1)+"""
- """+ to_xml(company.rml_footer2)+"""
- Contact :
- """+ to_xml(user_name.name)+"""
- """+ to_xml("-")+"""
- Page:
-
-
-
-
- """
- report_type = 'pdf'
- pdf = myreport.create_pdf(header_xml)
- fp = open('/home/ksa/Desktop/test.pdf','wb+')
- fp.write(pdf);
- fp.close();
- return True
+ def createReport(self, cr, uid, ids, context=None):
+ company = self.browse(cr, uid, ids)[0]
+ rml = etree.XML(company.rml_header)
+ rml = rml.getchildren()[0]
+ header_xml = """
+ """ + etree.tostring(rml) + """
+
+
+ """
+ tmppath= '/tmp/previews.rml'
+ fp = open(tmppath, 'wb+')
+ fp.write(header_xml)
+ fp.close()
+ if not netsvc.Service._services.get('report.comapany.report'):
+ myreport = report_sxw.report_sxw('report.comapany.report', 'res.company', tmppath, header=False)
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'comapany.report',
+ 'datas': {'ids': ids, 'model': 'res.company'},
+ 'nodestroy': True
+ }
res_company()