Repository: 8848digital/erpnext
Pull request #2337: Selling module tc
Author: login: Barathpalanisamy
Created: 2025-05-12T11:49:35Z | Merged: 2025-05-14T14:52:23Z

update new test case in Installation Note.

Id - 
1. TC_S_195  -  test_installation_note_with_serial_no_TC_S_195


Diff:
diff --git a/erpnext/selling/doctype/customer_credit_limit/customer_credit_limit.py b/erpnext/selling/doctype/customer_credit_limit/customer_credit_limit.py
index fcc6c6e6db66..44721e7df97a 100644
--- a/erpnext/selling/doctype/customer_credit_limit/customer_credit_limit.py
+++ b/erpnext/selling/doctype/customer_credit_limit/customer_credit_limit.py
@@ -12,7 +12,7 @@ class CustomerCreditLimit(Document):
 
 	from typing import TYPE_CHECKING
 
-	if TYPE_CHECKING:
+	if TYPE_CHECKING: # pragma: no cover
 		from frappe.types import DF
 
 		bypass_credit_limit_check: DF.Check
diff --git a/erpnext/selling/doctype/industry_type/industry_type.py b/erpnext/selling/doctype/industry_type/industry_type.py
index aedec5fa9435..d98b4d967f93 100644
--- a/erpnext/selling/doctype/industry_type/industry_type.py
+++ b/erpnext/selling/doctype/industry_type/industry_type.py
@@ -11,7 +11,7 @@ class IndustryType(Document):
 
 	from typing import TYPE_CHECKING
 
-	if TYPE_CHECKING:
+	if TYPE_CHECKING: # pragma: no cover
 		from frappe.types import DF
 
 		industry: DF.Data
diff --git a/erpnext/selling/doctype/installation_note/installation_note.py b/erpnext/selling/doctype/installation_note/installation_note.py
index 610763a3c5c9..3ff5f2849576 100644
--- a/erpnext/selling/doctype/installation_note/installation_note.py
+++ b/erpnext/selling/doctype/installation_note/installation_note.py
@@ -16,7 +16,7 @@ class InstallationNote(TransactionBase):
 
 	from typing import TYPE_CHECKING
 
