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

fix(Employee): set user image and validate user id only if user data is found #29452

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

ruchamahabal
Copy link
Member

@ruchamahabal ruchamahabal commented Jan 25, 2022

Setting user image in employee and validating user details fails if a stale/non-existent user id is linked to employee master

Traceback (most recent call last):
  File "apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 287, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 309, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 240, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 971, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 868, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1161, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1144, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 862, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "apps/erpnext/erpnext/hr/doctype/employee/employee.py", line 57, in validate
    self.validate_user_details()
  File "apps/erpnext/erpnext/hr/doctype/employee/employee.py", line 73, in validate_user_details
    if data.get("user_image") and self.image == '':
AttributeError: 'NoneType' object has no attribute 'get'

Already fixed for develop in #29024
Not adding tests; Its a defensive fix

@ruchamahabal ruchamahabal merged commit 177a209 into frappe:version-13-hotfix Jan 25, 2022
@ruchamahabal ruchamahabal deleted the fix-user-update branch January 25, 2022 11:19
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant