在模型中
batch_id = fields.Many2one('ae.batch', 'Batch')
subject_ids = fields.Many2many('ae.subject', string="Subjects")
topic_ids = fields.Many2many('ae.topic', string="Topics")
subtopic_ids = fields.Many2many('ae.subtopic', string="Subtopics")
目标是传递上下文以过滤(域),选择批量过滤器主题,选择主题,可以是一个或多个,过滤主题,以及过滤子主题。
批量(Many2one)到主题(Many2many) 主题(Many2many)到主题(Many2many) 主题(Many2many)到主题(Many2many)
检查视图:
<group col="4" name="plan_detail" String='Choose t'>
<field name="batch_id"
context="{'batch_id':batch_id}"/>
<field name="subject_ids"
domain="[('batch_id', '=', batch_id)]"
context="{'subject_ids': subject_ids}"/>
<field name="topic_ids"
domain="[('subject_id', 'in', 'subject_ids')]"
context="{'topic_ids': topic_ids}" />
<field name="subtopic_ids" widget="many2many_checkboxes"
domain="[('topic_id', 'in', topic_ids)]" />
工作正常,选择批量过滤所有主题。 被困在主题和主题之间,我认为是一个上下文或域名问题,我已经测试过如下手动更改域名:
<field name="topic_ids"
domain="[('subject_id', 'in', '[1, 2]')]"
context="{'topic_ids': topic_ids}" />
成功获取主题列表。我想我错误地传递上下文或获取域名。帮助
提前致谢。
答案 0 :(得分:1)
在您的代码中,在域中,您提到的字段subject_id位于引号之间。由于它代表一个字段,删除引号并执行。
试试这个
<field name="topic_ids" domain="[('subject_id', 'in', subject_ids)]"
context="{'topic_ids': topic_ids}" />