Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
10884 Переглядів

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 !

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
жовт. 22
5660
1
бер. 16
5567
2
бер. 15
7546
0
жовт. 24
1616
0
серп. 24
1453