Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ addon | version | maintainers | summary
[base_user_empty_password](base_user_empty_password/) | 18.0.1.0.0 | <a href='https://github.com/grindtildeath'><img src='https://github.com/grindtildeath.png' width='32' height='32' style='border-radius:50%;' alt='grindtildeath'/></a> | Allows to empty password of users
[base_user_show_email](base_user_show_email/) | 18.0.1.0.0 | | Untangle user login and email
[cross_connect_client](cross_connect_client/) | 18.0.1.0.0 | <a href='https://github.com/paradoxxxzero'><img src='https://github.com/paradoxxxzero.png' width='32' height='32' style='border-radius:50%;' alt='paradoxxxzero'/></a> | Cross Connect Client allows to connect to a Cross Connect Server enabled odoo instance.
[impersonate_login](impersonate_login/) | 18.0.1.1.0 | <a href='https://github.com/Kev-Roche'><img src='https://github.com/Kev-Roche.png' width='32' height='32' style='border-radius:50%;' alt='Kev-Roche'/></a> | tools
[impersonate_login](impersonate_login/) | 18.0.1.1.1 | <a href='https://github.com/Kev-Roche'><img src='https://github.com/Kev-Roche.png' width='32' height='32' style='border-radius:50%;' alt='Kev-Roche'/></a> | tools
[password_security](password_security/) | 18.0.1.0.0 | | Allow admin to set password security requirements.
[user_log_view](user_log_view/) | 18.0.1.0.0 | <a href='https://github.com/trojikman'><img src='https://github.com/trojikman.png' width='32' height='32' style='border-radius:50%;' alt='trojikman'/></a> | Allow to see user's actions log
[users_ldap_mail](users_ldap_mail/) | 18.0.1.0.0 | <a href='https://github.com/joao-p-marques'><img src='https://github.com/joao-p-marques.png' width='32' height='32' style='border-radius:50%;' alt='joao-p-marques'/></a> | LDAP mapping for user name and e-mail
[vault](vault/) | 18.0.1.0.2 | | Password vault integration in Odoo
[vault](vault/) | 18.0.1.0.3 | | Password vault integration in Odoo
[vault_share](vault_share/) | 18.0.1.0.0 | | Implementation of a mechanism to share secrets

[//]: # (end addons)
Expand Down
2 changes: 1 addition & 1 deletion impersonate_login/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Impersonate Login
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0f4564be316d51d716922597d0fbfc4ba6ee6b58b19243f17fc445dd6d9d3a4c
!! source digest: sha256:7a065218446f1a1c3d7c8df01e153960f15c80d7fc12534272a2e700896ca757
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion impersonate_login/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Impersonate Login",
"summary": "tools",
"version": "18.0.1.1.0",
"version": "18.0.1.1.1",
"category": "Tools",
"website": "https://github.com/OCA/server-auth",
"author": "Akretion, Odoo Community Association (OCA)",
Expand Down
11 changes: 11 additions & 0 deletions impersonate_login/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
class BaseModel(models.AbstractModel):
_inherit = "base"

def _keep_real_user_on_create_write(self):
# Avoid overriding the create_uid and write_uid
# when the model is abstract or transient
if self._abstract or self._transient:
return True
return False

def _prepare_create_values(self, vals_list):
result_vals_list = super()._prepare_create_values(vals_list)
if self._keep_real_user_on_create_write():
return result_vals_list
if (
request
and request.session.impersonate_from_uid
Expand All @@ -23,6 +32,8 @@ def _prepare_create_values(self, vals_list):
def write(self, vals):
"""Overwrite the write_uid with the impersonating user"""
res = super().write(vals)
if self._keep_real_user_on_create_write():
return res
if (
request
and request.session.impersonate_from_uid
Expand Down
2 changes: 1 addition & 1 deletion impersonate_login/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Impersonate Login</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0f4564be316d51d716922597d0fbfc4ba6ee6b58b19243f17fc445dd6d9d3a4c
!! source digest: sha256:7a065218446f1a1c3d7c8df01e153960f15c80d7fc12534272a2e700896ca757
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-auth/tree/18.0/impersonate_login"><img alt="OCA/server-auth" src="https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-auth-18-0/server-auth-18-0-impersonate_login"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-auth&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows one user (for example, a member of the support team)
Expand Down
39 changes: 39 additions & 0 deletions impersonate_login/tests/test_impersonate_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,42 @@ def test_04_write_uid(self):
self.assertEqual(contact.id, contact_id)
self.assertEqual(contact.ref, "abc")
self.assertEqual(contact.write_uid, self.admin_user)

def test_05_create_uid_on_transient_model(self):
"""Check the create_uid of records created
during an impersonated session on a transient model"""
# Login as admin
self.authenticate(user="admin", password="admin")

# Impersonate demo user and create a wizard record
self._impersonate_user(self.demo_user)

response = self.url_open(
"/web/dataset/call_kw/mail.wizard.invite/web_save",
data=json.dumps(
{
"params": {
"model": "mail.wizard.invite",
"method": "web_save",
"args": [
[],
{
"res_model": "res.partner",
"message": "Hello",
},
{},
],
"kwargs": {},
},
}
),
headers={"Content-Type": "application/json"},
)
self.assertEqual(response.status_code, 200)
data = response.json()
result = data["result"]
settings_id = result[0]["id"]

wizard = self.env["mail.wizard.invite"].browse(settings_id)
self.assertIn("Hello", wizard.message)
self.assertEqual(wizard.create_uid, self.demo_user)
2 changes: 1 addition & 1 deletion vault/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Vault
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9925e324c4689cb3c4bcb95fbe72d46f826b24e2ab8f40c32bab64f54dba6add
!! source digest: sha256:d2ac6b5a6aab5ac42269b57d89806d4068afd1fe128098f2315b2f04ee86cf43
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion vault/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Vault",
"summary": "Password vault integration in Odoo",
"license": "AGPL-3",
"version": "18.0.1.0.2",
"version": "18.0.1.0.3",
"website": "https://github.com/OCA/server-auth",
"application": True,
"author": "initOS GmbH, Odoo Community Association (OCA)",
Expand Down
Loading
Loading