2016-09-09 21 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

我很高兴这为你解决。 –

相关问题