我正在尝试根据活跃用户显示记录, 我的task_submission.py
class TaskSubmission(models.Model):
_name = 'training_program_management.task_submission'
solution_description = fields.Html(string="Task submission's Description", required=True)
partner_id = fields.Many2one('res.partner', string='trainee: ',
default=lambda self: self.env.user.partner_id.id, readonly=True)
task_id = fields.Many2one('project.task', readonly=True, string="submitting Task :")
project_id = fields.Many2one(related="task_id.project_id", string="Practical work ", readonly=True)
在TreeView中,我只需要显示任务提交 Partner_id = current_user_id.partner_id 我试过这个,但它似乎没有起作用:
<record model="ir.actions.server" id="mysub_task_action">
<field name="name">My Task submissions</field>
<field name='model_id' ref='training_program_management.task_submission'/>
<field name="state">code</field>
<field name="code">
action = {
'type': 'ir.actions.act_window',
'name': 'My task submissions',
'view_mode': 'tree',
'view_type': 'tree',
'view_id': env.ref("training_program_management.mysub_task_tree_view").id,
'context': '{ "tree_view_ref":"mysub_task_tree_view"}',
'res_model': 'training_program_management.task_submission',
'views': [(env.ref('training_program_management.mysub_task_tree_view').id, 'tree')],
'domain' : '[("partner_id", "=","user.id.id_partner.id")]',
}
</field>
</record>
答案 0 :(得分:1)
它不起作用,因为您不能在域中使用user.id.id_partner.id
周围的引号:user
实际上是您可以在域中使用的python对象。
'domain' : '[("partner_id", "=", user.partner_id.id)]',
应该工作。