def test_map_docs(self): '''Test mapping of multiple source docs on a single target doc''' make_test_records("Item") items = frappe.get_all("Item", fields=["name", "item_code"], filters={ 'is_sales_item': 1, 'has_variants': 0 }) customers = frappe.get_all("Customer") if items and customers: # Make source docs (quotations) and a target doc (sales order) customer = random.choice(customers).name qtn1, item_list_1 = self.make_quotation(items, customer) qtn2, item_list_2 = self.make_quotation(items, customer) so, item_list_3 = self.make_sales_order() # Map source docs to target with corresponding mapper method method = "erpnext.selling.doctype.quotation.quotation.make_sales_order" updated_so = mapper.map_docs(method, json.dumps([qtn1.name, qtn2.name]), so) # Assert that all inserted items are present in updated sales order src_items = item_list_1 + item_list_2 + item_list_3 self.assertEqual(set([d.item_code for d in src_items]), set([d.item_code for d in updated_so.items]))
def test_map_docs(self): '''Test mapping of multiple source docs on a single target doc''' make_test_records("Item") items = ['_Test Item', '_Test Item 2', '_Test FG Item'] # Make source docs (quotations) and a target doc (sales order) qtn1, item_list_1 = self.make_quotation(items, '_Test Customer') qtn2, item_list_2 = self.make_quotation(items, '_Test Customer') so, item_list_3 = self.make_sales_order() # Map source docs to target with corresponding mapper method method = "erpnext.selling.doctype.quotation.quotation.make_sales_order" updated_so = mapper.map_docs(method, json.dumps([qtn1.name, qtn2.name]), so) # Assert that all inserted items are present in updated sales order src_items = item_list_1 + item_list_2 + item_list_3 self.assertEqual(set(d for d in src_items), set(d.item_code for d in updated_so.items))