[FW][FIX] knowledge: archive children with current user

Surprisingly ``_filter_access_rules_python`` returns a sudo-ed recordset. We
do not want to call super in a write as sudo, even if the recordset has been
filtered based on current user's ACLs.

In this commit we reset the recordset environment to the current user's one.

Task-2859616

X-original-commit: odoo/odoo@a41d4b9ce1
Part-of: odoo/odoo#95471
Co-authored-by: Aurélien Warnon <awa@odoo.com>
This commit is contained in:
Thibault Delavallée
2022-07-07 17:31:03 +02:00
co-authored by Aurélien Warnon
parent 1a84e7293b
commit 32dd65d059
+3 -1
View File
@@ -661,7 +661,9 @@ class Article(models.Model):
* unreachable descendants (none, read) are set as free articles without
root;
"""
writable_descendants = self._detach_unwritable_descendants()
# _detach_unwritable_descendants calls _filter_access_rules_python which returns
# a sudo-ed recordset
writable_descendants = self._detach_unwritable_descendants().with_env(self.env)
return super(Article, self + writable_descendants).action_archive()
# ------------------------------------------------------------