Ejemplo n.º 1
0
def item_query_restaurant(doctype='Item', txt='', searchfield='name', start=0, page_len=20, filters=None, as_dict=False):
	'''Return items that are selected in active menu of the restaurant'''
	restaurant, menu = get_restaurant_and_menu_name(filters['table'])
	items = frappe.db.get_all('Restaurant Menu Item', ['item'], dict(parent = menu))
	del filters['table']
	filters['name'] = ('in', [d.item for d in items])

	return item_query('Item', txt, searchfield, start, page_len, filters, as_dict)
Ejemplo n.º 2
0
def item_query_restaurant(doctype='Item', txt='', searchfield='name', start=0, page_len=20, filters=None, as_dict=False):
	'''Return items that are selected in active menu of the restaurant'''
	restaurant, menu = get_restaurant_and_menu_name(filters['table'])
	items = frappe.db.get_all('Restaurant Menu Item', ['item'], dict(parent = menu))
	del filters['table']
	filters['name'] = ('in', [d.item for d in items])

	return item_query('Item', txt, searchfield, start, page_len, filters, as_dict)
Ejemplo n.º 3
0
def query_configuration_item(doctype, txt, searchfield, start, page_len, filters):
	main_item = filters['item']
	sub_items = [d.sub_item for d in frappe.get_all('Product Configuration Compatibility',
		filters={ 'main_item': main_item }, fields=['sub_item'])]
	item_filters = [['Item', 'item_code', 'in', sub_items]]

	if filters.get('item_group'):
		item_filters.append(['Item', 'item_group', '=', filters['item_group']])

	return item_query('Item', txt, 'name', start, page_len, item_filters)
Ejemplo n.º 4
0
 def test_item_query_for_supplier(self):
     create_party_specific_item(party_type='Supplier',
                                party=self.supplier.name,
                                restrict_based_on='Item Group',
                                based_on_value=self.item.item_group)
     filters = {'supplier': self.supplier.name, 'is_purchase_item': 1}
     items = item_query(doctype='Item',
                        txt='',
                        searchfield='name',
                        start=0,
                        page_len=20,
                        filters=filters,
                        as_dict=False)
     for item in items:
         self.assertEqual(item[2], self.item.item_group)
Ejemplo n.º 5
0
 def test_item_query_for_customer(self):
     create_party_specific_item(party_type='Customer',
                                party=self.customer.name,
                                restrict_based_on='Item',
                                based_on_value=self.item.name)
     filters = {'is_sales_item': 1, 'customer': self.customer.name}
     items = item_query(doctype='Item',
                        txt='',
                        searchfield='name',
                        start=0,
                        page_len=20,
                        filters=filters,
                        as_dict=False)
     for item in items:
         self.assertEqual(item[0], self.item.name)
Ejemplo n.º 6
0
def query_configuration_item(doctype, txt, searchfield, start, page_len,
                             filters):
    main_item = filters['item']
    sub_items = [
        d.sub_item
        for d in frappe.get_all('Product Configuration Compatibility',
                                filters={'main_item': main_item},
                                fields=['sub_item'])
    ]
    item_filters = [['Item', 'item_code', 'in', sub_items]]

    if filters.get('item_group'):
        item_filters.append(['Item', 'item_group', '=', filters['item_group']])

    return item_query('Item', txt, 'name', start, page_len, item_filters)
Ejemplo n.º 7
0
def item_query_restaurant(doctype="Item",
                          txt="",
                          searchfield="name",
                          start=0,
                          page_len=20,
                          filters=None,
                          as_dict=False):
    """Return items that are selected in active menu of the restaurant"""
    restaurant, menu = get_restaurant_and_menu_name(filters["table"])
    items = frappe.db.get_all("Restaurant Menu Item", ["item"],
                              dict(parent=menu))
    del filters["table"]
    filters["name"] = ("in", [d.item for d in items])

    return item_query("Item", txt, searchfield, start, page_len, filters,
                      as_dict)
Ejemplo n.º 8
0
 def test_item_query_for_supplier(self):
     create_party_specific_item(
         party_type="Supplier",
         party=self.supplier.name,
         restrict_based_on="Item Group",
         based_on_value=self.item.item_group,
     )
     filters = {"supplier": self.supplier.name, "is_purchase_item": 1}
     items = item_query(doctype="Item",
                        txt="",
                        searchfield="name",
                        start=0,
                        page_len=20,
                        filters=filters,
                        as_dict=False)
     for item in items:
         self.assertEqual(item[2], self.item.item_group)
Ejemplo n.º 9
0
 def test_item_query_for_customer(self):
     create_party_specific_item(
         party_type="Customer",
         party=self.customer.name,
         restrict_based_on="Item",
         based_on_value=self.item.name,
     )
     filters = {"is_sales_item": 1, "customer": self.customer.name}
     items = item_query(doctype="Item",
                        txt="",
                        searchfield="name",
                        start=0,
                        page_len=20,
                        filters=filters,
                        as_dict=False)
     for item in items:
         self.assertEqual(item[0], self.item.name)