Merge pull request #36322 from frappe/mergify/bp/develop/pr-36298

fix: show invoices name instead of object address (backport #36298)
diff --git a/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py b/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py
index 8eb28df..1deb3c5 100644
--- a/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py
+++ b/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py
@@ -49,6 +49,24 @@
 		self.assertEqual(pcv_doc.total_quantity, 2)
 		self.assertEqual(pcv_doc.net_total, 6700)
 
+	def test_pos_closing_without_item_code(self):
+		"""
+		Test if POS Closing Entry is created without item code
+		"""
+		test_user, pos_profile = init_user_and_profile()
+		opening_entry = create_opening_entry(pos_profile, test_user.name)
+
+		pos_inv = create_pos_invoice(
+			rate=3500, do_not_submit=1, item_name="Test Item", without_item_code=1
+		)
+		pos_inv.append("payments", {"mode_of_payment": "Cash", "account": "Cash - _TC", "amount": 3500})
+		pos_inv.submit()
+
+		pcv_doc = make_closing_entry_from_opening(opening_entry)
+		pcv_doc.submit()
+
+		self.assertTrue(pcv_doc.name)
+
 	def test_cancelling_of_pos_closing_entry(self):
 		test_user, pos_profile = init_user_and_profile()
 		opening_entry = create_opening_entry(pos_profile, test_user.name)
diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py
index 0fce61f..00c402f 100644
--- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py
+++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py
@@ -986,19 +986,34 @@
 			msg = f"Serial No {args.serial_no} not available for Item {args.item}"
 			frappe.throw(_(msg))
 
-	pos_inv.append(
-		"items",
-		{
-			"item_code": args.item or args.item_code or "_Test Item",
-			"warehouse": args.warehouse or "_Test Warehouse - _TC",
-			"qty": args.qty or 1,
-			"rate": args.rate if args.get("rate") is not None else 100,
-			"income_account": args.income_account or "Sales - _TC",
-			"expense_account": args.expense_account or "Cost of Goods Sold - _TC",
-			"cost_center": args.cost_center or "_Test Cost Center - _TC",
-			"serial_and_batch_bundle": bundle_id,
-		},
-	)
+	pos_invoice_item = {
+		"warehouse": args.warehouse or "_Test Warehouse - _TC",
+		"qty": args.qty or 1,
+		"rate": args.rate if args.get("rate") is not None else 100,
+		"income_account": args.income_account or "Sales - _TC",
+		"expense_account": args.expense_account or "Cost of Goods Sold - _TC",
+		"cost_center": args.cost_center or "_Test Cost Center - _TC",
+		"serial_and_batch_bundle": bundle_id,
+	}
+	# append in pos invoice items without item_code by checking flag without_item_code
+	if args.without_item_code:
+		pos_inv.append(
+			"items",
+			{
+				**pos_invoice_item,
+				"item_name": args.item_name or "_Test Item",
+				"description": args.item_name or "_Test Item",
+			},
+		)
+
+	else:
+		pos_inv.append(
+			"items",
+			{
+				**pos_invoice_item,
+				"item_code": args.item or args.item_code or "_Test Item",
+			},
+		)
 
 	if not args.do_not_save:
 		pos_inv.insert()
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 8fa0a84..dab7fa0 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -776,7 +776,6 @@
 
 	update_stock: function(frm, dt, dn) {
 		frm.events.hide_fields(frm);
-		frm.fields_dict.items.grid.toggle_reqd("item_code", frm.doc.update_stock);
 		frm.trigger('reset_posting_time');
 	},
 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index b3212b5..974a876 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -113,7 +113,6 @@
 
 		if cint(self.update_stock):
 			self.validate_dropship_item()
-			self.validate_item_code()
 			self.validate_warehouse()
 			self.update_current_stock()
 			self.validate_delivery_note()
@@ -854,11 +853,6 @@
 			):
 				frappe.throw(_("Paid amount + Write Off Amount can not be greater than Grand Total"))
 
-	def validate_item_code(self):
-		for d in self.get("items"):
-			if not d.item_code and self.is_opening == "No":
-				msgprint(_("Item Code required at Row No {0}").format(d.idx), raise_exception=True)
-
 	def validate_warehouse(self):
 		super(SalesInvoice, self).validate_warehouse()
 