-	if TYPE_CHECKING:
+	if TYPE_CHECKING: # pragma: no cover
 		from frappe.types import DF
 
 		from erpnext.selling.doctype.installation_note_item.installation_note_item import (
diff --git a/erpnext/selling/doctype/installation_note/test_installation_note.py b/erpnext/selling/doctype/installation_note/test_installation_note.py
index 56e0fe160ab9..d3c03cd8391d 100644
--- a/erpnext/selling/doctype/installation_note/test_installation_note.py
+++ b/erpnext/selling/doctype/installation_note/test_installation_note.py
@@ -2,9 +2,70 @@
 # See license.txt
 
 import unittest
-
-# test_records = frappe.get_test_records('Installation Note')
+import frappe
+from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_company
+from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_customer
+from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note
+from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
+from erpnext.stock.doctype.delivery_note.delivery_note import make_installation_note
+from erpnext.stock.doctype.item.test_item import make_item
 
 
 class TestInstallationNote(unittest.TestCase):
-	pass
+
+	def tearDown(self):
+		frappe.db.rollback()
+
+	def test_installation_note_with_serial_no_TC_S_195(self):
+		serial_no = "SN-TEST-00001"
+		customer = "_Test Customer"
+		company = "_Test Company"
+		item_code = "_Test Serialized Item"
+		
+		create_customer(customer, currency="INR")
+		
+		create_company(company)
+		
+		item = make_item(item_code, {
+			"is_stock_item": 1,
+			"has_serial_no": 1,
+			"item_group": "Products",
+			"stock_uom": "Nos"
+		})
+		item.save()
+		
+		if not frappe.db.exists("Serial No", serial_no):
+			stock_entry = frappe.get_doc({
+				"doctype": "Stock Entry",
+				"stock_entry_type": "Material Receipt",
+				"company": company,
+				"items": [{
+					"item_code": item_code,
+					"qty": 1,
+					"t_warehouse": "_Test Warehouse - _TC",
+					"serial_no": serial_no,
+					"basic_rate": 100
+				}]
+			})
+			stock_entry.insert()
+			stock_entry.submit()
+
+		so = make_sales_order(item_code=item_code)
+		dn = make_delivery_note(so.name)
+		dn.items[0].qty = 1
+		dn.items[0].serial_no = serial_no
+		dn.submit()
+		
+		installation_note = make_installation_note(dn.name)
+		installation_note.inst_date = frappe.utils.nowdate()
+		installation_note.save()
+		
+		self.assertEqual(installation_note.items[0].serial_no, serial_no)
+		
+		installation_note.submit()
+		self.assertEqual(installation_note.status, "Submitted")
+		self.assertEqual(installation_note.customer, customer)
+		self.assertEqual(installation_note.company, company)
+		
+		installation_note.cancel()
+		self.assertEqual(installation_note.status, "Cancelled")
\ No newline at end of file
diff --git a/erpnext/selling/doctype/installation_note_item/installation_note_item.py b/erpnext/selling/doctype/installation_note_item/installation_note_item.py
index 8566ab06a4c0..1933717a05ad 100644
--- a/erpnext/selling/doctype/installation_note_item/installation_note_item.py
+++ b/erpnext/selling/doctype/installation_note_item/installation_note_item.py
@@ -11,7 +11,7 @@ class InstallationNoteItem(Document):
 
 	from typing import TYPE_CHECKING
 
-	if TYPE_CHECKING:
+	if TYPE_CHECKING: # pragma: no cover
 		from frappe.types import DF
 
 		description: DF.TextEditor | None
diff --git a/erpnext/selling/doctype/party_specific_item/party_specific_item.py b/erpnext/selling/doctype/party_specific_item/party_specific_item.py
index 708a08087f33..a75015af94b1 100644
--- a/erpnext/selling/doctype/party_specific_item/party_specific_item.py
+++ b/erpnext/selling/doctype/party_specific_item/party_specific_item.py
@@ -12,7 +12,7 @@ class PartySpecificItem(Document):
 
 	from typing import TYPE_CHECKING
 
-	if TYPE_CHECKING:
+	if TYPE_CHECKING: # pragma: no cover
 		from frappe.types import DF
 
 		based_on_value: DF.DynamicLink
diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.py b/erpnext/selling/doctype/quotation_item/quotation_item.py
index 7d68eaf07bab..2addef83ba80 100644
--- a/erpnext/selling/doctype/quotation_item/quotation_item.py
+++ b/erpnext/selling/doctype/quotation_item/quotation_item.py
@@ -11,7 +11,7 @@ class QuotationItem(Document):
 
 	from typing import TYPE_CHECKING
 
-	if TYPE_CHECKING:
+	if TYPE_CHECKING: # pragma: no cover
 		from frappe.types import DF
 
 		actual_qty: DF.Float


Reviews:
user: login: aasif-patel
state: CHANGES_REQUESTED
author_association: COLLABORATOR
submitted_at: 2025-05-13T12:07:08Z
user: login: aasif-patel
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-05-14T14:31:07Z

Review comments:
diff_hunk: @@ -2,9 +2,73 @@
 # See license.txt
 
 import unittest
-
-# test_records = frappe.get_test_records('Installation Note')
+import frappe
+from erpnext.setup.doctype.company.test_company import create_child_company
+from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_customer
+from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note
+from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
+from erpnext.stock.doctype.delivery_note.delivery_note import make_installation_note
+from erpnext.stock.doctype.item.test_item import make_item
 
 
 class TestInstallationNote(unittest.TestCase):
-	pass
+
+	def tearDown(self):
+		frappe.db.rollback()
+
+	def test_installation_note_with_serial_no_TC_S_195(self):
+		serial_no = "SN-TEST-00001"
+		customer = "_Test Customer"
+		company = "_Test Company"
+		item_code = "_Test Serialized Item"
+		
+		if not frappe.db.exists("Customer", customer):
path: erpnext/selling/doctype/installation_note/test_installation_note.py
user: login: aasif-patel
body: create_customer from test payment entry handing the duplication not need to check record existance.
created_at: 2025-05-13T12:00:39Z
author_association: COLLABORATOR
diff_hunk: @@ -2,9 +2,73 @@
 # See license.txt
 
 import unittest
-
-# test_records = frappe.get_test_records('Installation Note')
+import frappe
+from erpnext.setup.doctype.company.test_company import create_child_company
+from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_customer
+from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note
+from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
+from erpnext.stock.doctype.delivery_note.delivery_note import make_installation_note
+from erpnext.stock.doctype.item.test_item import make_item
 
 
 class TestInstallationNote(unittest.TestCase):
-	pass
+
+	def tearDown(self):
+		frappe.db.rollback()
+
+	def test_installation_note_with_serial_no_TC_S_195(self):
+		serial_no = "SN-TEST-00001"
+		customer = "_Test Customer"
+		company = "_Test Company"
+		item_code = "_Test Serialized Item"
+		
+		if not frappe.db.exists("Customer", customer):
+			create_customer(customer, currency="INR")
+		
+		if not frappe.db.exists("Company", company):
+			create_child_company()
path: erpnext/selling/doctype/installation_note/test_installation_note.py
user: login: aasif-patel
body: No use create_child_company checks for "Test Company" not the company name you have mentioned, that means it will not create the company name you have declared.
created_at: 2025-05-13T12:05:32Z
author_association: COLLABORATOR
diff_hunk: @@ -2,9 +2,73 @@
 # See license.txt
 
 import unittest
-
-# test_records = frappe.get_test_records('Installation Note')
+import frappe
+from erpnext.setup.doctype.company.test_company import create_child_company
+from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_customer
+from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note
+from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
+from erpnext.stock.doctype.delivery_note.delivery_note import make_installation_note
+from erpnext.stock.doctype.item.test_item import make_item
 
 
 class TestInstallationNote(unittest.TestCase):
-	pass
+
+	def tearDown(self):
+		frappe.db.rollback()
+
+	def test_installation_note_with_serial_no_TC_S_195(self):
+		serial_no = "SN-TEST-00001"
+		customer = "_Test Customer"
+		company = "_Test Company"
+		item_code = "_Test Serialized Item"
+		
+		if not frappe.db.exists("Customer", customer):
+			create_customer(customer, currency="INR")
+		
+		if not frappe.db.exists("Company", company):
+			create_child_company()
+		
+		if not frappe.db.exists("Item", item_code):
path: erpnext/selling/doctype/installation_note/test_installation_note.py
user: login: aasif-patel
body: Not need to check record existance make_item method handling it
created_at: 2025-05-13T12:06:39Z
author_association: COLLABORATOR

PR comments:
user: login: codecov[bot]
created_at: 2025-05-12T14:00:33Z
body: ## [Codecov](https://app.codecov.io/gh/8848digital/erpnext/pull/2337?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=8848digital) Report
All modified and coverable lines are covered by tests :white_check_mark:

```diff
@@                 Coverage Diff                  @@
##           pre-prod-develop    #2337      +/-   ##
====================================================
- Coverage             57.87%   57.85%   -0.03%     
====================================================
  Files                   717      717              
  Lines                 70647    70462     -185     
====================================================
- Hits                  40890    40768     -122     
+ Misses                29757    29694      -63     
```

| [Files with missing lines](https://app.codecov.io/gh/8848digital/erpnext/pull/2337?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=8848digital) | Coverage Δ | |
|---|---|---|
| [...ype/customer\_credit\_limit/customer\_credit\_limit.py](https://app.codecov.io/gh/8848digital/erpnext/pull/2337?src=pr&el=tree&filepath=erpnext%2Fselling%2Fdoctype%2Fcustomer_credit_limit%2Fcustomer_credit_limit.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=8848digital#diff-ZXJwbmV4dC9zZWxsaW5nL2RvY3R5cGUvY3VzdG9tZXJfY3JlZGl0X2xpbWl0L2N1c3RvbWVyX2NyZWRpdF9saW1pdC5weQ==) | `41.66% <100.00%> (ø)` | |
| [...ext/selling/doctype/industry\_type/industry\_type.py](https://app.codecov.io/gh/8848digital/erpnext/pull/2337?src=pr&el=tree&filepath=erpnext%2Fselling%2Fdoctype%2Findustry_type%2Findustry_type.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=8848digital#diff-ZXJwbmV4dC9zZWxsaW5nL2RvY3R5cGUvaW5kdXN0cnlfdHlwZS9pbmR1c3RyeV90eXBlLnB5) | `71.42% <100.00%> (ø)` | |
| [...ing/doctype/installation\_note/installation\_note.py](https://app.codecov.io/gh/8848digital/erpnext/pull/2337?src=pr&el=tree&filepath=erpnext%2Fselling%2Fdoctype%2Finstallation_note%2Finstallation_note.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=8848digital#diff-ZXJwbmV4dC9zZWxsaW5nL2RvY3R5cGUvaW5zdGFsbGF0aW9uX25vdGUvaW5zdGFsbGF0aW9uX25vdGUucHk=) | `51.85% <100.00%> (+51.85%)` | :arrow_up: |
| [...e/installation\_note\_item/installation\_note\_item.py](https://app.codecov.io/gh/8848digital/erpnext/pull/2337?src=pr&el=tree&filepath=erpnext%2Fselling%2Fdoctype%2Finstallation_note_item%2Finstallation_note_item.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=8848digital#diff-ZXJwbmV4dC9zZWxsaW5nL2RvY3R5cGUvaW5zdGFsbGF0aW9uX25vdGVfaXRlbS9pbnN0YWxsYXRpb25fbm90ZV9pdGVtLnB5) | `29.41% <100.00%> (+29.41%)` | :arrow_up: |
| [...doctype/party\_specific\_item/party\_specific\_item.py](https://app.codecov.io/gh/8848digital/erpnext/pull/2337?src=pr&el=tree&filepath=erpnext%2Fselling%2Fdoctype%2Fparty_specific_item%2Fparty_specific_item.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=8848digital#diff-ZXJwbmV4dC9zZWxsaW5nL2RvY3R5cGUvcGFydHlfc3BlY2lmaWNfaXRlbS9wYXJ0eV9zcGVjaWZpY19pdGVtLnB5) | `60.00% <100.00%> (ø)` | |
| [...t/selling/doctype/quotation\_item/quotation\_item.py](https://app.codecov.io/gh/8848digital/erpnext/pull/2337?src=pr&el=tree&filepath=erpnext%2Fselling%2Fdoctype%2Fquotation_item%2Fquotation_item.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=8848digital#diff-ZXJwbmV4dC9zZWxsaW5nL2RvY3R5cGUvcXVvdGF0aW9uX2l0ZW0vcXVvdGF0aW9uX2l0ZW0ucHk=) | `8.33% <100.00%> (ø)` | |

... and [62 files with indirect coverage changes](https://app.codecov.io/gh/8848digital/erpnext/pull/2337/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=8848digital)

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
author_association: NONE
user: login: Barathpalanisamy
created_at: 2025-05-14T04:14:45Z
body: @aasif-patel  changes done.

author_association: NONE
user: login: swathibollineni2
created_at: 2025-05-16T04:51:06Z
body: @Barathpalanisamy
 TC_S_195 - MandatoryError: HSN/SAC Code is required. Please enter a valid HSN/SAC code.
author_association: NONE
user: login: pallavi238848
created_at: 2025-05-16T05:32:33Z
body: @hrishikesh8848 , check this as @Barathpalanisamy is no more a part of this project.
author_association: COLLABORATOR