2016-09-28 100 views
0

在CRM模块,我想设置过滤器来GROUP_BY领域many2many,但我已经收到此错误:在树视图Odoo 8中通过many2many字段过滤组?

AssertionError: Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True

领域是“categ_ids” 此代码PY和xml:

'write_date': fields.datetime('Update Date', readonly=True), 
'categ_ids': fields.many2many('crm.case.categ', 'crm_lead_category_rel', 'lead_id', 'category_id', 'Tags', \ 
    domain="['|', ('section_id', '=', section_id), ('section_id', '=', False), ('object_id.model', '=', 'crm.lead')]", help="Classify and analyze your lead/opportunity categories like: Training, Service"), 
'contact_name': fields.char('Contact Name', size=64), 

FOR XML:

谢谢提前

回答

1

该字段categ_ids是一个相关领域(many2many)。错误是说你不能使用一个相关的字段作为一个功能组。

+0

然后无法对此字段执行group_by –

+0

您需要group_by模型中数据库中保存的字段。您可以使用计算字段并使用store = True,但是如果您的数据在您的相关模型上发生变化,您将需要一个函数来保持计算字段的当前值。 –

+0

你举个例子吗 –