From fca6c3d305fc64458c070eedf1ea49e44dc50e96 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 18 Apr 2022 15:59:38 +0530 Subject: [PATCH] fix(minor): circular imports? --- frappe/cache_manager.py | 1 - frappe/model/naming.py | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frappe/cache_manager.py b/frappe/cache_manager.py index b15f8f2234..01ccc03753 100644 --- a/frappe/cache_manager.py +++ b/frappe/cache_manager.py @@ -5,7 +5,6 @@ import json import frappe from frappe.desk.notifications import clear_notifications, delete_notification_count_for -from frappe.model.document import Document common_default_keys = ["__default", "__global"] diff --git a/frappe/model/naming.py b/frappe/model/naming.py index 9d1079d995..aa502f5a4c 100644 --- a/frappe/model/naming.py +++ b/frappe/model/naming.py @@ -6,7 +6,6 @@ from typing import TYPE_CHECKING, Optional, Union import frappe from frappe import _ -from frappe.database.sequence import get_next_val, set_next_val from frappe.model import log_types from frappe.query_builder import DocType from frappe.utils import cint, cstr, now_datetime @@ -36,6 +35,8 @@ def set_new_name(doc): doc.name = None if is_autoincremented(doc.doctype, meta): + from frappe.database.sequence import get_next_val + doc.name = get_next_val(doc.doctype) return @@ -322,11 +323,14 @@ def get_default_naming_series(doctype): def validate_name(doctype: str, name: Union[int, str], case: Optional[str] = None): + if not name: frappe.throw(_("No Name Specified for {0}").format(doctype)) if isinstance(name, int): if is_autoincremented(doctype): + from frappe.database.sequence import set_next_val + # this will set the sequence val to be the provided name and set it to be used # so that the sequence will start from the next val of the setted val(name) set_next_val(doctype, name, is_val_used=True)