def execute():
    webnotes.reload_doc("core", "doctype", "doctype")

    tables = webnotes.conn.sql_list("show tables")
    if not "tabMaterial Request Item" in tables:
        webnotes.rename_doc("DocType",
                            "Purchase Request Item",
                            "Material Request Item",
                            force=True)
    if not "tabMaterial Request" in tables:
        webnotes.rename_doc("DocType",
                            "Purchase Request",
                            "Material Request",
                            force=True)

    webnotes.reload_doc("stock", "doctype", "material_request")
    webnotes.reload_doc("stock", "doctype", "material_request_item")

    webnotes.conn.sql(
        """update `tabMaterial Request` set material_request_type='Purchase'"""
    )

    os.system("rm -rf app/buying/doctype/purchase_request")
    os.system("rm -rf app/buying/doctype/purchase_request_item")

    os.system("rm -rf app/hr/doctype/holiday_block_list")
    os.system("rm -rf app/hr/doctype/holiday_block_list_allow")
    os.system("rm -rf app/hr/doctype/holiday_block_list_date")

    for dt in ("Purchase Request", "Purchase Request Item"):
        if webnotes.conn.exists("DocType", dt):
            webnotes.delete_doc("DocType", dt)
Пример #2
0
def rename_doc(doctype, old, new, force=False, merge=False):
	"""
		Renames a doc(dt, old) to doc(dt, new) and 
		updates all linked fields of type "Link" or "Select" with "link:"
	"""
	if not webnotes.conn.exists(doctype, old):
		return
		
	# get doclist of given doctype
	doclist = webnotes.model.doctype.get(doctype)
	
	validate_rename(doctype, new, doclist, merge, force)

	# call on_rename
	obj = webnotes.get_obj(doctype, old)
	if hasattr(obj, 'on_rename'):
		new = obj.on_rename(new, old) or new
		
	if not merge:
		rename_parent_and_child(doctype, old, new, doclist)
			
	# update link fields' values
	link_fields = get_link_fields(doctype)
	update_link_field_values(link_fields, old, new)
	
	if doctype=='DocType':
		rename_doctype(doctype, old, new, force)
	
	if merge:
		webnotes.delete_doc(doctype, old)
		
	return new
def execute():
    doctypes = [
        "Announcement", "Authorization Rules", "Blog Subscriber", "Books",
        "Call Log", "Call Log Details", "Campaign Expense",
        "Communication Log", "Compaint Note", "Company Control", "Competitor",
        "Complaint Detail", "Desktop Item", "DocType Label",
        "Employee Training", "Featured Item", "GL Control", "GL Mapper",
        "GL Mapper Detail", "Holiday Block List", "Holiday Block List Allow",
        "Holiday Block List Date", "Home Control", "Home Settings",
        "Item Parameter", "Item Parameter Value", "Lead Email CC Detail",
        "Manage Account", "Market Segment", "Multi Ledger Report Detail",
        "Naming Series Options", "Navigation Control", "Online Contact",
        "Order Reconciliation", "Order Reconciliation Detail",
        "Other Income Detail", "Partner Target Detail", "Permission Control",
        "Permission Rules", "Print Style", "Product Catalogue Control",
        "Product Group", "Product Settings", "Products Settings",
        "Profile Control", "Project Activity", "Project Activity Update",
        "Project Control", "Project Cost Breakup", "Related Page", "RV Detail",
        "Sales Browser Control", "Sandbox", "Search Criteria", "Series Detail",
        "Shipping Address", "SMS Receiver", "State", "TC Detail",
        "Territory Target Detail", "Timesheet", "Timesheet Detail",
        "Top Bar Settings", "Training Session", "Training Session Details",
        "Transfer Ownership", "Trash Control", "Trend Analyzer Control",
        "Update Delivery Date", "User Setting-Profile",
        "User Setting-Role Permission", "User Setting-Role User",
        "User Settings", "Valuation Control", "Website Product Category",
        "Workflow Action Detail", "Workflow Engine", "Workflow Rule",
        "Workflow Rule Detail"
    ]

    for d in doctypes:
        webnotes.delete_doc("DocType", d)
Пример #4
0
def execute():
	import webnotes
	try:
		for mapper in webnotes.conn.sql("""select name from `tabGL Mapper`"""):
			webnotes.delete_doc("GL Mapper", mapper[0])
	except Exception, e:
		pass
Пример #5
0
def update_cart(item_code, qty, with_doclist=0):
    quotation = _get_cart_quotation()

    qty = flt(qty)
    if qty == 0:
        quotation.set_doclist(quotation.doclist.get({"item_code": ["!=", item_code]}))
        if not quotation.doclist.get({"parentfield": "quotation_details"}) and not quotation.doc.fields.get(
            "__islocal"
        ):
            quotation.__delete = True

    else:
        quotation_items = quotation.doclist.get({"item_code": item_code})
        if not quotation_items:
            quotation.doclist.append(
                {"doctype": "Quotation Item", "parentfield": "quotation_details", "item_code": item_code, "qty": qty}
            )
        else:
            quotation_items[0].qty = qty

    apply_cart_settings(quotation=quotation)

    if hasattr(quotation, "__delete"):
        webnotes.delete_doc("Quotation", quotation.doc.name, ignore_permissions=True)
        quotation = _get_cart_quotation()
    else:
        quotation.ignore_permissions = True
        quotation.save()

    set_cart_count(quotation)

    if with_doclist:
        return get_cart_quotation(quotation.doclist)
    else:
        return quotation.doc.name
Пример #6
0
def cleanup_sitemap():
	"""remove sitemap records where its config do not exist anymore"""
	to_delete = webnotes.conn.sql_list("""select name from `tabWebsite Sitemap` ws
			where not exists(select name from `tabWebsite Sitemap Config` wsc
				where wsc.name=ws.website_sitemap_config)""")
	
	webnotes.delete_doc("Website Sitemap", to_delete, ignore_permissions=True)
Пример #7
0
def rename_module():
    webnotes.reload_doc("core", "doctype", "role")
    webnotes.reload_doc("core", "doctype", "page")
    webnotes.reload_doc("core", "doctype", "module_def")

    if webnotes.conn.exists("Role", "Production User"):
        webnotes.rename_doc("Role", "Production User", "Manufacturing User")
    if webnotes.conn.exists("Role", "Production Manager"):
        webnotes.rename_doc("Role", "Production Manager",
                            "Manufacturing Manager")

    if webnotes.conn.exists("Page", "manufacturing-home"):
        webnotes.delete_doc("Page", "production-home")
    else:
        webnotes.rename_doc("Page", "production-home", "manufacturing-home")

    if webnotes.conn.exists("Module Def", "Production"):
        webnotes.rename_doc("Module Def", "Production", "Manufacturing")

    modules_list = webnotes.conn.get_global('modules_list')
    if modules_list:
        webnotes.conn.set_global(
            "modules_list", modules_list.replace("Production",
                                                 "Manufacturing"))

    # set end of life to null if "0000-00-00"
    webnotes.conn.sql(
        """update `tabItem` set end_of_life=null where end_of_life='0000-00-00'"""
    )
