我正在尝试创建一个简化搜索的向导。我已经创建了报告和xml,它工作正常。然而,当我尝试进行搜索时,它会带来所有月份的所有工资单,而不是我选择的月份。因此,我试图使用向导来过滤我的搜索。这已经解决了我的问题。
我的向导代码是
import time
from datetime import datetime
from dateutil import relativedelta
from openerp.osv import fields, osv
class ReportWizard(osv.osv_memory):
_name = 'bluspiral.sche.schedule'
# _inherit = 'account.invoice'
_description = 'Cash Payroll Schedule'
_columns = {
'date_from': fields.date('Date From', required=True),
'date_to': fields.date('Date To', required=True),
}
_defaults = {
'date_from': lambda *a: time.strftime('%Y-%m-01'),
'date_to': lambda *a: str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10],
}
def print_payroll_schedule_report(self, cr, uid, ids, context=None):
datas = {}
if context is None:
context = {}
data = self.read(cr, uid, ids,['date_from', 'date_to'], context=context)
date_from = data[0]['date_from']
date_to = data[0]['date_to']
obj = self.pool['hr.payslip']
ids = obj.search(cr, uid, [('date_from','>=',date_from), ('date_from','<=',date_to)])
datas = {
'ids': ids,
'model': 'bluspiral.sche.schedule.template',
'form': data
}
return self.pool['report'].get_action(
cr, uid, [], 'bluspiral_sche.cash_report', data=datas, context=context
)
我一直得到的错误是:
Traceback (most recent call last):
File "/opt/openerp-8.0/openerp/addons/report/controllers/main.py", line 125, in report_download
response = self.report_routes(reportname, converter='pdf', **dict(data))
File "/opt/openerp-8.0/openerp/http.py", line 396, in response_wrap
response = f(*args, **kw)
File "/opt/openerp-8.0/openerp/addons/report/controllers/main.py", line 65, in report_routes
pdf = report_obj.get_pdf(cr, uid, docids, reportname, data=options_data, context=context)
File "/opt/openerp-8.0/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/openerp-8.0/openerp/addons/report/models/report.py", line 190, in get_pdf
html = self.get_html(cr, uid, ids, report_name, data=data, context=context)
File "/opt/openerp-8.0/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/openerp-8.0/openerp/addons/report/models/report.py", line 165, in get_html
return particularreport_obj.render_html(cr, uid, ids, data=data, context=context)
File "/opt/openerp-8.0/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/openerp-8.0/openerp/addons/report/models/abstract_report.py", line 35, in render_html
if data and data.get('form', {}).get('landscape'):
AttributeError: 'list' object has no attribute 'get'
有什么想法吗?