0
傳遞上下文域在模型在Odoo 9
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)]" />
什麼是工作,正確選擇批次過濾器所有主題。 科目和主題之間Stucked,我認爲這是一個上下文或域的問題,我測試過手動更改域,像這樣:
<field name="topic_ids"
domain="[('subject_id', 'in', '[1, 2]')]"
context="{'topic_ids': topic_ids}" />
併成功獲取主題列表。我想我錯了傳遞上下文或獲取域名。幫幫我。
在此先感謝。