首页 > 解决方案 > 如何根据批号Odoo10按One2many字段记录分组?

问题描述

我正在使用 Odoo10 并希望根据批号对 One2many 字段记录进行分组/过滤。我尝试了不同的解决方案,但没有得到预期的结果。那么,任何人都可以建议我解决这个问题吗?

如果我们想根据相同的产品名称在销售订单中按销售订单行分组,这也是同样的问题。

我试过下面的代码:

<field name="weight_cal_machine" mode="tree,form" colspan="4" nolabel="1" widget="one2many_list" context="{'group_by':'batch_number'}">
    <tree editable="bottom" delete="false"
          colors="blue:status_type == 'assign'; darkgreen:status_type == 'verify';"
          create="false">
        <field name="batch_number" readonly="1" string="Batch"/>
        <field name="status_type"/>
    </tree>
    <form>
        <group colspan="4" col="4">
            <field name="batch_number" readonly="1"/>
        </group>
    </form>
</field>

标签: filtergroup-byodooone2many

解决方案


AFAIK 没有办法让 One2many 或 Many2many 字段像不属于表单字段的常规树视图那样分组。我很久以前就实现了 Odoo 是 OpenERP 7.0 的时候,但需要大量的 js 小部件定制才能让它工作。这是客户的要求。开箱即用的 Odoo 表单小部件不支持它


推荐阅读