def autoname(doc, method): uses_naming_series = frappe.db.get_value( 'Healthcare Settings', None, 'templates_use_naming_series', ) if cint(uses_naming_series): key = get_default_naming_series('Lab Test Template') doc.test_code = make_autoname(key, 'Lab Test Template', doc)
def autoname(self): pref = "" if self.type == 'Standard': pref += 'STD' elif self.type == 'Drawing': pref += 'DWG' series = get_default_naming_series(self.doctype) digits = getseries(series, 3) pref += str(digits) chk_digit = fn_check_digit(self, pref) name = pref + str(chk_digit) self.name = name
def create_lead(email_id): """create a lead if it does not exist""" from frappe.model.naming import get_default_naming_series full_name, email_id = parse_addr(email_id) if frappe.db.get_value("Lead", {"email_id": email_id}): return lead = frappe.get_doc({ "doctype": "Lead", "email_id": email_id, "lead_name": full_name or email_id, "status": "Lead", "naming_series": get_default_naming_series("Lead"), "company": frappe.db.get_default("Company"), "source": "Email" }) lead.insert()
def send_naming_series(): today = now_datetime() n = '' naming_series = get_default_naming_series("Planning Master") parts = naming_series.split('.')[:-1] for e in parts: part = '' if e == 'YY': part = today.strftime('%y') elif e == 'MM': part = today.strftime('%m') elif e == 'DD': part = today.strftime("%d") elif e == 'YYYY': part = today.strftime('%Y') elif e == 'FY': part = frappe.defaults.get_user_default("fiscal_year") else: part = e n += part #naming_series = parse_naming_series(naming_series) return n
def create_lead(): args = frappe.form_dict print(args) creator_name = None email = None notes = None phone = None event_type = None if args: creator_name = args.get('person') notes = args.get('message') phone = args.get('phone') email = args.get("email") event_type = args.get("event_type") try: lead = frappe.get_doc({ 'doctype': "Lead", 'lead_name': creator_name, 'email_id': email, 'status': "Lead", 'notes': notes, 'phone': phone, "naming_series": get_default_naming_series("Lead") }) lead.insert(ignore_permissions=True) except Exception as e: print("in Exception:") print(e) return True