Merge branch 'develop' into mergify/bp/develop/pr-27792
This commit is contained in:
		
						commit
						fee54023a6
					
				| @ -2023,11 +2023,7 @@ class TestSalesInvoice(unittest.TestCase): | |||||||
| 		frappe.local.enable_perpetual_inventory['_Test Company 1'] = old_perpetual_inventory | 		frappe.local.enable_perpetual_inventory['_Test Company 1'] = old_perpetual_inventory | ||||||
| 		frappe.db.set_value("Stock Settings", None, "allow_negative_stock", old_negative_stock) | 		frappe.db.set_value("Stock Settings", None, "allow_negative_stock", old_negative_stock) | ||||||
| 
 | 
 | ||||||
| 	def test_sle_if_target_warehouse_exists_accidentally(self): | 	def test_sle_for_target_warehouse(self): | ||||||
| 		""" |  | ||||||
| 			Check if inward entry exists if Target Warehouse accidentally exists |  | ||||||
| 			but Customer is not an internal customer. |  | ||||||
| 		""" |  | ||||||
| 		se = make_stock_entry( | 		se = make_stock_entry( | ||||||
| 			item_code="138-CMS Shoe", | 			item_code="138-CMS Shoe", | ||||||
| 			target="Finished Goods - _TC", | 			target="Finished Goods - _TC", | ||||||
| @ -2048,9 +2044,9 @@ class TestSalesInvoice(unittest.TestCase): | |||||||
| 		sles = frappe.get_all("Stock Ledger Entry", filters={"voucher_no": si.name}, | 		sles = frappe.get_all("Stock Ledger Entry", filters={"voucher_no": si.name}, | ||||||
| 			fields=["name", "actual_qty"]) | 			fields=["name", "actual_qty"]) | ||||||
| 
 | 
 | ||||||
| 		# check if only one SLE for outward entry is created | 		# check if both SLEs are created | ||||||
| 		self.assertEqual(len(sles), 1) | 		self.assertEqual(len(sles), 2) | ||||||
| 		self.assertEqual(sles[0].actual_qty, -1) | 		self.assertEqual(sum(d.actual_qty for d in sles), 0.0) | ||||||
| 
 | 
 | ||||||
| 		# tear down | 		# tear down | ||||||
| 		si.cancel() | 		si.cancel() | ||||||
|  | |||||||
| @ -424,7 +424,7 @@ class SellingController(StockController): | |||||||
| 					or (cint(self.is_return) and self.docstatus==2)): | 					or (cint(self.is_return) and self.docstatus==2)): | ||||||
| 						sl_entries.append(self.get_sle_for_source_warehouse(d)) | 						sl_entries.append(self.get_sle_for_source_warehouse(d)) | ||||||
| 
 | 
 | ||||||
| 				if d.target_warehouse and self.get("is_internal_customer"): | 				if d.target_warehouse: | ||||||
| 					sl_entries.append(self.get_sle_for_target_warehouse(d)) | 					sl_entries.append(self.get_sle_for_target_warehouse(d)) | ||||||
| 
 | 
 | ||||||
