如何使用过滤后的 id 过滤树视图?

How to filter the tree view with the filtered ids?

我创建了一个包含两个字段 od_document_typeod_employee 的向导,然后我使用这些字段过滤了一个自定义模型。我在 document_datas 中得到过滤后的 ids。现在我想 return 自定义模型的树视图与这些过滤 ids

Code

# -*- coding: utf-8 -*-

from odoo import api, fields, models, _

class OrchidPassportTracking(models.TransientModel):
    _name = "orchid.passport.tracking"

    od_document_type = fields.Many2one('orchid.document.type',string="Document Type")
    od_employee = fields.Many2one('hr.employee',string="Employee")

    def find_status(self):
        domain = []
        if self.od_document_type:
            document_type_domain = ('doc_id','=',self.od_document_type.id)
            domain.append(document_type_domain)
        if self.od_employee:
            employee_domain = ('employee_id','=',self.od_employee.id)
            domain.append(employee_domain)
        document_datas = self.env['orchid.document.expiry'].search(domain)

        return {
            'name':'Passport Tracking',
            'view_type': 'form',
            'view_mode': 'tree,form',
            'res_model': 'orchid.document.expiry',
            'type': 'ir.actions.act_window',
            'action':'action_orchid_document_type',
            'domain':{'id':[('id','in',document_datas.id)]},
        }

我这样试过,但是树视图显示的是全部内容,而不是过滤后的内容 contents.What 怎么办? 在此先感谢..

试试下面的代码,

return {
        'name':'Passport Tracking',
        'view_type': 'form',
        'view_mode': 'tree,form',
        'res_model': 'orchid.document.expiry',
        'type': 'ir.actions.act_window',
        'action':'action_orchid_document_type',
        'domain':[('id','in',document_datas.ids)],
    }