Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Filter context in search view

By
Koffi KPONOUGLO
on 8/26/14, 11:01 AM 1,511 views

Hi everybody,

I am creating a filter avec the context based on the many2one field but I get an error.

More details : I would like to get a list of task works and group them by task_id and project_id.

  • So I created a menu item and search view based on project.task.work model.
  • This model has task_id field so I created the filter based on it and everything is going correctly
  • But the object doesn't have project_id field so when I try do write a filter base on project_id like this:

 <filter string="Project" name="project" icon="terp-folder-violet" context="{'group_by':'task_id._project_id'}"/>

I get this error :

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

Any help?

thanks

1

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 8/27/14, 5:29 AM

The error message explains the problem explicitly, i.e. the field you want to use for groupby (task_id.project_id) is not stored in project.task.work model.  If the requirement is to group by Project, then you need to do:

  1. Create a related field in project.task.work to hold the project_id of task_id and make it stored (e.g 'project_id' : fields.related('task_id', 'project_id', type='many2one', relation='project.project', store=True)
  2. After restarting and upgrading to initiate the new field, use that field instead in the groupby context.

Hi Jonh, I did it like you said. It is working correctly. Thanks

Koffi KPONOUGLO
on 8/27/14, 7:48 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/26/14, 11:01 AM
Seen: 1511 times
Last updated: 3/16/15, 8:10 AM