diff --git a/erpnext/assets/doctype/asset/asset.js b/erpnext/assets/doctype/asset/asset.js
index 97a41de..a97ea73 100644
--- a/erpnext/assets/doctype/asset/asset.js
+++ b/erpnext/assets/doctype/asset/asset.js
@@ -141,7 +141,7 @@
 				frm.trigger("set_depr_posting_failure_alert");
 			}
 
-			frm.trigger("setup_chart");
+			frm.trigger("setup_chart_and_depr_schedule_view");
 		}
 
 		frm.trigger("toggle_reference_doc");
@@ -206,7 +206,38 @@
 		})
 	},
 
-	setup_chart: async function(frm) {
+	render_depreciation_schedule_view: function(frm, depr_schedule) {
+		var wrapper = $(frm.fields_dict["depreciation_schedule_view"].wrapper).empty();
+
+		let table = $(`<table class="table table-bordered" style="margin-top:0px;">
+			<thead>
+				<tr>
+					<td align="center">${__("No.")}</td>
+					<td>${__("Schedule Date")}</td>
+					<td align="right">${__("Depreciation Amount")}</td>
+					<td align="right">${__("Accumulated Depreciation Amount")}</td>
+					<td>${__("Journal Entry")}</td>
+				</tr>
+			</thead>
+			<tbody></tbody>
+		</table>`);
+
+		depr_schedule.forEach((sch) => {
+			const row = $(`<tr>
+				<td align="center">${sch['idx']}</td>
+				<td><b>${frappe.format(sch['schedule_date'], { fieldtype: 'Date' })}</b></td>
+				<td><b>${frappe.format(sch['depreciation_amount'], { fieldtype: 'Currency' })}</b></td>
+				<td>${frappe.format(sch['accumulated_depreciation_amount'], { fieldtype: 'Currency' })}</td>
+				<td><a href="/app/journal-entry/${sch['journal_entry'] || ''}">${sch['journal_entry'] || ''}</a></td>
+			</tr>`);
+			table.find("tbody").append(row);
+		});
+
+		wrapper.append(table);
+
+	},
+
+	setup_chart_and_depr_schedule_view: async function(frm) {
 		if(frm.doc.finance_books.length > 1) {
 			return
 		}
@@ -228,7 +259,7 @@
 				"erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule.get_depr_schedule",
 				{
 					asset_name: frm.doc.name,
-					status: frm.doc.docstatus ? "Active" : "Draft",
+					status: "Active",
 					finance_book: frm.doc.finance_books[0].finance_book || null
 				}
 			)).message;
@@ -246,6 +277,9 @@
 					}
 				}
 			});
+
+			frm.toggle_display(["depreciation_schedule_view"], 1);
+			frm.events.render_depreciation_schedule_view(frm, depr_schedule);
 		} else {
 			if(frm.doc.opening_accumulated_depreciation) {
 				x_intervals.push(frappe.format(frm.doc.creation.split(" ")[0], { fieldtype: 'Date' }));
diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json
index a1e8f33..698fc78 100644
--- a/erpnext/assets/doctype/asset/asset.json
+++ b/erpnext/assets/doctype/asset/asset.json
@@ -52,6 +52,8 @@
   "column_break_24",
   "frequency_of_depreciation",
   "next_depreciation_date",
+  "depreciation_schedule_sb",
+  "depreciation_schedule_view",
   "insurance_details",
   "policy_number",
   "insurer",
@@ -487,6 +489,17 @@
    "options": "\nSuccessful\nFailed",
    "print_hide": 1,
    "read_only": 1
+  },
+  {
+   "fieldname": "depreciation_schedule_sb",
+   "fieldtype": "Section Break",
+   "label": "Depreciation Schedule"
+  },
+  {
+   "fieldname": "depreciation_schedule_view",
+   "fieldtype": "HTML",
+   "hidden": 1,
+   "label": "Depreciation Schedule View"
   }
  ],
  "idx": 72,
@@ -520,7 +533,7 @@
    "table_fieldname": "accounts"
   }
  ],
