我正在做这个项目,现在我被困在这个项目上一段时间了。我创建了一个树状视图,并试图通过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}$提前谢谢。在
您必须使用One2many字段在树视图中显示多个记录。在
相关问题 更多 >
编程相关推荐