콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
11077 화면

I'm using odoo8.  I have a Transient Model used in a Dialog Form.

The view has a button:

<button name="summary_report" type="object" string="Invoice Summary"/>

summary_report is defined in the transient model: mil.sales_report

 @api.one
def summary_report(self):
datas = {}
invoices = self.env['account.invoice'].search([
('company_id', '=', self.company_id.id)
])
context = dict({}, active_ids=invoices, active_model='account.invoice')
'''
datas = {
'ids':invoices,
'model':'account.invoice',
#'form':,
'context':self._context
}
'''
return {
'type': 'ir.actions.report.xml',
'report_name': 'mil_sales_report.invoice_summary_template',
'context': context
               }

I am trying to query the account.invoice model and pass the results to report 'mil_sales_report.invoice_summary_template'.
When I press the button widow closes and nothing happens.


아바타
취소
작성자 베스트 답변

It now works.  I changed the code to:

#needed for calling function from wizard, api.one will not work
 @api.multi
#function definition is in odoo v8 format
def summary_report(self):
#ensure that self contains only one record
self.ensure_one()
#get the model to query
invoiceModel = self.env['account.invoice']
#query the model
invoices = invoiceModel.search([
('company_id', '=', self.company_id.id)
])
#set the data
#ids is the list of ids, so have to pass <model>._ids
#model is the model name <model>._name or string literal
#form is the field list, I use <model>.read() to get all fields, read() can have parameter to only read specific fields
datas = {
'ids': invoices._ids,
'model': invoiceModel._name,
'form': invoiceModel.read(),
'context':self._context
}
#call the report
return {
'type': 'ir.actions.report.xml',
'report_name': 'mil_sales_report.invoice_summary_template',
'datas': datas
               }



아바타
취소
베스트 답변

def summary_report(self, cr, uid, ids, data, context=None):

if context is None:

context = {} #yourCode

return self.pool['report'].get_action(cr, uid, [], 'mil_sales_report.invoice_summary_template', data=datas, context=context)

 hope this will help you !

아바타
취소
관련 게시물 답글 화면 활동
1
10월 22
5787
1
3월 16
5747
2
3월 15
7751
0
10월 24
1831
0
8월 24
1630