fix(minor): circular imports?

This commit is contained in:
Rushabh Mehta 2022-04-18 15:59:38 +05:30
parent d55986d56d
commit fca6c3d305
2 changed files with 5 additions and 2 deletions

View file

@ -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"]

View file

@ -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)