Пример #8
0
def execute():
    import webnotes
    try:
        for mapper in webnotes.conn.sql("""select name from `tabGL Mapper`"""):
            webnotes.delete_doc("GL Mapper", mapper[0])
    except Exception, e:
        pass
Пример #9
0
def execute():
	webnotes.reload_doc("core", "doctype", "doctype")
	
	tables = webnotes.conn.sql_list("show tables")
	if not "tabMaterial Request Item" in tables:
		webnotes.rename_doc("DocType", "Purchase Request Item", "Material Request Item", force=True)
	if not "tabMaterial Request" in tables:
		webnotes.rename_doc("DocType", "Purchase Request", "Material Request", force=True)
	webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_bill")
	webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_receive")

	webnotes.reload_doc("stock", "doctype", "material_request")
	webnotes.reload_doc("stock", "doctype", "material_request_item")
	
	webnotes.conn.sql("""update `tabMaterial Request` set material_request_type='Purchase'""")
	
	os.system("rm -rf app/buying/doctype/purchase_request")
	os.system("rm -rf app/buying/doctype/purchase_request_item")
	
	os.system("rm -rf app/hr/doctype/holiday_block_list")
	os.system("rm -rf app/hr/doctype/holiday_block_list_allow")
	os.system("rm -rf app/hr/doctype/holiday_block_list_date")
	
	for dt in ("Purchase Request", "Purchase Request Item"):
		if webnotes.conn.exists("DocType", dt):
			webnotes.delete_doc("DocType", dt)
def build_website_sitemap_config():
    config = {"pages": {}, "generators": {}}
    basepath = webnotes.utils.get_base_path()

    existing_configs = dict(
        webnotes.conn.sql(
            """select name, lastmod from `tabWebsite Sitemap Config`"""))

    for path, folders, files in os.walk(basepath, followlinks=True):
        for ignore in ('locale', 'public'):
            if ignore in folders:
                folders.remove(ignore)

        if os.path.basename(path) == "pages" and os.path.basename(
                os.path.dirname(path)) == "templates":
            for fname in files:
                fname = webnotes.utils.cstr(fname)
                if fname.split(".")[-1] in ("html", "xml", "js", "css"):
                    name = add_website_sitemap_config("Page", path, fname,
                                                      existing_configs)
                    if name in existing_configs: del existing_configs[name]

        if os.path.basename(path) == "generators" and os.path.basename(
                os.path.dirname(path)) == "templates":
            for fname in files:
                if fname.endswith(".html"):
                    name = add_website_sitemap_config("Generator", path, fname,
                                                      existing_configs)
                    if name in existing_configs: del existing_configs[name]

    for name in existing_configs:
        webnotes.delete_doc("Website Sitemap Config", name)

    webnotes.conn.commit()
def execute():
	for sc in ["itemwise_price_list", "itemwise_receipt_details",
			"shortage_to_purchase_request", "stock_aging_report",
			"stock_ledger", "stock_level", "stock_report",
			"custom_test2", "custom_test3", "custom_test4",
			"test_so2", "test_so3"]:
		webnotes.delete_doc("Search Criteria", sc)
def execute():
    for w in webnotes.conn.sql(
            """select name from `tabWarehouse` where docstatus=2"""):
        try:
            webnotes.delete_doc("Warehouse", w[0])
        except webnotes.ValidationError:
            pass
Пример #13
0
def build_website_sitemap_config():		
	config = {"pages": {}, "generators":{}}
	basepath = webnotes.utils.get_base_path()
	
	existing_configs = dict(webnotes.conn.sql("""select name, lastmod from `tabWebsite Sitemap Config`"""))
		
	for path, folders, files in os.walk(basepath, followlinks=True):
		for ignore in ('locale', 'public'):
			if ignore in folders: 
				folders.remove(ignore)

		if os.path.basename(path)=="pages" and os.path.basename(os.path.dirname(path))=="templates":
			for fname in files:
				fname = webnotes.utils.cstr(fname)
				if fname.split(".")[-1] in ("html", "xml", "js", "css"):
					name = add_website_sitemap_config("Page", path, fname, existing_configs)
					if name in existing_configs: del existing_configs[name]

		if os.path.basename(path)=="generators" and os.path.basename(os.path.dirname(path))=="templates":
			for fname in files:
				if fname.endswith(".html"):
					name = add_website_sitemap_config("Generator", path, fname, existing_configs)
					if name in existing_configs: del existing_configs[name]
					
	for name in existing_configs:
		webnotes.delete_doc("Website Sitemap Config", name)

	webnotes.conn.commit()
def execute():
    webnotes.reload_doc("core", "doctype", "communication")
    webnotes.conn.commit()
    for d in webnotes.conn.sql(
            """select owner, creation, modified, modified_by, parent, 
		from_email, mail from `tabSupport Ticket Response`""",
            as_dict=1):
        c = webnotes.doc("Communication")
        c.creation = d.creation
        c.owner = d.owner
        c.modified = d.modified
        c.modified_by = d.modified_by
        c.naming_series = "COMM-"
        c.subject = "response to Support Ticket: " + d.parent
        c.content = d.mail
        c.email_address = d.from_email
        c.support_ticket = d.parent
        email_addr = email.utils.parseaddr(c.email_address)[1]
        c.contact = webnotes.conn.get_value(
            "Contact", {"email_id": email_addr}, "name") or None
        c.lead = webnotes.conn.get_value("Lead", {"email_id": email_addr},
                                         "name") or None
        c.communication_medium = "Email"
        webnotes.conn.begin()
        c.save(1, keep_timestamps=True)
        webnotes.conn.commit()

    webnotes.delete_doc("DocType", "Support Ticket Response")
Пример #15
0
    def on_trash(self):
        # delete bin
        bins = webnotes.conn.sql("select * from `tabBin` where warehouse = %s",
                                 self.doc.name,
                                 as_dict=1)
        for d in bins:
            if d['actual_qty'] or d['reserved_qty'] or d['ordered_qty'] or \
              d['indented_qty'] or d['projected_qty'] or d['planned_qty']:
                throw(
                    """Warehouse: %s can not be deleted as qty exists for item: %s"""
                    % (self.doc.name, d['item_code']))
            else:
                webnotes.conn.sql("delete from `tabBin` where name = %s",
                                  d['name'])

        warehouse_account = webnotes.conn.get_value(
            "Account", {
                "account_type": "Warehouse",
                "master_name": self.doc.name
            })
        if warehouse_account:
            webnotes.delete_doc("Account", warehouse_account)

        if webnotes.conn.sql(
                """select name from `tabStock Ledger Entry` 
				where warehouse = %s""", self.doc.name):
            throw(
                _("""Warehouse can not be deleted as stock ledger entry 
				exists for this warehouse."""))
