【发布时间】:2018-08-29 07:05:32
【问题描述】:
以下代码来自Odoo 10中的export_stockinfo_xls。我想知道context.get('active_ids', [])是什么意思,返回值是什么。为什么我们在那个表达式中使用[]?
@api.multi
def export_xls(self):
context = self._context
datas = {'ids': context.get('active_ids', [])} # what mean this and what return
datas['model'] = 'product.product'
datas['form'] = self.read()[0]
for field in datas['form'].keys():
if isinstance(datas['form'][field], tuple):
datas['form'][field] = datas['form'][field][0]
if context.get('xls_export'):
return {
'type': 'ir.actions.report.xml',
'report_name': 'export_stockinfo_xls.stock_report_xls.xlsx',
'datas': datas,
'name': 'Current Stock'
}
【问题讨论】: