Skip to content

Commit

Permalink
[MIG] base_user_role_company: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BertVGroenendael authored and yankinmax committed Jan 21, 2025
1 parent b30cb06 commit 13aba35
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions base_user_role_company/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ Contributors

- Robin Conjour <rconjour@wesolved.com>

`Dynapps <http://dynapps.eu>`__

- Bert Van Groenendael <bert.vangroenendael@dynapps.eu>

Maintainers
-----------

Expand Down
4 changes: 2 additions & 2 deletions base_user_role_company/models/role.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError


Expand All @@ -26,7 +26,7 @@ def _check_company(self):
and record.company_id not in record.user_id.company_ids
):
raise ValidationError(

Check warning on line 28 in base_user_role_company/models/role.py

View check run for this annotation

Codecov / codecov/patch

base_user_role_company/models/role.py#L28

Added line #L28 was not covered by tests
_(
self.env._(
'User "%(user)s" does not have access to the company '
'"%(company)s"'
)
Expand Down
8 changes: 4 additions & 4 deletions base_user_role_company/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ class ResUsers(models.Model):
_inherit = "res.users"

@classmethod
def authenticate(cls, db, login, password, user_agent_env):
uid = super().authenticate(db, login, password, user_agent_env)
def authenticate(cls, db, credential, user_agent_env):
auth_info = super().authenticate(db, credential, user_agent_env)

Check warning on line 12 in base_user_role_company/models/user.py

View check run for this annotation

Codecov / codecov/patch

base_user_role_company/models/user.py#L12

Added line #L12 was not covered by tests
# On login, ensure the proper roles are applied
# The last Role applied may not be the correct one,
# sonce the new session current company can be different
with cls.pool.cursor() as cr:
env = api.Environment(cr, uid, {})
env = api.Environment(cr, auth_info["uid"], {})

Check warning on line 17 in base_user_role_company/models/user.py

View check run for this annotation

Codecov / codecov/patch

base_user_role_company/models/user.py#L16-L17

Added lines #L16 - L17 were not covered by tests
if env.user.role_line_ids:
env.user.set_groups_from_roles()
return uid
return auth_info

Check warning on line 20 in base_user_role_company/models/user.py

View check run for this annotation

Codecov / codecov/patch

base_user_role_company/models/user.py#L19-L20

Added lines #L19 - L20 were not covered by tests

def _get_enabled_roles(self):
res = super()._get_enabled_roles()
Expand Down
4 changes: 4 additions & 0 deletions base_user_role_company/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
[WeSolved](http://wesolved.com)

> - Robin Conjour \<<rconjour@wesolved.com>\>
[Dynapps](http://dynapps.eu)

> - Bert Van Groenendael \<<bert.vangroenendael@dynapps.eu>\>
6 changes: 6 additions & 0 deletions base_user_role_company/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,12 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Robin Conjour &lt;<a class="reference external" href="mailto:rconjour&#64;wesolved.com">rconjour&#64;wesolved.com</a>&gt;</li>
</ul>
</blockquote>
<p><a class="reference external" href="http://dynapps.eu">Dynapps</a></p>
<blockquote>
<ul class="simple">
<li>Bert Van Groenendael &lt;<a class="reference external" href="mailto:bert.vangroenendael&#64;dynapps.eu">bert.vangroenendael&#64;dynapps.eu</a>&gt;</li>
</ul>
</blockquote>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
Expand Down
2 changes: 1 addition & 1 deletion base_user_role_company/views/role.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
expr="//field[@name='role_line_ids']//field[@name='role_id']"
position="after"
>
<field name="allowed_company_ids" invisible="1" />
<field name="allowed_company_ids" />
<field name="company_id" groups="base.group_multi_company" />
</xpath>
</field>
Expand Down

0 comments on commit 13aba35

Please sign in to comment.