回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在编写一个方法,它首先将从模型中检索当前上下文,然后使用context.update()为上下文添加新值。我还尝试使用当前的方法self.with_context(),但仍然没有成功,因为上下文值似乎已冻结,无法传入。我在网上从某个来源读到,有一种方法可以覆盖名称。但消息来源只是简单的引用,不会有明确的指示让我可以遵循。我是奥多的新手,v7和v8之间的问题让我很头疼。请帮助我修改以下源代码:</p>
<blockquote>
<pre><code>def get_print_report(self):
domain = [('effective_date', '>=', self.from_date),
('effective_date', '<=', self.to_date),
('employee_id', 'in', self.employee_ids.ids),
('department_id', '=', self.department_id.id),
('job_id', '=', self.job_id.id)]
list_view = self.env.ref(
'trainingwagekp.payroll_wage_hist_wizard_tree_view')
context = self._context.copy()
if context is None:
context = {}
if context.get('order_by', False):
context.update({'default_order': self.order_by + ' desc'})
self.with_context(context)
print '===============', self._context
return{'name': 'Wage History Report',
'view_type': 'form',
'view_mode': 'tree',
'view_id': list_view.id,
'res_model': 'trobz.payroll.wage.history',
'type': 'ir.actions.act_window',
'context': context,
'domain': domain,
}
</code></pre>
</blockquote>
<p>也请让我知道哪一个是最好的方式来修改奥多8的上下文。谢谢</p>