fix(desk): guard owner/modified_by access in update_user_info (#35581)
* fix(desk): guard owner/modified_by access in update_user_info Fixes a regression introduced by #35557 This updates the code to safely check for the presence of those fields using `getattr` before adding them to the uservlist. This preserves the intended upstream behavior while avoiding runtime errors for virtual/single/transient documents. * chore: cache getattr instead of calling it twice * refactor: less code --------- Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
parent
c8e36907ac
commit
2f50f3174f
2 changed files with 5 additions and 3 deletions
|
|
@ -2,9 +2,10 @@
|
|||
# See license.txt
|
||||
|
||||
import frappe
|
||||
from frappe.desk.form.load import getdoc
|
||||
from frappe.tests import IntegrationTestCase
|
||||
|
||||
|
||||
class TestSystemHealthReport(IntegrationTestCase):
|
||||
def test_it_works(self):
|
||||
frappe.get_doc("System Health Report")
|
||||
getdoc("System Health Report", "System Health Report")
|
||||
|
|
|
|||
|
|
@ -481,8 +481,9 @@ def update_user_info(docinfo, doc=None):
|
|||
users = set()
|
||||
|
||||
if doc:
|
||||
users.add(doc.owner)
|
||||
users.add(doc.modified_by)
|
||||
for field in ("owner", "modified_by"):
|
||||
if user := doc.get(field):
|
||||
users.add(user)
|
||||
|
||||
users.update(d.sender for d in docinfo.communications)
|
||||
users.update(d.user for d in docinfo.shared)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue