Beispiel #1
0
def set_price_list(out, party, party_type, given_price_list, pos=None):
    # price list
    price_list = get_permitted_documents('Price List')

    if price_list:
        price_list = price_list[0]
    elif pos and party_type == 'Customer':
        customer_price_list = frappe.get_value('Customer', party.name,
                                               'default_price_list')

        if customer_price_list:
            price_list = customer_price_list
        else:
            pos_price_list = frappe.get_value('POS Profile', pos,
                                              'selling_price_list')
            price_list = pos_price_list or given_price_list
    else:
        price_list = get_default_price_list(party) or given_price_list

    if price_list:
        out.price_list_currency = frappe.db.get_value("Price List",
                                                      price_list,
                                                      "currency",
                                                      cache=True)

    out["selling_price_list" if party.doctype ==
        "Customer" else "buying_price_list"] = price_list
Beispiel #2
0
def set_price_list(party_details,
                   party,
                   party_type,
                   given_price_list,
                   pos=None):
    # price list
    price_list = get_permitted_documents('Price List')

    # if there is only one permitted document based on user permissions, set it
    if price_list and len(price_list) == 1:
        price_list = price_list[0]
    elif pos and party_type == 'Customer':
        customer_price_list = frappe.get_value('Customer', party.name,
                                               'default_price_list')

        if customer_price_list:
            price_list = customer_price_list
        else:
            pos_price_list = frappe.get_value('POS Profile', pos,
                                              'selling_price_list')
            price_list = pos_price_list or given_price_list
    else:
        price_list = get_default_price_list(party) or given_price_list

    if price_list:
        party_details.price_list_currency = frappe.db.get_value("Price List",
                                                                price_list,
                                                                "currency",
                                                                cache=True)

    party_details["selling_price_list" if party.doctype ==
                  "Customer" else "buying_price_list"] = price_list
Beispiel #3
0
def get_warehouse_list(filters):
	from frappe.core.doctype.user_permission.user_permission import get_permitted_documents

	condition = ''
	user_permitted_warehouse = get_permitted_documents('Warehouse')
	value = ()
	if user_permitted_warehouse:
		condition = "and name in %s"
		value = set(user_permitted_warehouse)
	elif not user_permitted_warehouse and filters.get("warehouse"):
		condition = "and name = %s"
		value = filters.get("warehouse")

	return frappe.db.sql("""select name
		from `tabWarehouse` where is_group = 0
		{condition}""".format(condition=condition), value, as_dict=1)
Beispiel #4
0
def set_price_list(out, party, party_type, given_price_list, pos=None):
	# price list
	price_list = get_permitted_documents('Price List')

	if price_list:
		price_list = price_list[0]
	elif pos and party_type == 'Customer':
		customer_price_list = frappe.get_value('Customer', party.name, 'default_price_list')

		if customer_price_list:
			price_list = customer_price_list
		else:
			pos_price_list = frappe.get_value('POS Profile', pos, 'selling_price_list')
			price_list = pos_price_list or given_price_list
	else:
		price_list = get_default_price_list(party) or given_price_list

	if price_list:
		out.price_list_currency = frappe.db.get_value("Price List", price_list, "currency", cache=True)

	out["selling_price_list" if party.doctype=="Customer" else "buying_price_list"] = price_list