[REF] base_report_designer: rml_parse has already a self.pool, not need to call pooler.get_pool().
bzr revid: vmt@openerp.com-20130327130449-zmpaqcfw1pddmg0b
This commit is contained in:
parent
598b455c22
commit
7b7de2bfc9
|
@ -24,7 +24,6 @@ import openerp.modules.registry
|
|||
from openerp.osv import osv
|
||||
from openerp_sxw2rml import sxw2rml
|
||||
from StringIO import StringIO
|
||||
from openerp import pooler
|
||||
from openerp import addons
|
||||
|
||||
|
||||
|
@ -46,20 +45,19 @@ class report_xml(osv.osv):
|
|||
'''
|
||||
Untested function
|
||||
'''
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
sxwval = StringIO(base64.decodestring(file_sxw))
|
||||
if file_type=='sxw':
|
||||
fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_oo2rml.xsl'),'rb')
|
||||
if file_type=='odt':
|
||||
fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_odt2rml.xsl'),'rb')
|
||||
report = pool.get('ir.actions.report.xml').write(cr, uid, [report_id], {
|
||||
report = self.pool['ir.actions.report.xml'].write(cr, uid, [report_id], {
|
||||
'report_sxw_content': base64.decodestring(file_sxw),
|
||||
'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read())),
|
||||
})
|
||||
|
||||
# FIXME: this should be moved to an override of the ir.actions.report_xml.create() method
|
||||
cr.commit()
|
||||
pool.get('ir.actions.report.xml').register_all(cr)
|
||||
self.pool['ir.actions.report.xml'].register_all(cr)
|
||||
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
|
||||
|
||||
return True
|
||||
|
|
|
@ -24,7 +24,7 @@ import base64
|
|||
import time
|
||||
import urllib
|
||||
|
||||
from openerp import osv, pooler, tools
|
||||
from openerp import osv, tools
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
@ -39,9 +39,9 @@ class base_report_sxw(osv.osv_memory):
|
|||
|
||||
def get_report(self, cr, uid, ids, context=None):
|
||||
data = self.read(cr, uid, ids, context=context)[0]
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
data_obj = self.pool['ir.model.data']
|
||||
id2 = data_obj._get_id(cr, uid, 'base_report_designer', 'view_base_report_file_sxw')
|
||||
report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context=context)
|
||||
report = self.pool['ir.actions.report.xml'].browse(cr, uid, data['report_id'], context=context)
|
||||
if id2:
|
||||
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
|
||||
return {
|
||||
|
@ -74,9 +74,9 @@ class base_report_file_sxw(osv.osv_memory):
|
|||
|
||||
"""
|
||||
res = super(base_report_file_sxw, self).default_get(cr, uid, fields, context=context)
|
||||
report_id1 = self.pool.get('base.report.sxw').search(cr,uid,[])
|
||||
data = self.pool.get('base.report.sxw').read(cr, uid, report_id1, context=context)[0]
|
||||
report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context=context)
|
||||
report_id1 = self.pool['base.report.sxw'].search(cr,uid,[])
|
||||
data = self.pool['base.report.sxw'].read(cr, uid, report_id1, context=context)[0]
|
||||
report = self.pool['ir.actions.report.xml'].browse(cr, uid, data['report_id'], context=context)
|
||||
if context is None:
|
||||
context={}
|
||||
if 'report_id' in fields:
|
||||
|
@ -97,14 +97,14 @@ class base_report_file_sxw(osv.osv_memory):
|
|||
sxwval = StringIO.StringIO(base64.decodestring(data['file_sxw_upload']))
|
||||
fp = tools.file_open('normalized_oo2rml.xsl',subdir='addons/base_report_designer/openerp_sxw2rml')
|
||||
newrmlcontent = str(openerp_sxw2rml.sxw2rml(sxwval, xsl=fp.read()))
|
||||
report = self.pool.get('ir.actions.report.xml').write(cr, uid, [data['report_id']], {
|
||||
report = self.pool['ir.actions.report.xml'].write(cr, uid, [data['report_id']], {
|
||||
'report_sxw_content': base64.decodestring(data['file_sxw_upload']),
|
||||
'report_rml_content': newrmlcontent
|
||||
})
|
||||
cr.commit()
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
data_obj = self.pool['ir.model.data']
|
||||
id2 = data_obj._get_id(cr, uid, 'base_report_designer', 'view_base_report_file_rml')
|
||||
report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context=context)
|
||||
report = self.pool['ir.actions.report.xml'].browse(cr, uid, data['report_id'], context=context)
|
||||
if id2:
|
||||
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
|
||||
return {
|
||||
|
@ -135,9 +135,9 @@ class base_report_rml_save(osv.osv_memory):
|
|||
"""
|
||||
|
||||
res = super(base_report_rml_save, self).default_get(cr, uid, fields, context=context)
|
||||
report_id = self.pool.get('base.report.sxw').search(cr,uid,[])
|
||||
data = self.pool.get('base.report.file.sxw').read(cr, uid, report_id, context=context)[0]
|
||||
report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context=context)
|
||||
report_id = self.pool['base.report.sxw'].search(cr,uid,[])
|
||||
data = self.pool['base.report.file.sxw'].read(cr, uid, report_id, context=context)[0]
|
||||
report = self.pool['ir.actions.report.xml'].browse(cr, uid, data['report_id'], context=context)
|
||||
|
||||
if 'file_rml' in fields:
|
||||
res['file_rml'] = base64.encodestring(report.report_rml_content)
|
||||
|
|
Loading…
Reference in New Issue