如何显示计算出的one2many字段Odoo(api v8)

时间:2015-09-10 22:43:00

标签: odoo

我想知道如何在树视图中显示one2many计算字段,我尝试了以下代码但没有结果:

@api.one
def _compute_o2m_field(self):
    related_recordset = self.env["product.product"].search([])
    self.productos = related_recordset

products = fields.One2many(string="products", compute='_compute_o2m_field')

任何想法?, 感谢

1 个答案:

答案 0 :(得分:3)

@api.one
def _compute_o2m_field(self):
    related_recordset = self.env["product.product"].search([])
    self.products = related_recordset.ids

products = fields.One2many('product.product','many2onefieldonproduct',string="products", compute='_compute_o2m_field')