【问题标题】:Odoo 8 tree view only show one recordOdoo 8 树视图只显示一条记录
【发布时间】:2016-10-20 06:30:24
【问题描述】:

我正在做这个项目,现在我已经坚持了一段时间。我创建了一个树视图,并尝试通过计算字段使用所有值填充视图(此视图中的每个字段都是计算)。但我只得到所有记录的最后一条记录。我深入查看了我的代码,发现我的逻辑没有问题。如果你能指导我完成这将是一个很大的帮助。我的代码如下:

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

product_template.xml 文件:

<field name="product_variant_ids">

    <tree>

        <field name="product_location" />

        <field name="location_role"/>

        <field name="product_pick_type"/>  

    </tree>

</field>

提前致谢。

【问题讨论】:

    标签: python treeview openerp odoo-8 openerp-8


    【解决方案1】:

    您必须使用 One2many 字段在树视图中显示多条记录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-26
      • 1970-01-01
      • 2016-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多