- "modified": "2023-03-30 15:07:41.542374",
+ "modified": "2023-07-26 13:33:36.821534",
  "modified_by": "Administrator",
  "module": "Assets",
  "name": "Asset",
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index 7dc438e..5d35808 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -21,6 +21,7 @@
 import erpnext
 from erpnext.accounts.general_ledger import make_reverse_gl_entries
 from erpnext.assets.doctype.asset.depreciation import (
+	get_comma_separated_links,
 	get_depreciation_accounts,
 	get_disposal_account_and_cost_center,
 )
@@ -59,8 +60,17 @@
 		if not self.booked_fixed_asset and self.validate_make_gl_entry():
 			self.make_gl_entries()
 		if not self.split_from:
-			make_draft_asset_depr_schedules_if_not_present(self)
+			asset_depr_schedules_names = make_draft_asset_depr_schedules_if_not_present(self)
 			convert_draft_asset_depr_schedules_into_active(self)
+			if asset_depr_schedules_names:
+				asset_depr_schedules_links = get_comma_separated_links(
+					asset_depr_schedules_names, "Asset Depreciation Schedule"
+				)
+				frappe.msgprint(
+					_(
+						"Asset Depreciation Schedules created:<br>{0}<br><br>Please check, edit if needed, and submit the Asset."
+					).format(asset_depr_schedules_links)
+				)
 
 	def on_cancel(self):
 		self.validate_cancellation()
@@ -74,7 +84,15 @@
 
 	def after_insert(self):
 		if not self.split_from:
-			make_draft_asset_depr_schedules(self)
+			asset_depr_schedules_names = make_draft_asset_depr_schedules(self)
+			asset_depr_schedules_links = get_comma_separated_links(
+				asset_depr_schedules_names, "Asset Depreciation Schedule"
+			)
+			frappe.msgprint(
+				_(
+					"Asset Depreciation Schedules created:<br>{0}<br><br>Please check, edit if needed, and submit the Asset."
+				).format(asset_depr_schedules_links)
+			)
 
 	def validate_asset_and_reference(self):
 		if self.purchase_invoice or self.purchase_receipt:
diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py
index deae8c7..e616665 100644
--- a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py
+++ b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py
@@ -571,6 +571,8 @@
 
 
 def make_draft_asset_depr_schedules_if_not_present(asset_doc):
+	asset_depr_schedules_names = []
+
 	for row in asset_doc.get("finance_books"):
 		draft_asset_depr_schedule_name = get_asset_depr_schedule_name(
 			asset_doc.name, "Draft", row.finance_book
@@ -581,12 +583,20 @@
 		)
 
 		if not draft_asset_depr_schedule_name and not active_asset_depr_schedule_name:
-			make_draft_asset_depr_schedule(asset_doc, row)
+			name = make_draft_asset_depr_schedule(asset_doc, row)
+			asset_depr_schedules_names.append(name)
+
+	return asset_depr_schedules_names
 
 
 def make_draft_asset_depr_schedules(asset_doc):
+	asset_depr_schedules_names = []
+
 	for row in asset_doc.get("finance_books"):
-		make_draft_asset_depr_schedule(asset_doc, row)
+		name = make_draft_asset_depr_schedule(asset_doc, row)
+		asset_depr_schedules_names.append(name)
+
+	return asset_depr_schedules_names
 
 
 def make_draft_asset_depr_schedule(asset_doc, row):
@@ -596,6 +606,8 @@
 
 	asset_depr_schedule_doc.insert()
 
+	return asset_depr_schedule_doc.name
+
 
 def update_draft_asset_depr_schedules(asset_doc):
 	for row in asset_doc.get("finance_books"):
diff --git a/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json b/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json
index abe295c..884e0c6 100644
--- a/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json
+++ b/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json
@@ -53,7 +53,7 @@
   },
   {
    "allow_on_submit": 1,
-   "depends_on": "eval:(doc.docstatus==1 && !doc.journal_entry && doc.schedule_date <= get_today())",
+   "depends_on": "eval:(doc.docstatus==1 && !doc.journal_entry && doc.schedule_date <= frappe.datetime.now_date())",
    "fieldname": "make_depreciation_entry",
    "fieldtype": "Button",
    "label": "Make Depreciation Entry"
@@ -61,7 +61,7 @@
  ],
  "istable": 1,
  "links": [],
- "modified": "2023-03-13 23:17:15.849950",
+ "modified": "2023-07-26 12:56:48.718736",
  "modified_by": "Administrator",
  "module": "Assets",
  "name": "Depreciation Schedule",