Пример #16
0
def make_demo_user():
	if webnotes.conn.exists("Profile", "*****@*****.**"):
		webnotes.delete_doc("Profile", "*****@*****.**")

	p = webnotes.new_bean("Profile")
	p.doc.email = "*****@*****.**"
	p.doc.first_name = "Demo"
	p.doc.last_name = "User"
	p.doc.enabled = 1
	p.doc.user_type = "ERPNext Demo"
	p.doc.send_invite_email = 0
	p.doc.new_password = "******"
	p.insert()
	
	for role in ("Accounts Manager", "Analytics", "Expense Approver", "Accounts User", 
		"Leave Approver", "Blogger", "Customer", "Sales Manager", "Employee", "Support Manager", 
		"HR Manager", "HR User", "Maintenance Manager", "Maintenance User", "Material Manager", 
		"Material Master Manager", "Material User", "Partner", "Manufacturing Manager", 
		"Manufacturing User", "Projects User", "Purchase Manager", "Purchase Master Manager", 
		"Purchase User", "Quality Manager", "Report Manager", "Sales Master Manager", "Sales User", 
		"Supplier", "Support Team"):
		p.doclist.append({
			"doctype": "UserRole",
			"parentfield": "user_roles",
			"role": role
		})

	p.save()
	
	# only read for newsletter
	webnotes.conn.sql("""update `tabDocPerm` set `write`=0, `create`=0, `cancel`=0
		where parent='Newsletter'""")
	
	webnotes.conn.commit()
Пример #17
0
def rename_module():
	webnotes.reload_doc("core", "doctype", "role")
	webnotes.reload_doc("core", "doctype", "page")
	webnotes.reload_doc("core", "doctype", "module_def")

	if webnotes.conn.exists("Role", "Production User"):
		webnotes.rename_doc("Role", "Production User", "Manufacturing User")
	if webnotes.conn.exists("Role", "Production Manager"):
		webnotes.rename_doc("Role", "Production Manager", "Manufacturing Manager")

	if webnotes.conn.exists("Page", "manufacturing-home"):
		webnotes.delete_doc("Page", "production-home")
	else:
		webnotes.rename_doc("Page", "production-home", "manufacturing-home")

	if webnotes.conn.exists("Module Def", "Production"):
		webnotes.rename_doc("Module Def", "Production", "Manufacturing")
	
	modules_list = webnotes.conn.get_global('modules_list')
	if modules_list:
		webnotes.conn.set_global("modules_list", modules_list.replace("Production", 
			"Manufacturing"))
		
	# set end of life to null if "0000-00-00"
	webnotes.conn.sql("""update `tabItem` set end_of_life=null where end_of_life='0000-00-00'""")
def execute():
    webnotes.conn.sql(
        """update tabDocPerm set permlevel=0 where permlevel is null""")
    webnotes.conn.sql(
        """update tabDocPerm set `create`=0, `submit`=0, `cancel`=0,
		`amend`=0, `match`='' where permlevel>0""")
    webnotes.delete_doc("Permission Control")
Пример #19
0
def execute():
	webnotes.reload_doc("utilities", "doctype", "note")
	webnotes.reload_doc("utilities", "doctype", "note_user")
	
	for question in webnotes.conn.sql("""select * from tabQuestion""", as_dict=True):
		if question.question:
			try:
				name = question.question[:180]
				if webnotes.conn.exists("Note", name):
					webnotes.delete_doc("Note", name)

				similar_questions = webnotes.conn.sql_list("""select name from `tabQuestion`
					where question like %s""", "%s%%" % name)
				answers = [markdown2.markdown(c) for c in webnotes.conn.sql_list("""
						select answer from tabAnswer where question in (%s)""" % \
						", ".join(["%s"]*len(similar_questions)), similar_questions)]

				webnotes.bean({
					"doctype":"Note",
					"title": name,
					"content": "<hr>".join(answers),
					"owner": question.owner,
					"creation": question.creation,
					"public": 1
				}).insert()
			
			except NameError:
				pass
			except Exception, e:
				if e.args[0] != 1062:
					raise
Пример #20
0
def execute():
    base_path = webnotes.utils.get_base_path()

    # Remove symlinks from public folder:
    # 	- server.py
    # 	- web.py
    # 	- unsupported.html
    # 	- blank.html
    # 	- rss.xml
    # 	- sitemap.xml
    for file in ("server.py", "web.py", "unsupported.html", "blank.html",
                 "rss.xml", "sitemap.xml"):
        file_path = os.path.join(base_path, "public", file)
        if os.path.exists(file_path):
            os.remove(file_path)

    # Remove wn-web files
    # 	- js/wn-web.js
    # 	- css/wn-web.css
    for file_path in (("js", "wn-web.js"), ("css", "wn-web.css")):
        file_path = os.path.join(base_path, "public", *file_path)
        if os.path.exists(file_path):
            os.remove(file_path)

    # Remove update app page
    webnotes.delete_doc("Page", "update-manager")
Пример #21
0
def execute():
	base_path = webnotes.utils.get_base_path()
	
	# Remove symlinks from public folder:
	# 	- server.py
	# 	- web.py
	# 	- unsupported.html
	# 	- blank.html
	# 	- rss.xml
	# 	- sitemap.xml
	for file in ("server.py", "web.py", "unsupported.html", "blank.html", "rss.xml", "sitemap.xml"):
		file_path = os.path.join(base_path, "public", file)
		if os.path.exists(file_path):
			os.remove(file_path)
			
	# Remove wn-web files
	# 	- js/wn-web.js
	# 	- css/wn-web.css
	for file_path in (("js", "wn-web.js"), ("css", "wn-web.css")):
		file_path = os.path.join(base_path, "public", *file_path)
		if os.path.exists(file_path):
			os.remove(file_path)
			
	# Remove update app page
	webnotes.delete_doc("Page", "update-manager")