| 				if d.warehouse and ((not cint(self.is_return) and self.docstatus==2) | 				if d.warehouse and ((not cint(self.is_return) and self.docstatus==2) | ||||||
| @ -559,6 +559,12 @@ class SellingController(StockController): | |||||||
| 				frappe.throw(_("Row {0}: Delivery Warehouse ({1}) and Customer Warehouse ({2}) can not be same") | 				frappe.throw(_("Row {0}: Delivery Warehouse ({1}) and Customer Warehouse ({2}) can not be same") | ||||||
| 					.format(d.idx, warehouse, warehouse)) | 					.format(d.idx, warehouse, warehouse)) | ||||||
| 
 | 
 | ||||||
|  | 		if not self.get("is_internal_customer") and any(d.get("target_warehouse") for d in items): | ||||||
|  | 			msg = _("Target Warehouse is set for some items but the customer is not an internal customer.") | ||||||
|  | 			msg += " " + _("This {} will be treated as material transfer.").format(_(self.doctype)) | ||||||
|  | 			frappe.msgprint(msg, title="Internal Transfer", alert=True) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 	def validate_items(self): | 	def validate_items(self): | ||||||
| 		# validate items to see if they have is_sales_item enabled | 		# validate items to see if they have is_sales_item enabled | ||||||
| 		from erpnext.controllers.buying_controller import validate_item_type | 		from erpnext.controllers.buying_controller import validate_item_type | ||||||
|  | |||||||
| @ -51,7 +51,7 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	add_lead_to_prospect (frm) { | 	add_lead_to_prospect () { | ||||||
| 		frappe.prompt([ | 		frappe.prompt([ | ||||||
| 			{ | 			{ | ||||||
| 				fieldname: 'prospect', | 				fieldname: 'prospect', | ||||||
| @ -65,7 +65,7 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller | |||||||
| 			frappe.call({ | 			frappe.call({ | ||||||
| 				method: 'erpnext.crm.doctype.lead.lead.add_lead_to_prospect', | 				method: 'erpnext.crm.doctype.lead.lead.add_lead_to_prospect', | ||||||
| 				args: { | 				args: { | ||||||
| 					'lead': frm.doc.name, | 					'lead': cur_frm.doc.name, | ||||||
| 					'prospect': data.prospect | 					'prospect': data.prospect | ||||||
| 				}, | 				}, | ||||||
| 				callback: function(r) { | 				callback: function(r) { | ||||||
| @ -79,41 +79,41 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller | |||||||
| 		}, __('Add Lead to Prospect'), __('Add')); | 		}, __('Add Lead to Prospect'), __('Add')); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	make_customer (frm) { | 	make_customer () { | ||||||
| 		frappe.model.open_mapped_doc({ | 		frappe.model.open_mapped_doc({ | ||||||
| 			method: "erpnext.crm.doctype.lead.lead.make_customer", | 			method: "erpnext.crm.doctype.lead.lead.make_customer", | ||||||
| 			frm: frm | 			frm: cur_frm | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	make_opportunity (frm) { | 	make_opportunity () { | ||||||
| 		frappe.model.open_mapped_doc({ | 		frappe.model.open_mapped_doc({ | ||||||
| 			method: "erpnext.crm.doctype.lead.lead.make_opportunity", | 			method: "erpnext.crm.doctype.lead.lead.make_opportunity", | ||||||
| 			frm: frm | 			frm: cur_frm | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	make_quotation (frm) { | 	make_quotation () { | ||||||
| 		frappe.model.open_mapped_doc({ | 		frappe.model.open_mapped_doc({ | ||||||
| 			method: "erpnext.crm.doctype.lead.lead.make_quotation", | 			method: "erpnext.crm.doctype.lead.lead.make_quotation", | ||||||
| 			frm: frm | 			frm: cur_frm | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	make_prospect (frm) { | 	make_prospect () { | ||||||
| 		frappe.model.with_doctype("Prospect", function() { | 		frappe.model.with_doctype("Prospect", function() { | ||||||
| 			let prospect = frappe.model.get_new_doc("Prospect"); | 			let prospect = frappe.model.get_new_doc("Prospect"); | ||||||
| 			prospect.company_name = frm.doc.company_name; | 			prospect.company_name = cur_frm.doc.company_name; | ||||||
| 			prospect.no_of_employees = frm.doc.no_of_employees; | 			prospect.no_of_employees = cur_frm.doc.no_of_employees; | ||||||
| 			prospect.industry = frm.doc.industry; | 			prospect.industry = cur_frm.doc.industry; | ||||||
| 			prospect.market_segment = frm.doc.market_segment; | 			prospect.market_segment = cur_frm.doc.market_segment; | ||||||
| 			prospect.territory = frm.doc.territory; | 			prospect.territory = cur_frm.doc.territory; | ||||||
| 			prospect.fax = frm.doc.fax; | 			prospect.fax = cur_frm.doc.fax; | ||||||
| 			prospect.website = frm.doc.website; | 			prospect.website = cur_frm.doc.website; | ||||||
| 			prospect.prospect_owner = frm.doc.lead_owner; | 			prospect.prospect_owner = cur_frm.doc.lead_owner; | ||||||
| 
 | 
 | ||||||
| 			let lead_prospect_row = frappe.model.add_child(prospect, 'prospect_lead'); | 			let lead_prospect_row = frappe.model.add_child(prospect, 'prospect_lead'); | ||||||
| 			lead_prospect_row.lead = frm.doc.name; | 			lead_prospect_row.lead = cur_frm.doc.name; | ||||||
| 
 | 
 | ||||||
| 			frappe.set_route("Form", "Prospect", prospect.name); | 			frappe.set_route("Form", "Prospect", prospect.name); | ||||||
| 		}); | 		}); | ||||||
|  | |||||||
| @ -47,7 +47,7 @@ class MaintenanceSchedule(TransactionBase): | |||||||
| 			"Yearly": 365 | 			"Yearly": 365 | ||||||
| 		} | 		} | ||||||
| 		for item in self.items: | 		for item in self.items: | ||||||
| 			if item.periodicity and item.start_date: | 			if item.periodicity and item.periodicity != "Random" and item.start_date: | ||||||
| 				if not item.end_date: | 				if not item.end_date: | ||||||
| 					if item.no_of_visits: | 					if item.no_of_visits: | ||||||
| 						item.end_date = add_days(item.start_date, item.no_of_visits * days_in_period[item.periodicity]) | 						item.end_date = add_days(item.start_date, item.no_of_visits * days_in_period[item.periodicity]) | ||||||
|  | |||||||
| @ -185,7 +185,6 @@ class DeliveryNote(SellingController): | |||||||
| 			if not d['warehouse'] and frappe.db.get_value("Item", d['item_code'], "is_stock_item") == 1: | 			if not d['warehouse'] and frappe.db.get_value("Item", d['item_code'], "is_stock_item") == 1: | ||||||
| 				frappe.throw(_("Warehouse required for stock Item {0}").format(d["item_code"])) | 				frappe.throw(_("Warehouse required for stock Item {0}").format(d["item_code"])) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 	def update_current_stock(self): | 	def update_current_stock(self): | ||||||
| 		if self.get("_action") and self._action != "update_after_submit": | 		if self.get("_action") and self._action != "update_after_submit": | ||||||
| 			for d in self.get('items'): | 			for d in self.get('items'): | ||||||
|  | |||||||
| @ -468,7 +468,7 @@ | |||||||
|    "width": "100px" |    "width": "100px" | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "depends_on": "eval:parent.is_internal_customer", |    "depends_on": "eval:parent.is_internal_customer || doc.target_warehouse", | ||||||
|    "fieldname": "target_warehouse", |    "fieldname": "target_warehouse", | ||||||
|    "fieldtype": "Link", |    "fieldtype": "Link", | ||||||
|    "hidden": 1, |    "hidden": 1, | ||||||
| @ -759,7 +759,7 @@ | |||||||
|  "index_web_pages_for_search": 1, |  "index_web_pages_for_search": 1, | ||||||
|  "istable": 1, |  "istable": 1, | ||||||
|  "links": [], |  "links": [], | ||||||
|  "modified": "2021-02-23 01:04:08.588104", |  "modified": "2021-10-05 12:12:44.018872", | ||||||
|  "modified_by": "Administrator", |  "modified_by": "Administrator", | ||||||
|  "module": "Stock", |  "module": "Stock", | ||||||
|  "name": "Delivery Note Item", |  "name": "Delivery Note Item", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user