2016-09-09 66 views

回答

2

您可以使用一個計算字段。

def _get_category(self): 
    if not self.category_id or not self.category_id.parent_id: 
     self.category_parent_id = False 
    else: 
     self.category_parent_id = self.category_id.parent_id.id or False 

category_parent_id = fields.Many2one('product.category',compute=_get_category) 

現在,您可以直接在窗體視圖中使用category_parent_id。

+0

非常感謝您的指導。 – Paramita

+0

我很高興這爲你解決。 –

相關問題