Пример #22
0
def rename_doc(doctype, old, new, force=False, merge=False):
    """
		Renames a doc(dt, old) to doc(dt, new) and 
		updates all linked fields of type "Link" or "Select" with "link:"
	"""
    if not webnotes.conn.exists(doctype, old):
        return

    # get doclist of given doctype
    doclist = webnotes.model.doctype.get(doctype)

    validate_rename(doctype, new, doclist, merge, force)

    # call on_rename
    obj = webnotes.get_obj(doctype, old)
    if hasattr(obj, 'on_rename'):
        new = obj.on_rename(new, old) or new

    if not merge:
        rename_parent_and_child(doctype, old, new, doclist)

    # update link fields' values
    link_fields = get_link_fields(doctype)
    update_link_field_values(link_fields, old, new)

    if doctype == 'DocType':
        rename_doctype(doctype, old, new, force)

    if merge:
        webnotes.delete_doc(doctype, old)

    return new
Пример #23
0
def import_doclist(doclist):
	doctype = doclist[0]["doctype"]
	name = doclist[0]["name"]
	old_doc = None
	
	doctypes = set([d["doctype"] for d in doclist])
	ignore = list(doctypes.intersection(set(ignore_doctypes)))
	
	if doctype in ignore_values:
		if webnotes.conn.exists(doctype, name):
			old_doc = webnotes.doc(doctype, name)

	# delete old
	webnotes.delete_doc(doctype, name, force=1, ignore_doctypes=ignore, for_reload=True)
	
	# don't overwrite ignored docs
	doclist1 = remove_ignored_docs_if_they_already_exist(doclist, ignore, name)

	# update old values (if not to be overwritten)
	if doctype in ignore_values and old_doc:
		update_original_values(doclist1, doctype, old_doc)
	
	# reload_new
	new_bean = webnotes.bean(doclist1)
	new_bean.ignore_children_type = ignore
	new_bean.ignore_links = True
	new_bean.ignore_validate = True
	new_bean.ignore_permissions = True
	new_bean.ignore_mandatory = True
	
	if doctype=="DocType" and name in ["DocField", "DocType"]:
		new_bean.ignore_fields = True
	
	new_bean.insert()
Пример #24
0
    def on_trash(self):
        # delete bin
        bins = webnotes.conn.sql("select * from `tabBin` where warehouse = %s", self.doc.name, as_dict=1)
        for d in bins:
            if (
                d["actual_qty"]
                or d["reserved_qty"]
                or d["ordered_qty"]
                or d["indented_qty"]
                or d["projected_qty"]
                or d["planned_qty"]
            ):
                msgprint(
                    """Warehouse: %s can not be deleted as qty exists for item: %s""" % (self.doc.name, d["item_code"]),
                    raise_exception=1,
                )
            else:
                webnotes.conn.sql("delete from `tabBin` where name = %s", d["name"])

        warehouse_account = webnotes.conn.get_value(
            "Account", {"account_type": "Warehouse", "master_name": self.doc.name}
        )
        if warehouse_account:
            webnotes.delete_doc("Account", warehouse_account)

        if webnotes.conn.sql(
            """select name from `tabStock Ledger Entry` 
				where warehouse = %s""",
            self.doc.name,
        ):
            msgprint(
                """Warehouse can not be deleted as stock ledger entry 
				exists for this warehouse.""",
                raise_exception=1,
            )
Пример #25
0
def execute():
    webnotes.reload_doc("utilities", "doctype", "note")
    webnotes.reload_doc("utilities", "doctype", "note_user")

    for question in webnotes.conn.sql("""select * from tabQuestion""",
                                      as_dict=True):
        if question.question:
            try:
                name = question.question[:180]
                if webnotes.conn.exists("Note", name):
                    webnotes.delete_doc("Note", name)

                similar_questions = webnotes.conn.sql_list(
                    """select name from `tabQuestion`
					where question like %s""", "%s%%" % name)
                answers = [markdown2.markdown(c) for c in webnotes.conn.sql_list("""
						select answer from tabAnswer where question in (%s)""" % \
                  ", ".join(["%s"]*len(similar_questions)), similar_questions)]

                webnotes.bean({
                    "doctype": "Note",
                    "title": name,
                    "content": "<hr>".join(answers),
                    "owner": question.owner,
                    "creation": question.creation,
                    "public": 1
                }).insert()

            except NameError:
                pass
            except Exception, e:
                if e.args[0] != 1062:
                    raise
def execute():
    for sc in [
            "itemwise_price_list", "itemwise_receipt_details",
            "shortage_to_purchase_request", "stock_aging_report",
            "stock_ledger", "stock_level", "stock_report", "custom_test2",
            "custom_test3", "custom_test4", "test_so2", "test_so3"
    ]:
        webnotes.delete_doc("Search Criteria", sc)
Пример #27
0
 def delete_bin(self, item_code, warehouse):
     bin = webnotes.conn.exists({
         "doctype": "Bin",
         "item_code": item_code,
         "warehouse": warehouse
     })
     if bin:
         webnotes.delete_doc("Bin", bin[0][0])
Пример #28
0
	def on_trash(self):
		from webnotes.webutils import clear_cache
		
		# remove website sitemap permissions
		to_remove = webnotes.conn.sql_list("""select name from `tabWebsite Sitemap Permission` 
			where website_sitemap=%s""", (self.doc.name,))
		webnotes.delete_doc("Website Sitemap Permission", to_remove, ignore_permissions=True)
		
		clear_cache(self.doc.name)
Пример #29
0
def make_demo_user():
	from webnotes.auth import _update_password
	
	roles = ["Accounts Manager", "Analytics", "Expense Approver", "Accounts User", 
		"Leave Approver", "Blogger", "Customer", "Sales Manager", "Employee", "Support Manager", 
		"HR Manager", "HR User", "Maintenance Manager", "Maintenance User", "Material Manager", 
		"Material Master Manager", "Material User", "Manufacturing Manager", 
		"Manufacturing User", "Projects User", "Purchase Manager", "Purchase Master Manager", 
		"Purchase User", "Quality Manager", "Report Manager", "Sales Master Manager", 
		"Sales User", "Supplier", "Support Team"]
		
	def add_roles(bean):
		for role in roles:
			p.doclist.append({
				"doctype": "UserRole",
				"parentfield": "user_roles",
				"role": role
			})
	
	# make demo user
	if webnotes.conn.exists("Profile", "*****@*****.**"):
		webnotes.delete_doc("Profile", "*****@*****.**")

	p = webnotes.new_bean("Profile")
	p.doc.email = "*****@*****.**"
	p.doc.first_name = "Demo"
	p.doc.last_name = "User"
	p.doc.enabled = 1
	p.doc.user_type = "ERPNino Demo"
	p.insert()
	add_roles(p)
	p.save()
	_update_password("*****@*****.**", "demo")
	
	# make system manager user
	if webnotes.conn.exists("Profile", "*****@*****.**"):
		webnotes.delete_doc("Profile", "*****@*****.**")
	
	p = webnotes.new_bean("Profile")
	p.doc.email = "*****@*****.**"
	p.doc.first_name = "Admin"
	p.doc.last_name = "User"
	p.doc.enabled = 1
	p.doc.user_type = "System User"
	p.insert()
	roles.append("System Manager")
	add_roles(p)
	p.save()
	_update_password("*****@*****.**", "admin010123")
	
	# only read for newsletter
	webnotes.conn.sql("""update `tabDocPerm` set `write`=0, `create`=0, `cancel`=0
		where parent='Newsletter'""")
	webnotes.conn.sql("""update `tabDocPerm` set `write`=0, `create`=0, `cancel`=0
		where parent='Profile' and role='All'""")
	
	webnotes.conn.commit()
