Example #1
0
def set_cart_count(login_manager):
    role, parties = check_customer_or_supplier()
    if role == 'Supplier':
        return
    if show_cart_count():
        from erpnext.shopping_cart.cart import set_cart_count
        set_cart_count()
Example #2
0
def change_in_shipping(shipp):
	with_items=True
	quotation = _get_cart_quotation()
	if shipp == '0':
		quotation.shipping_rule = None
	else:
		quotation.shipping_rule = shipp
	empty_card = False
	"""qty = flt(qty)
	if qty == 0:
		quotation_items = quotation.get("items", {"item_code": ["!=", item_code]})
		if quotation_items:
			quotation.set("items", quotation_items)
		else:
			empty_card = True

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

	apply_cart_settings(quotation=quotation)

	quotation.flags.ignore_permissions = True
	if not empty_card:
		quotation.save()
	else:
		quotation.delete()
		quotation = None

	set_cart_count(quotation)

	context = get_cart_quotation(quotation)

	if cint(with_items):
		return {
			"items": frappe.render_template("templates/includes/cart/cart_items.html",
				context),
			"taxes": frappe.render_template("templates/includes/order/order_taxes.html",
				context),
		}
	else:
		return {
			'name': quotation.name,
			'shopping_cart_menu': get_shopping_cart_menu(context)
		}
Example #3
0
def update_calendar_items_cart(item_code, qty, with_items=False):
    from erpnext.shopping_cart.cart import _get_cart_quotation, apply_cart_settings, \
     set_cart_count, get_cart_quotation, get_shopping_cart_menu
    quotation = _get_cart_quotation()

    empty_card = False
    qty = flt(qty)
    if qty == 0:
        quotation_items = quotation.get("items",
                                        {"item_code": ["!=", item_code]})
        if quotation_items:
            quotation.set("items", quotation_items)
        else:
            empty_card = True

    else:
        quotation.append("items", {
            "doctype": "Quotation Item",
            "item_code": item_code,
            "qty": qty
        })

    apply_cart_settings(quotation=quotation)

    quotation.flags.ignore_permissions = True
    quotation.payment_schedule = []
    if not empty_card:
        quotation.save()
    else:
        quotation.delete()
        quotation = None

    set_cart_count(quotation)

    context = get_cart_quotation(quotation)

    if cint(with_items):
        return {
            "items":
            frappe.render_template("templates/includes/cart/cart_items.html",
                                   context),
            "taxes":
            frappe.render_template("templates/includes/order/order_taxes.html",
                                   context),
        }
    else:
        return {
            'name': quotation.name,
            'shopping_cart_menu': get_shopping_cart_menu(context)
        }
Example #4
0
def update_calendar_items_cart(item_code, qty, uom_name):
    from erpnext.shopping_cart.cart import _get_cart_quotation, apply_cart_settings, \
     set_cart_count, get_cart_quotation, get_shopping_cart_menu
    quotation = _get_cart_quotation()

    empty_card = False
    qty = flt(qty)
    if qty == 0:
        quotation_items = quotation.get("items",
                                        {"item_code": ["!=", item_code]})
        if quotation_items:
            quotation.set("items", quotation_items)
        else:
            empty_card = True

    else:
        quotation.append(
            "items", {
                "doctype": "Quotation Item",
                "item_code": item_code,
                "qty": qty,
                "uom": get_sp_uom(uom_name)
            })

    apply_cart_settings(quotation=quotation)

    quotation.flags.ignore_permissions = True
    quotation.payment_schedule = []
    if not empty_card:
        quotation.save()
    else:
        quotation.delete()
        quotation = None

    set_cart_count(quotation)

    context = get_cart_quotation(quotation)

    return {
        'name': quotation.name if quotation else None,
        'shopping_cart_menu': get_shopping_cart_menu(context)
    }
Example #5
0
def set_cart_count(login_manager):
	if show_cart_count():
		from erpnext.shopping_cart.cart import set_cart_count
		set_cart_count()
Example #6
0
def set_cart_count(login_manager):
	role, parties = check_customer_or_supplier()
	if role == 'Supplier': return
	if show_cart_count():
		from erpnext.shopping_cart.cart import set_cart_count
		set_cart_count()