Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16.0-operating_unit: All OU addes to res users when groups_id change. #628

Closed
jado95 opened this issue Oct 16, 2023 · 1 comment
Closed
Labels
bug stale PR/Issue without recent activity, it'll be soon closed automatically.

Comments

@jado95
Copy link
Contributor

jado95 commented Oct 16, 2023

All operating units added to res.user when edit any group.
PR: #629

Module

operating_unit

Describe the bug

Odoo v16, multicompany database.
On user form, when change group for that user, all operating unit are automatically added to field operating_unit_ids (Allowed Operating Units).
I debug this code:

@api.depends("groups_id", "assigned_operating_unit_ids")
    def _compute_operating_unit_ids(self):
        for user in self:
            if user.has_group("operating_unit.group_manager_operating_unit"):
                dom = []
                if self.env.context.get("allowed_company_ids"):
                    dom = [
                        "|",
                        ("company_id", "=", False),
                        ("company_id", "in", self.env.context["allowed_company_ids"]),
                    ]
                else:
                    dom = []
                user.operating_unit_ids = self.env["operating.unit"].sudo().search(dom)
            else:
                user.operating_unit_ids = user.assigned_operating_unit_ids

And user = res.users(,).
With this result, has_group("operating_unit.group_manager_operating_unit") always return True.
I don't know why the result of user is this, but with user._origin.has_group("operating_unit.group_manager_operating_unit") everything seems to work.
Anyone encountering the same problem?

Copy link

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

No branches or pull requests

2 participants