Пример #30
0
def delete_events(ref_type, ref_name):
    webnotes.delete_doc(
        "Event",
        webnotes.conn.sql_list(
            """select name from `tabEvent` 
		where ref_type=%s and ref_name=%s""",
            (ref_type, ref_name),
        ),
        for_reload=True,
    )
Пример #31
0
    def delete_events(self):
        webnotes.delete_doc(
            "Event",
            webnotes.conn.sql_list(
                """select name from `tabEvent` 
			where ref_type=%s and ref_name=%s""",
                (self.doc.doctype, self.doc.name),
            ),
            ignore_permissions=True,
        )
Пример #32
0
	def test_si_gl_entry_with_aii_and_update_stock_with_warehouse_but_no_account(self):
		self.clear_stock_account_balance()
		set_perpetual_inventory()
		webnotes.delete_doc("Account", "_Test Warehouse No Account - _TC")
		
		# insert purchase receipt
		from stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
			as pr_test_records
		pr = webnotes.bean(copy=pr_test_records[0])
		pr.doc.naming_series = "_T-Purchase Receipt-"
		pr.doclist[1].warehouse = "_Test Warehouse No Account - _TC"
		pr.run_method("calculate_taxes_and_totals")
		pr.insert()
		pr.submit()
		
		si_doclist = webnotes.copy_doclist(test_records[1])
		si_doclist[0]["update_stock"] = 1
		si_doclist[0]["posting_time"] = "12:05"
		si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"

		si = webnotes.bean(copy=si_doclist)
		si.insert()
		si.submit()
		
		# check stock ledger entries
		sle = webnotes.conn.sql("""select * from `tabStock Ledger Entry` 
			where voucher_type = 'Sales Invoice' and voucher_no = %s""", 
			si.doc.name, as_dict=1)[0]
		self.assertTrue(sle)
		self.assertEquals([sle.item_code, sle.warehouse, sle.actual_qty], 
			["_Test Item", "_Test Warehouse No Account - _TC", -1.0])
		
		# check gl entries
		gl_entries = webnotes.conn.sql("""select account, debit, credit
			from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
			order by account asc, debit asc""", si.doc.name, as_dict=1)
		self.assertTrue(gl_entries)
		
		expected_gl_entries = sorted([
			[si.doc.debit_to, 630.0, 0.0],
			[si_doclist[1]["income_account"], 0.0, 500.0],
			[si_doclist[2]["account_head"], 0.0, 80.0],
			[si_doclist[3]["account_head"], 0.0, 50.0],
		])
		for i, gle in enumerate(gl_entries):
			self.assertEquals(expected_gl_entries[i][0], gle.account)
			self.assertEquals(expected_gl_entries[i][1], gle.debit)
			self.assertEquals(expected_gl_entries[i][2], gle.credit)
				
		si.cancel()
		gle = webnotes.conn.sql("""select * from `tabGL Entry` 
			where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
		
		self.assertFalse(gle)
		set_perpetual_inventory(0)
Пример #33
0
	def test_si_gl_entry_with_aii_and_update_stock_with_warehouse_but_no_account(self):
		self.clear_stock_account_balance()
		set_perpetual_inventory()
		webnotes.delete_doc("Account", "_Test Warehouse No Account - _TC")
		
		# insert purchase receipt
		from stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
			as pr_test_records
		pr = webnotes.bean(copy=pr_test_records[0])
		pr.doc.naming_series = "_T-Purchase Receipt-"
		pr.doclist[1].warehouse = "_Test Warehouse No Account - _TC"
		pr.run_method("calculate_taxes_and_totals")
		pr.insert()
		pr.submit()
		
		si_doclist = webnotes.copy_doclist(test_records[1])
		si_doclist[0]["update_stock"] = 1
		si_doclist[0]["posting_time"] = "12:05"
		si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"

		si = webnotes.bean(copy=si_doclist)
		si.insert()
		si.submit()
		
		# check stock ledger entries
		sle = webnotes.conn.sql("""select * from `tabStock Ledger Entry` 
			where voucher_type = 'Sales Invoice' and voucher_no = %s""", 
			si.doc.name, as_dict=1)[0]
		self.assertTrue(sle)
		self.assertEquals([sle.item_code, sle.warehouse, sle.actual_qty], 
			["_Test Item", "_Test Warehouse No Account - _TC", -1.0])
		
		# check gl entries
		gl_entries = webnotes.conn.sql("""select account, debit, credit
			from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
			order by account asc, debit asc""", si.doc.name, as_dict=1)
		self.assertTrue(gl_entries)
		
		expected_gl_entries = sorted([
			[si.doc.debit_to, 630.0, 0.0],
			[si_doclist[1]["income_account"], 0.0, 500.0],
			[si_doclist[2]["account_head"], 0.0, 80.0],
			[si_doclist[3]["account_head"], 0.0, 50.0],
		])
		for i, gle in enumerate(gl_entries):
			self.assertEquals(expected_gl_entries[i][0], gle.account)
			self.assertEquals(expected_gl_entries[i][1], gle.debit)
			self.assertEquals(expected_gl_entries[i][2], gle.credit)
				
		si.cancel()
		gle = webnotes.conn.sql("""select * from `tabGL Entry` 
			where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
		
		self.assertFalse(gle)
		set_perpetual_inventory(0)
Пример #34
0
def execute():
	webnotes.clear_perms("Profile")
	webnotes.reload_doc("core", "doctype", "profile")
	webnotes.conn.sql("""delete from `tabDefaultValue` where defkey='theme'""")
	webnotes.delete_doc("Page", "profile-settings")
	return

	for name in webnotes.conn.sql("""select name from tabProfile"""):
		theme = webnotes.conn.get_default("theme", name[0])
		if theme:
			webnotes.conn.set_value("Profile", name[0], "theme", theme)
Пример #35
0
def execute():
    webnotes.clear_perms("Profile")
    webnotes.reload_doc("core", "doctype", "profile")
    webnotes.conn.sql("""delete from `tabDefaultValue` where defkey='theme'""")
    webnotes.delete_doc("Page", "profile-settings")
    return

    for name in webnotes.conn.sql("""select name from tabProfile"""):
        theme = webnotes.conn.get_default("theme", name[0])
        if theme:
            webnotes.conn.set_value("Profile", name[0], "theme", theme)
Пример #36
0
	def if_home_clear_cache(self):
		"""if home page, clear cache"""
		if webnotes.conn.get_value("Website Settings", None, "home_page")==self.doc.name:
			if webnotes.conn.exists("Website Sitemap", "index"):
				webnotes.delete_doc("Website Sitemap", "index", ignore_permissions=True)
			WebsiteGenerator.on_update(self, page_name="index")

			from webnotes.sessions import clear_cache
			clear_cache('Guest')
			
			from webnotes.webutils import clear_cache
			clear_cache(self.doc.page_name)
			clear_cache('index')
def execute():
	webnotes.reload_doc("core", "doctype", "doctype")
	
	tables = webnotes.conn.sql_list("show tables")
	
	if "tabPacked Item" not in tables:
		webnotes.rename_doc("DocType", "Delivery Note Packing Item", "Packed Item", force=True)
	
	webnotes.reload_doc("stock", "doctype", "packed_item")
	
	if os.path.exists("app/stock/doctype/delivery_note_packing_item"):
		os.system("rm -rf app/stock/doctype/delivery_note_packing_item")
	
	if webnotes.conn.exists("DocType", "Delivery Note Packing Item"):
			webnotes.delete_doc("DocType", "Delivery Note Packing Item")
Пример #38
0
def make_word_map():
    webnotes.conn.sql("""delete from tabWord""")
    webnotes.conn.sql("""delete from `tabWord Data Set`""")
    webnotes.conn.commit()
    webnotes.conn.auto_commit_on_many_writes = True
    for d in webnotes.conn.sql("""select name, ifnull(title, "") as title, 
		ifnull(description, "") as description 
		from `tabData Set`""",
                               as_dict=True):
        sys.stdout.write(".")
        sys.stdout.flush()

        # cleanup
        all_text = d.title + d.description
        all_text = all_text.replace("%", "percent").replace('"', "")
        for t in replace_with_space:
            all_text = all_text.replace(t, " ")
        for t in eliminate_list:
            all_text = all_text.replace(t, "")

        for word in all_text.split():
            name = word.title()
            if len(name) > 5 and (name not in common_list):
                if not webnotes.conn.exists("Word", name):
                    webnotes.doc({
                        "doctype": "Word",
                        "name": name,
                        "count": 1
                    }).insert()
                else:
                    webnotes.conn.sql(
                        """update tabWord set `count`=`count` + 1 where name=%s""",
                        name)

                if not webnotes.conn.sql(
                        """select name from `tabWord Data Set` 
					where word=%s and data_set=%s""", (name, d.name)):
                    webnotes.doc({
                        "doctype": "Word Data Set",
                        "data_set": d.name,
                        "word": name
                    }).insert()

    for d in webnotes.conn.sql("select name from tabWord where `count`< 100"):
        webnotes.delete_doc('Word', d[0])

    webnotes.conn.commit()
Пример #39
0
def delete_items():
	"""delete selected items"""
	import json
	from webnotes.model.code import get_obj

	il = json.loads(webnotes.form_dict.get('items'))
	doctype = webnotes.form_dict.get('doctype')
	
	for d in il:
		try:
			dt_obj = get_obj(doctype, d)
			if hasattr(dt_obj, 'on_trash'):
				dt_obj.on_trash()
			webnotes.delete_doc(doctype, d)
		except Exception, e:
			webnotes.errprint(webnotes.get_traceback())
			pass
Пример #40
0
def execute():
	from webnotes.utils import get_base_path
	import shutil
	webnotes.reload_doc("core", "doctype", "doctype")

	tables = webnotes.conn.sql_list("show tables")
	
	if "tabApplicable Territory" not in tables:
		webnotes.rename_doc("DocType", "For Territory", "Applicable Territory", force=True)
	
	webnotes.reload_doc("setup", "doctype", "applicable_territory")
	
	path = os.path.join(get_base_path(), "app", "setup", "doctype", "for_territory")
	if os.path.exists(path):
		shutil.rmtree(path)
	
	if webnotes.conn.exists("DocType", "For Territory"):
		webnotes.delete_doc("DocType", "For Territory")
def execute():
    webnotes.reload_doc("core", "doctype", "doctype")

    tables = webnotes.conn.sql_list("show tables")

    if "tabPacked Item" not in tables:
        webnotes.rename_doc("DocType",
                            "Delivery Note Packing Item",
                            "Packed Item",
                            force=True)

    webnotes.reload_doc("stock", "doctype", "packed_item")

    if os.path.exists("app/stock/doctype/delivery_note_packing_item"):
        os.system("rm -rf app/stock/doctype/delivery_note_packing_item")

    if webnotes.conn.exists("DocType", "Delivery Note Packing Item"):
        webnotes.delete_doc("DocType", "Delivery Note Packing Item")
Пример #42
0
def rename_doc(doctype, old, new, force=False, merge=False, ignore_permissions=False):
	"""
		Renames a doc(dt, old) to doc(dt, new) and 
		updates all linked fields of type "Link" or "Select" with "link:"
	"""
	if not webnotes.conn.exists(doctype, old):
		return
	
	force = cint(force)
	merge = cint(merge)
	
	# get doclist of given doctype
	doclist = webnotes.model.doctype.get(doctype)
	
	# call before_rename
	new = webnotes.bean(doctype, old).run_method("before_rename", old, new, merge) or new
		
	new = validate_rename(doctype, new, doclist, merge, force, ignore_permissions)
		
	if not merge:
		rename_parent_and_child(doctype, old, new, doclist)
			
	# update link fields' values
	link_fields = get_link_fields(doctype)
	update_link_field_values(link_fields, old, new)
	
	if doctype=='DocType':
		rename_doctype(doctype, old, new, force)
	
	update_attachments(doctype, old, new)
	
	if merge:
		webnotes.delete_doc(doctype, old)
		
	# call after_rename
	webnotes.bean(doctype, new).run_method("after_rename", old, new, merge)
	
	# update restrictions
	webnotes.conn.sql("""update tabDefaultValue set defvalue=%s where parenttype='Restriction' 
		and defkey=%s and defvalue=%s""", (new, doctype, old))
	webnotes.clear_cache()
	
	return new
Пример #43
0
	def test_serialized_stock_entry(self):
		data = [["2012-01-01", "01:00", "10001", 400, 400],
			["2012-01-01", "03:00", "10002", 500, 700],
			["2012-01-01", "04:00", "10003", 700, 700],
			["2012-01-01", "05:00", "10004", 1200, 800],
			["2012-01-01", "05:00", "10005", 800, 800],
			["2012-01-01", "02:00", "10006", 1200, 800],
			["2012-01-01", "06:00", "10007", 1500, 900]]
		for d in data:
			webnotes.bean([{
				"doctype": "Serial No",
				"item_code": "Nebula 8",
				"warehouse": "Default Warehouse", 
				"status": "In Store",
				"sle_exists": 0,
				"purchase_date": d[0],
				"purchase_time": d[1],
				"serial_no": d[2],
				"purchase_rate": d[3],
				"company": company,
			}]).insert()
			
		for d in data:
			res = webnotes.conn.sql("""select valuation_rate from `tabStock Ledger Entry`
				where posting_date=%s and posting_time=%s and actual_qty=1 and serial_no=%s""",
				(d[0], d[1], d[2]))
			self.assertEquals(res[0][0], d[4])
		
		print "deleted"
		webnotes.delete_doc("Serial No", "10002")
		
		test_data = [["10001", 400, 400],
			["10003", 700, 766.666667],
			["10004", 1200, 875],
			["10005", 800, 860],
			["10006", 1200, 800],
			["10007", 1500, 966.666667]]
		
		for d in test_data:
			res = webnotes.conn.sql("""select valuation_rate from `tabStock Ledger Entry`
				where actual_qty=1 and serial_no=%s""", (d[0],))
			self.assertEquals(res[0][0], d[2])
Пример #44
0
def rename_doc(doctype, old, new, force=False, merge=False):
	"""
		Renames a doc(dt, old) to doc(dt, new) and 
		updates all linked fields of type "Link" or "Select" with "link:"
	"""
	if not webnotes.conn.exists(doctype, old):
		return
	
	force = cint(force)
	merge = cint(merge)
	
	# get doclist of given doctype
	doclist = webnotes.model.doctype.get(doctype)
	
	# call before_rename
	old_obj = webnotes.get_obj(doctype, old)
	if hasattr(old_obj, 'before_rename'):
		new = old_obj.before_rename(old, new, merge) or new
		
	new = validate_rename(doctype, new, doclist, merge, force)
		
	if not merge:
		rename_parent_and_child(doctype, old, new, doclist)
			
	# update link fields' values
	link_fields = get_link_fields(doctype)
	update_link_field_values(link_fields, old, new)
	
	if doctype=='DocType':
		rename_doctype(doctype, old, new, force)
	
	update_attachments(doctype, old, new)
	
	if merge:
		webnotes.delete_doc(doctype, old)
		
	# call after_rename
	new_obj = webnotes.get_obj(doctype, new)
	if hasattr(new_obj, 'after_rename'):
		new_obj.after_rename(old, new, merge)
		
	return new
Пример #45
0
def rename_doc(doctype, old, new, force=False, merge=False):
    """
		Renames a doc(dt, old) to doc(dt, new) and 
		updates all linked fields of type "Link" or "Select" with "link:"
	"""
    if not webnotes.conn.exists(doctype, old):
        return

    force = cint(force)
    merge = cint(merge)

    # get doclist of given doctype
    doclist = webnotes.model.doctype.get(doctype)

    # call before_rename
    old_obj = webnotes.get_obj(doctype, old)
    if hasattr(old_obj, 'before_rename'):
        new = old_obj.before_rename(old, new, merge) or new

    new = validate_rename(doctype, new, doclist, merge, force)

    if not merge:
        rename_parent_and_child(doctype, old, new, doclist)

    # update link fields' values
    link_fields = get_link_fields(doctype)
    update_link_field_values(link_fields, old, new)

    if doctype == 'DocType':
        rename_doctype(doctype, old, new, force)

    update_attachments(doctype, old, new)

    if merge:
        webnotes.delete_doc(doctype, old)

    # call after_rename
    new_obj = webnotes.get_obj(doctype, new)
    if hasattr(new_obj, 'after_rename'):
        new_obj.after_rename(old, new, merge)

    return new
Пример #46
0
def execute():
	# set page published = 1
	webnotes.reload_doc("website", "doctype", "web_page")
	webnotes.conn.sql("""update `tabWeb Page` set published=1;""")

	# convert all page & blog markdowns to html
	from markdown2 import markdown

	for page in webnotes.conn.sql("""select name, main_section from `tabWeb Page`"""):
		m = markdown(page[1] or "").encode("utf8")
		webnotes.conn.set_value("Web Page", page[0], "main_section", m)

	for page in webnotes.conn.sql("""select name, content from `tabBlog`"""):
		m = markdown(page[1] or "").encode("utf8")
		webnotes.conn.set_value("Blog", page[0], "content", m)

	# delete website cache
	webnotes.delete_doc("DocType", "Web Cache")
	webnotes.conn.commit()
	webnotes.conn.sql("""drop table if exists `tabWeb Cache`""")
Пример #47
0
    def test_serialized_stock_entry(self):
        data = [["2012-01-01", "01:00", "10001", 400, 400],
                ["2012-01-01", "03:00", "10002", 500, 700],
                ["2012-01-01", "04:00", "10003", 700, 700],
                ["2012-01-01", "05:00", "10004", 1200, 800],
                ["2012-01-01", "05:00", "10005", 800, 800],
                ["2012-01-01", "02:00", "10006", 1200, 800],
                ["2012-01-01", "06:00", "10007", 1500, 900]]
        for d in data:
            webnotes.model_wrapper([{
                "doctype": "Serial No",
                "item_code": "Nebula 8",
                "warehouse": "Default Warehouse",
                "status": "In Store",
                "sle_exists": 0,
                "purchase_date": d[0],
                "purchase_time": d[1],
                "serial_no": d[2],
                "purchase_rate": d[3],
                "company": company,
            }]).insert()

        for d in data:
            res = webnotes.conn.sql(
                """select valuation_rate from `tabStock Ledger Entry`
				where posting_date=%s and posting_time=%s and actual_qty=1 and serial_no=%s""",
                (d[0], d[1], d[2]))
            self.assertEquals(res[0][0], d[4])

        print "deleted"
        webnotes.delete_doc("Serial No", "10002")

        test_data = [["10001", 400, 400], ["10003", 700, 766.666667],
                     ["10004", 1200, 875], ["10005", 800, 860],
                     ["10006", 1200, 800], ["10007", 1500, 966.666667]]

        for d in test_data:
            res = webnotes.conn.sql(
                """select valuation_rate from `tabStock Ledger Entry`
				where actual_qty=1 and serial_no=%s""", (d[0], ))
            self.assertEquals(res[0][0], d[2])
def add_website_sitemap_config(page_or_generator, path, fname,
                               existing_configs):
    basepath = webnotes.utils.get_base_path()
    template_path = os.path.relpath(os.path.join(path, fname), basepath)
    lastmod = int(os.path.getmtime(template_path))

    name = fname[:-5] if fname.endswith(".html") else fname

    config_lastmod = existing_configs.get(name)
    if str(config_lastmod) != str(lastmod):
        webnotes.delete_doc("Website Sitemap Config", name)
    else:
        return name
        # already exists and safe

    wsc = webnotes._dict({
        "doctype": "Website Sitemap Config",
        "page_or_generator": page_or_generator,
        "link_name": name,
        "template_path": template_path,
        "lastmod": lastmod
    })

    controller_name = fname.split(".")[0].replace("-", "_") + ".py"
    controller_path = os.path.join(path, controller_name)
    if os.path.exists(controller_path):
        wsc.controller = os.path.relpath(controller_path[:-3],
                                         basepath).replace(os.path.sep, ".")
        wsc.controller = ".".join(wsc.controller.split(".")[1:])

    if wsc.controller:
        module = webnotes.get_module(wsc.controller)
        wsc.no_cache = getattr(module, "no_cache", 0)
        wsc.no_sitemap = wsc.no_cache or getattr(module, "no_sitemap", 0)
        wsc.ref_doctype = getattr(module, "doctype", None)
        wsc.page_name_field = getattr(module, "page_name_field", "page_name")
        wsc.condition_field = getattr(module, "condition_field", None)

    webnotes.bean(wsc).insert()

    return name
Пример #49
0
	def on_trash(self):
		# delete bin
		bins = webnotes.conn.sql("select * from `tabBin` where warehouse = %s", 
			self.doc.name, as_dict=1)
		for d in bins:
			if d['actual_qty'] or d['reserved_qty'] or d['ordered_qty'] or \
					d['indented_qty'] or d['projected_qty'] or d['planned_qty']:
				throw("""Warehouse: %s can not be deleted as qty exists for item: %s""" 
					% (self.doc.name, d['item_code']))
			else:
				webnotes.conn.sql("delete from `tabBin` where name = %s", d['name'])
				
		warehouse_account = webnotes.conn.get_value("Account", 
			{"account_type": "Warehouse", "master_name": self.doc.name})
		if warehouse_account:
			webnotes.delete_doc("Account", warehouse_account)
				
		if webnotes.conn.sql("""select name from `tabStock Ledger Entry` 
				where warehouse = %s""", self.doc.name):
			throw(_("""Warehouse can not be deleted as stock ledger entry 
				exists for this warehouse."""))
def execute():
	webnotes.conn.sql("""drop table if exists `tabDocType Mapper`""")
	webnotes.conn.sql("""drop table if exists `tabTable Mapper Detail`""")
	webnotes.conn.sql("""drop table if exists `tabField Mapper Detail`""")
	webnotes.delete_doc("DocType", "DocType Mapper")
	webnotes.delete_doc("DocType", "Table Mapper Detail")
	webnotes.delete_doc("DocType", "Field Mapper Detail")	
Пример #51
0
def update_cart(item_code, qty, with_doclist=0):
    quotation = _get_cart_quotation()

    qty = flt(qty)
    if qty == 0:
        quotation.set_doclist(
            quotation.doclist.get({"item_code": ["!=", item_code]}))
        if not quotation.doclist.get({"parentfield": "quotation_details"}) and \
         not quotation.doc.fields.get("__islocal"):
            quotation.__delete = True

    else:
        quotation_items = quotation.doclist.get({"item_code": item_code})
        if not quotation_items:
            quotation.doclist.append({
                "doctype": "Quotation Item",
                "parentfield": "quotation_details",
                "item_code": item_code,
                "qty": qty
            })
        else:
            quotation_items[0].qty = qty

    apply_cart_settings(quotation=quotation)

    if hasattr(quotation, "__delete"):
        webnotes.delete_doc("Quotation",
                            quotation.doc.name,
                            ignore_permissions=True)
        quotation = _get_cart_quotation()
    else:
        quotation.ignore_permissions = True
        quotation.save()

    set_cart_count(quotation)

    if with_doclist:
        return get_cart_quotation(quotation.doclist)
    else:
        return quotation.doc.name
def execute():
    webnotes.conn.sql("""drop table if exists `tabDocType Mapper`""")
    webnotes.conn.sql("""drop table if exists `tabTable Mapper Detail`""")
    webnotes.conn.sql("""drop table if exists `tabField Mapper Detail`""")
    webnotes.delete_doc("DocType", "DocType Mapper")
    webnotes.delete_doc("DocType", "Table Mapper Detail")
    webnotes.delete_doc("DocType", "Field Mapper Detail")
def execute():
    import webnotes, os, shutil
    from webnotes.utils import get_base_path

    webnotes.delete_doc('Page', 'stock-ledger')
    webnotes.delete_doc('Page', 'stock-ageing')
    webnotes.delete_doc('Page', 'stock-level')
    webnotes.delete_doc('Page', 'general-ledger')

    for d in [["stock", "stock_ledger"], ["stock", "stock_ageing"],
              ["stock", "stock_level"], ["accounts", "general_ledger"]]:
        path = os.path.join(get_base_path(), "app", d[0], "page", d[1])
        if os.path.exists(path):
            shutil.rmtree(path)
Пример #54
0
def execute():
    webnotes.delete_doc("DocType", "Product")
    webnotes.delete_doc("DocType", "Test")
    webnotes.delete_doc("Module Def", "Test")

    os.system("rm -rf app/test")
    os.system("rm -rf app/website/doctype/product")
def execute():
	import webnotes, os, shutil
	from webnotes.utils import get_base_path
	
	webnotes.delete_doc('Page', 'stock-ledger')
	webnotes.delete_doc('Page', 'stock-ageing')
	webnotes.delete_doc('Page', 'stock-level')
	webnotes.delete_doc('Page', 'general-ledger')
	
	for d in [["stock", "stock_ledger"], ["stock", "stock_ageing"],
		 	["stock", "stock_level"], ["accounts", "general_ledger"]]:
		path = os.path.join(get_base_path(), "app", d[0], "page", d[1])
		if os.path.exists(path):
			shutil.rmtree(path)
Пример #56
0
def execute():
    from webnotes.utils import get_base_path
    import shutil
    webnotes.reload_doc("core", "doctype", "doctype")

    tables = webnotes.conn.sql_list("show tables")

    if "tabApplicable Territory" not in tables:
        webnotes.rename_doc("DocType",
                            "For Territory",
                            "Applicable Territory",
                            force=True)

    webnotes.reload_doc("setup", "doctype", "applicable_territory")

    path = os.path.join(get_base_path(), "app", "setup", "doctype",
                        "for_territory")
    if os.path.exists(path):
        shutil.rmtree(path)

    if webnotes.conn.exists("DocType", "For Territory"):
        webnotes.delete_doc("DocType", "For Territory")