[FIX] Multiples fixes: correct context passing, changed osv.Model to osv.AbstractModel to avoid creating tables in database when the model use for the reports contains only method
bzr revid: sle@openerp.com-20140321105806-0bwo992995la91fe
This commit is contained in:
parent
246ec6854b
commit
57e6e8fd28
|
@ -30,12 +30,12 @@ except ImportError:
|
||||||
import xlwt
|
import xlwt
|
||||||
|
|
||||||
|
|
||||||
class tax_report(osv.Model, common_report_header):
|
class tax_report(osv.AbstractModel, common_report_header):
|
||||||
_name = 'report.account.report_vat'
|
_name = 'report.account.report_vat'
|
||||||
|
|
||||||
def render_html(self, cr, uid, ids, data=None, context=None):
|
def render_html(self, cr, uid, ids, data=None, context=None):
|
||||||
report_obj = request.registry['report']
|
report_obj = request.registry['report']
|
||||||
self.cr, self.uid = cr, uid
|
self.cr, self.uid, self.context = cr, uid, context
|
||||||
|
|
||||||
res = {}
|
res = {}
|
||||||
self.period_ids = []
|
self.period_ids = []
|
||||||
|
@ -55,7 +55,7 @@ class tax_report(osv.Model, common_report_header):
|
||||||
'period_to': self.get_end_period(data),
|
'period_to': self.get_end_period(data),
|
||||||
'taxlines': self._get_lines(self._get_basedon(data), company_id=data['form']['company_id']),
|
'taxlines': self._get_lines(self._get_basedon(data), company_id=data['form']['company_id']),
|
||||||
}
|
}
|
||||||
return report_obj.render(self.cr, self.uid, [], 'account.report_vat', docargs)
|
return report_obj.render(self.cr, self.uid, [], 'account.report_vat', docargs, context=context)
|
||||||
|
|
||||||
def _get_basedon(self, form):
|
def _get_basedon(self, form):
|
||||||
return form['form']['based_on']
|
return form['form']['based_on']
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
from openerp.osv import osv
|
from openerp.osv import osv
|
||||||
|
|
||||||
|
|
||||||
class bom_structure(osv.Model):
|
class bom_structure(osv.AbstractModel):
|
||||||
_name = 'report.mrp.report_mrpbomstructure'
|
_name = 'report.mrp.report_mrpbomstructure'
|
||||||
|
|
||||||
def render_html(self, cr, uid, ids, data=None, context=None):
|
def render_html(self, cr, uid, ids, data=None, context=None):
|
||||||
|
|
|
@ -32,13 +32,12 @@ class ReportController(Controller):
|
||||||
#------------------------------------------------------
|
#------------------------------------------------------
|
||||||
# Generic reports controller
|
# Generic reports controller
|
||||||
#------------------------------------------------------
|
#------------------------------------------------------
|
||||||
|
@route('/report/<reportname>/<docids>', type='http', auth='user', website=True, multilang=True)
|
||||||
@route(['/report/<reportname>/<docids>'], type='http', auth='user', website=True, multilang=True)
|
|
||||||
def report_html(self, reportname, docids):
|
def report_html(self, reportname, docids):
|
||||||
cr, uid, context = request.cr, request.uid, request.context
|
cr, uid, context = request.cr, request.uid, request.context
|
||||||
return request.registry['report'].get_html(cr, uid, docids, reportname, context=context)
|
return request.registry['report'].get_html(cr, uid, docids, reportname, context=context)
|
||||||
|
|
||||||
@route(['/report/pdf/report/<reportname>/<docids>'], type='http', auth="user", website=True)
|
@route('/report/pdf/report/<reportname>/<docids>', type='http', auth="user", website=True)
|
||||||
def report_pdf(self, reportname, docids):
|
def report_pdf(self, reportname, docids):
|
||||||
cr, uid, context = request.cr, request.uid, request.context
|
cr, uid, context = request.cr, request.uid, request.context
|
||||||
pdf = request.registry['report'].get_pdf(cr, uid, docids, reportname, context=context)
|
pdf = request.registry['report'].get_pdf(cr, uid, docids, reportname, context=context)
|
||||||
|
@ -48,15 +47,14 @@ class ReportController(Controller):
|
||||||
#------------------------------------------------------
|
#------------------------------------------------------
|
||||||
# Particular reports controller
|
# Particular reports controller
|
||||||
#------------------------------------------------------
|
#------------------------------------------------------
|
||||||
|
@route('/report/<reportname>', type='http', auth='user', website=True, multilang=True)
|
||||||
@route(['/report/<reportname>'], type='http', auth='user', website=True, multilang=True)
|
|
||||||
def report_html_particular(self, reportname, **data):
|
def report_html_particular(self, reportname, **data):
|
||||||
cr, uid, context = request.cr, request.uid, request.context
|
cr, uid, context = request.cr, request.uid, request.context
|
||||||
report_obj = request.registry['report']
|
report_obj = request.registry['report']
|
||||||
data = report_obj.eval_params(data) # Sanitizing
|
data = report_obj.eval_params(data) # Sanitizing
|
||||||
return report_obj.get_html(cr, uid, [], reportname, data=data, context=context)
|
return report_obj.get_html(cr, uid, [], reportname, data=data, context=context)
|
||||||
|
|
||||||
@route(['/report/pdf/report/<reportname>'], type='http', auth='user', website=True, multilang=True)
|
@route('/report/pdf/report/<reportname>', type='http', auth='user', website=True, multilang=True)
|
||||||
def report_pdf_particular(self, reportname, **data):
|
def report_pdf_particular(self, reportname, **data):
|
||||||
cr, uid, context = request.cr, request.uid, request.context
|
cr, uid, context = request.cr, request.uid, request.context
|
||||||
report_obj = request.registry['report']
|
report_obj = request.registry['report']
|
||||||
|
@ -66,15 +64,15 @@ class ReportController(Controller):
|
||||||
return request.make_response(pdf, headers=pdfhttpheaders)
|
return request.make_response(pdf, headers=pdfhttpheaders)
|
||||||
|
|
||||||
#------------------------------------------------------
|
#------------------------------------------------------
|
||||||
# Misc. utils
|
# Misc. route utils
|
||||||
#------------------------------------------------------
|
#------------------------------------------------------
|
||||||
|
|
||||||
@route(['/report/barcode', '/report/barcode/<type>/<path:value>'], type='http', auth="user")
|
@route(['/report/barcode', '/report/barcode/<type>/<path:value>'], type='http', auth="user")
|
||||||
def report_barcode(self, type, value, width=300, height=50):
|
def report_barcode(self, type, value, width=300, height=50):
|
||||||
"""Contoller able to render barcode images thanks to reportlab.
|
"""Contoller able to render barcode images thanks to reportlab.
|
||||||
Samples:
|
Samples:
|
||||||
<img t-att-src="'/report/barcode/QR/%s' % o.name"/>
|
<img t-att-src="'/report/barcode/QR/%s' % o.name"/>
|
||||||
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('QR', o.name, 200, 200)"/>
|
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' %
|
||||||
|
('QR', o.name, 200, 200)"/>
|
||||||
|
|
||||||
:param type: Accepted types: 'Codabar', 'Code11', 'Code128', 'EAN13', 'EAN8', 'Extended39',
|
:param type: Accepted types: 'Codabar', 'Code11', 'Code128', 'EAN13', 'EAN8', 'Extended39',
|
||||||
'Extended93', 'FIM', 'I2of5', 'MSI', 'POSTNET', 'QR', 'Standard39', 'Standard93',
|
'Extended93', 'FIM', 'I2of5', 'MSI', 'POSTNET', 'QR', 'Standard39', 'Standard93',
|
||||||
|
@ -112,9 +110,8 @@ class ReportController(Controller):
|
||||||
else:
|
else:
|
||||||
# Particular report:
|
# Particular report:
|
||||||
querystring = url.split('?')[1]
|
querystring = url.split('?')[1]
|
||||||
querystring = urlparse.parse_qsl(querystring)
|
querystring = dict(urlparse.parse_qsl(querystring))
|
||||||
dict_querystring = dict(querystring)
|
response = self.report_pdf_particular(reportname, **querystring)
|
||||||
response = self.report_pdf_particular(reportname, **dict_querystring)
|
|
||||||
|
|
||||||
response.headers.add('Content-Disposition', 'attachment; filename=%s.pdf;' % reportname)
|
response.headers.add('Content-Disposition', 'attachment; filename=%s.pdf;' % reportname)
|
||||||
response.set_cookie('fileToken', token)
|
response.set_cookie('fileToken', token)
|
||||||
|
|
|
@ -187,29 +187,12 @@ class Report(osv.Model):
|
||||||
qcontext['o'] = self.pool[model].browse(cr, uid, doc_id, context=ctx)
|
qcontext['o'] = self.pool[model].browse(cr, uid, doc_id, context=ctx)
|
||||||
return view_obj.render(cr, uid, template, qcontext, context=ctx)
|
return view_obj.render(cr, uid, template, qcontext, context=ctx)
|
||||||
|
|
||||||
current_user = self.pool['res.users'].browse(cr, uid, uid, context=context)
|
|
||||||
|
|
||||||
# Website independance code
|
|
||||||
website = False
|
|
||||||
res_company = current_user.company_id
|
|
||||||
|
|
||||||
try:
|
|
||||||
from openerp.addons.web.http import request
|
|
||||||
if request.website:
|
|
||||||
website = request.website
|
|
||||||
res_company = request.website.company_id
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
values.update({
|
values.update({
|
||||||
'time': time,
|
'time': time,
|
||||||
'user': current_user,
|
|
||||||
'user_id': current_user.id,
|
|
||||||
'formatLang': lambda *args, **kwargs: self.formatLang(*args, cr=cr, uid=uid, **kwargs),
|
'formatLang': lambda *args, **kwargs: self.formatLang(*args, cr=cr, uid=uid, **kwargs),
|
||||||
'get_digits': self.get_digits,
|
'get_digits': self.get_digits,
|
||||||
'render_doc': render_doc,
|
'render_doc': render_doc,
|
||||||
'website': website,
|
'editable': True, # Will active inherit_branding
|
||||||
'res_company': res_company,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return view_obj.render(cr, uid, template, values, context=context)
|
return view_obj.render(cr, uid, template, values, context=context)
|
||||||
|
|
|
@ -49,7 +49,7 @@ openerp.report = function(instance) {
|
||||||
}
|
}
|
||||||
if (action.report_type == 'qweb-html' || action.report_type == 'controller') {
|
if (action.report_type == 'qweb-html' || action.report_type == 'controller') {
|
||||||
// Open the html report in a popup
|
// Open the html report in a popup
|
||||||
window.open(report_url, '_blank', 'height=768,width=1024');
|
window.open(report_url, '_blank', 'height=900,width=1280');
|
||||||
instance.web.unblockUI();
|
instance.web.unblockUI();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -63,7 +63,7 @@ openerp.report = function(instance) {
|
||||||
// Fallback of qweb-pdf if wkhtmltopdf is not installed
|
// Fallback of qweb-pdf if wkhtmltopdf is not installed
|
||||||
if (!presence && action.report_type == 'qweb-pdf') {
|
if (!presence && action.report_type == 'qweb-pdf') {
|
||||||
self.do_notify(_t('Report'), _t('Unable to find Wkhtmltopdf on this \
|
self.do_notify(_t('Report'), _t('Unable to find Wkhtmltopdf on this \
|
||||||
system. The report will be shown in html.<br><br><a href="http://wkhtmltopdf.org/" _target="blank">\
|
system. The report will be shown in html.<br><br><a href="http://wkhtmltopdf.org/" target="_blank">\
|
||||||
wkhtmltopdf.org</a>'), true);
|
wkhtmltopdf.org</a>'), true);
|
||||||
window.open(report_url.substring(12), '_blank', 'height=768,width=1024');
|
window.open(report_url.substring(12), '_blank', 'height=768,width=1024');
|
||||||
instance.web.unblockUI();
|
instance.web.unblockUI();
|
||||||
|
|
|
@ -42,16 +42,18 @@
|
||||||
|
|
||||||
<script type="text/javascript" src="/web/static/lib/select2/select2.js"></script>
|
<script type="text/javascript" src="/web/static/lib/select2/select2.js"></script>
|
||||||
<script type="text/javascript" src="/web/static/lib/ckeditor/ckeditor.js"></script>
|
<script type="text/javascript" src="/web/static/lib/ckeditor/ckeditor.js"></script>
|
||||||
<script type="text/javascript" src="/website/static/lib/bootstrap-tour/bootstrap-tour.js"></script>
|
|
||||||
<script t-if="not translatable" type="text/javascript" src="/website/static/lib/ace/ace.js"></script>
|
<script t-if="not translatable" type="text/javascript" src="/website/static/lib/ace/ace.js"></script>
|
||||||
<script type="text/javascript" src="/website/static/lib/vkbeautify/vkbeautify.0.99.00.beta.js"></script>
|
<script type="text/javascript" src="/website/static/lib/vkbeautify/vkbeautify.0.99.00.beta.js"></script>
|
||||||
<script type="text/javascript" src="/web/static/lib/jquery.ui/js/jquery-ui-1.9.1.custom.js"></script>
|
<script type="text/javascript" src="/web/static/lib/jquery.ui/js/jquery-ui-1.9.1.custom.js"></script>
|
||||||
|
<script type="text/javascript" src="/website/static/lib/bootstrap-tour/bootstrap-tour.js"></script>
|
||||||
<!-- mutation observers shim backed by mutation events (8 < IE < 11, Safari < 6, FF < 14, Chrome < 17) -->
|
<!-- mutation observers shim backed by mutation events (8 < IE < 11, Safari < 6, FF < 14, Chrome < 17) -->
|
||||||
<script type="text/javascript" src="/website/static/lib//jquery.mjs.nestedSortable/jquery.mjs.nestedSortable.js"></script>
|
<script type="text/javascript" src="/website/static/lib//jquery.mjs.nestedSortable/jquery.mjs.nestedSortable.js"></script>
|
||||||
<script type="text/javascript" src="/website/static/lib/MutationObservers/test/sidetable.js"></script>
|
<script type="text/javascript" src="/website/static/lib/MutationObservers/test/sidetable.js"></script>
|
||||||
<script type="text/javascript" src='/website/static/lib/nearest/jquery.nearest.js'></script>
|
<script type="text/javascript" src='/website/static/lib/nearest/jquery.nearest.js'></script>
|
||||||
<script type="text/javascript" src="/website/static/lib/MutationObservers/MutationObserver.js"></script>
|
<script type="text/javascript" src="/website/static/lib/MutationObservers/MutationObserver.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="/website/static/lib/jquery.placeholder/jquery.placeholder.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="/website/static/src/js/website.editor.js"></script>
|
<script type="text/javascript" src="/website/static/src/js/website.editor.js"></script>
|
||||||
<script type="text/javascript" src="/website/static/src/js/website.editor.newpage.js" groups="base.group_website_designer"></script>
|
<script type="text/javascript" src="/website/static/src/js/website.editor.newpage.js" groups="base.group_website_designer"></script>
|
||||||
<script type="text/javascript" src="/website/static/src/js/website.menu.js" groups="base.group_website_designer"></script>
|
<script type="text/javascript" src="/website/static/src/js/website.menu.js" groups="base.group_website_designer"></script>
|
||||||
|
|
Loading…
Reference in New Issue