Odoo 8树状图仅显示一条记录

2024-04-29 19:49:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做这个项目,现在我被困在这个项目上一段时间了。我创建了一个树状视图,并试图通过compute字段填充视图中的所有值(该视图中的每个字段都是compute)。但我只得到所有记录的最后一张记录。我深入研究了我的代码,发现我的逻辑没有问题。如果你能引导我度过难关,那将是一个很大的帮助。我的代码如下:

在product.template.py在

product_location = fields.Char("Location", compute='get_location')

location_role = fields.Char("Role", compute="get_location_role")

product_pick_type = fields.Char("Pick Type", compute='get_product_pick_type')



def get_location(self):

    quant = http.request.env['stock.quant'].get_quant_by_product(self.id)

    for res in quant:

        self.product_location = res.location_id.name

def get_location_role(self):

            quant = self.env['stock.quant'].get_quant_by_product(self.id)

            for res in quant:

                self.location_role = res.location_id.location_role_id.role

 def get_product_pick_type(self):

            quant = self.env['stock.quant'].get_quant_by_product(self.id)

            for res in quant:

                self.product_pick_type = res.location_id.pick_type

产品_模板.xml文件:

^{pr2}$

提前谢谢。在


Tags: self视图idfieldsgetdeftyperes