From 1cc51e6bb0bb43a0db11b3ba2005a6adc3ec97f5 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Tue, 14 Feb 2023 12:24:31 +0530 Subject: [PATCH] fix: Wait for user creation before creating contact (#20022) closes https://github.com/frappe/frappe/issues/19995 --- frappe/core/doctype/user/user.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frappe/core/doctype/user/user.py b/frappe/core/doctype/user/user.py index a7e5cf7669..e04e43051f 100644 --- a/frappe/core/doctype/user/user.py +++ b/frappe/core/doctype/user/user.py @@ -122,11 +122,20 @@ class User(Document): now = frappe.flags.in_test or frappe.flags.in_install self.send_password_notification(self.__new_password) frappe.enqueue( - "frappe.core.doctype.user.user.create_contact", user=self, ignore_mandatory=True, now=now + "frappe.core.doctype.user.user.create_contact", + user=self, + ignore_mandatory=True, + now=now, + enqueue_after_commit=True, ) if self.name not in STANDARD_USERS and not self.user_image: - frappe.enqueue("frappe.core.doctype.user.user.update_gravatar", name=self.name, now=now) + frappe.enqueue( + "frappe.core.doctype.user.user.update_gravatar", + name=self.name, + now=now, + enqueue_after_commit=True, + ) # Set user selected timezone if self.time_zone: