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

[4913][ADD] base_user_role #164

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open

[4913][ADD] base_user_role #164

wants to merge 1 commit into from

Conversation

kanda999
Copy link
Contributor

@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 16.0-add-base_user_role branch from 706f87f to b247ebc Compare October 31, 2024 08:29
@AungKoKoLin1997
Copy link
Contributor

This part cause the tests CI failed.

class AuditLogRuleTestForUserModel(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
# get User model id
cls.user_model_id = cls.env["ir.model"].search([("model", "=", "res.users")]).id
# creating auditlog.rule
cls.auditlog_rule = (
cls.env["auditlog.rule"]
.with_context(tracking_disable=True)
.create(
{
"name": "testrule 01",
"model_id": cls.user_model_id,
"log_read": True,
"log_create": True,
"log_write": True,
"log_unlink": True,
"log_type": "full",
"capture_record": True,
}
)
)
# Subscribe auditlog.rule
cls.auditlog_rule.subscribe()
# Create user id
cls.user = (
cls.env["res.users"]
.with_context(no_reset_password=True, tracking_disable=True)
.create(
{
"name": "Test User",
"login": "testuser",
}
)
)
cls.group = cls.env.ref("auditlog.group_auditlog_manager")
cls.auditlog_log = cls.env["auditlog.log"]
def test_01_AuditlogFull_field_group_write_log(self):
"""Change group and check successfully created log"""
self.user.with_context(tracking_disable=True).write(
{"groups_id": [(4, self.group.id)]}
)
# Checking log is created for testpartner1
write_log_record = self.auditlog_log.search(
[
("model_id", "=", self.auditlog_rule.model_id.id),
("method", "=", "write"),
("res_id", "=", self.user.id),
]
).ensure_one()
self.assertTrue(write_log_record)
def test_02_AuditlogFull_field_group_write_log(self):
"""Change group and check successfully created log, but using reified fields"""
fname = name_boolean_group(self.group.id)
self.user.with_context(tracking_disable=True).write(
{
fname: True,
}
)
# Checking log is created for testpartner1
write_log_record = self.auditlog_log.search(
[
("model_id", "=", self.auditlog_rule.model_id.id),
("method", "=", "write"),
("res_id", "=", self.user.id),
]
).ensure_one()
self.assertTrue(write_log_record)

This is the reason of the issue and I am finding the way to fix.
cls.auditlog_rule.subscribe()

@AungKoKoLin1997
Copy link
Contributor

I'm going to fix the CI issue.

@AungKoKoLin1997
Copy link
Contributor

I checked the root cause and I found the calling write() from test cases of base_user_role is not executed from extend write() method of base_user_role and just directly calls to write() of base module if we use together with auditlog.
I think the monkey patching of auditlog is causing this behavior but it is called when we update the value from UI.

model_model._patch_method("write", rule._make_write())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants