[FIX] Adapted mrp bom structure (exit controller, added model)

bzr revid: sle@openerp.com-20140320142520-3qapc7039q46eg9k
This commit is contained in:
Simon Lejeune 2014-03-20 15:25:20 +01:00
parent 52522bf0f9
commit d941bce076
2 changed files with 14 additions and 17 deletions

View File

@ -19,24 +19,22 @@
#
##############################################################################
from openerp.addons.web import http
from openerp.addons.web.http import request
from openerp.osv import osv
class bom_structure(http.Controller):
class bom_structure(osv.Model):
_name = 'report.mrp.report_mrpbomstructure'
@http.route(['/report/mrp.report_mrpbomstructure/<docids>'], type='http', auth='user', website=True, multilang=True)
def report_mrpbomstructure(self, docids):
ids = [int(i) for i in docids.split(',')]
ids = list(set(ids))
report_obj = request.registry['mrp.bom']
docs = report_obj.browse(request.cr, request.uid, ids, context=request.context)
def render_html(self, cr, uid, ids, data=None, context=None):
mrpbom_obj = self.pool['mrp.bom']
report_obj = self.pool['report']
docs = mrpbom_obj.browse(cr, uid, ids, context=context)
docargs = {
'docs': docs,
'get_children': self.get_children,
}
return request.registry['report'].render(request.cr, request.uid, [], 'mrp.report_mrpbomstructure', docargs)
return report_obj.render(cr, uid, [], 'mrp.report_mrpbomstructure', docargs)
def get_children(self, object, level=0):
result = []

View File

@ -228,13 +228,12 @@ class Report(osv.Model):
# If the report is using a custom model to render its html, we must use it.
# Otherwise, fallback on the generic html rendering.
if data is not None:
try:
report_model_name = 'report.%s' % report_name
particularreport_obj = self.pool[report_model_name]
return particularreport_obj.render_html(cr, uid, [], data=data, context=context)
except:
pass
try:
report_model_name = 'report.%s' % report_name
particularreport_obj = self.pool[report_model_name]
return particularreport_obj.render_html(cr, uid, ids, data=data, context=context)
except:
pass
if isinstance(ids, (str, unicode)):
ids = [int(i) for i in ids.split(',')]