[16.0] web_domain_field problem with standard project.task read_group

Open
#3,111 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

The issue identifies web_domain_field and the overridden project.task read_group as the relevant entry points. Read the domain serialization and read_group handling, then reproduce by grouping a tree view using a field with the dynamic true domain (1, '=', 1). Done means grouping works without treating 1 as a field name; the issue does not name a test file.

Written by the indexing model from the issue text.

Description

bug

Module

Web Domain Field - web_domain_field

Describe the bug

Odoo standard project task has read_group overridden and loops on domains. When we create a true domain (1, '=', 1) with web_domain_field it is created as [1, '=', 1], so it's not recognised as true leaf by odoo osv, causing this overridden read_group to try splitting "1" like a field name.

To Reproduce

16.0:

Steps to reproduce the behavior:

  1. Use a dynamic domain on a project.task field.
  2. Add that field into a tree view.
  3. Try to group by.

Expected behavior
Right now I cannot see a proper solution for this other than overridding the read_group on project.task like this:

@api.model
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
    fields_list = ([f.split(':')[0] for f in fields] or [])
    if groupby:
        fields_groupby = [groupby] if isinstance(groupby, str) else groupby
        # only take field name when having ':' e.g 'date_deadline:week' => 'date_deadline'
        fields_list += [f.split(':')[0] for f in fields_groupby]
    if domain:
        for term in domain:
            if isinstance(term, (tuple, list)) and term not in [expression.TRUE_LEAF, expression.FALSE_LEAF, [1, '=', 1]]:
                fields_list += [term[0].split('.')[0]]
    self._ensure_fields_are_accessible(fields_list)
    return super(models.Model, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)

Watch how [1, '=', 1] is excluded for parsing and then the models.Model super read_group is called.

Dominant language
JavaScript
Stars
1.2k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
30

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OCA/web

All issues in OCA/web

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.