【发布时间】:2018-10-16 07:04:17
【问题描述】:
我想通过点击网站上的打印按钮来打印报告。
但它显示了一些错误:
文件“/home/priya/workspace/ODOO11/odoo-11.0/odoo/http.py”,第 829 行,在调度中 r = self._call_function(**self.params) _call_function 中的文件“/home/priya/workspace/ODOO11/odoo-11.0/odoo/http.py”,第 342 行 返回检查调用(self.db,*args,**kwargs) 文件“/home/priya/workspace/ODOO11/odoo-11.0/odoo/service/model.py”,第 97 行,在包装器中 返回 f(dbname, *args, **kwargs) 文件“/home/priya/workspace/ODOO11/odoo-11.0/odoo/http.py”,第335行,在checked_call中 结果 = self.endpoint(*a, **kw) 调用中的文件“/home/priya/workspace/ODOO11/odoo-11.0/odoo/http.py”,第 936 行 返回 self.method(*args, **kw) 文件“/home/priya/workspace/ODOO11/odoo-11.0/odoo/http.py”,第 515 行,在 response_wrap 响应 = f(*args, **kw) 文件“/home/priya/repo/rp-group/rpg_quotation/controllers/web_page.py”,第 1442 行,在 update_quotation res = self.print_quotation_software_report(数据,int(quotation_id)) 文件“/home/priya/repo/rp-group/rpg_quotation/controllers/web_page.py”,第 2699 行,在 print_quotation_software_report pdf = request.env.ref('rpg_quotation.rpg_quotation_software_setwise__report').report_action(self, data=data, config=False) 文件“/home/priya/workspace/ODOO11/odoo-11.0/odoo/addons/base/ir/ir_actions_report.py”,第 703 行,在 report_action context = dict(self.env.context, active_ids=active_ids)
UnboundLocalError: local variable 'active_ids' referenced before assignment
我的js代码:
$(document).on('click', Quotation.elements.print_quotation_software_selector, function() {
var self = $(this);
var data = {
'xpath': null,
'cmd': 'print_quotation_software_report'
};
Quotation.methods.xhr(data, function(r) {
});
});
我的 Python 代码:
def print_quotation_software_report(self,data,quotation_id):
order_id = quotation_id
if quotation_id:
pdf = request.env.ref('rpg_quotation.rpg_quotation_software_setwise__report').report_action(self, data=data, config=False)
pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', len(pdf))]
return request.make_response(pdf, headers=pdfhttpheaders)
这里,
rpg_quotation 是模块名称,rpg_quotation_software_setwise__report 是报告 ID。
【问题讨论】:
标签: odoo-11