brotherton-erpnext/erpnext/controllers/tests/test_transaction_base.py
Sagar Sharma 6485ac4e59
fix: misleading "Set Default X" fields after saving (#28798)
* fix: misleading "Set Default X" fields after saving

* refactor: remove unncessary code and minor formatting

* fix: extend to more doctypes and correct fieldnames

Co-authored-by: Ankush Menat <ankush@frappe.io>
2021-12-09 17:04:00 +05:30

23 lines
777 B
Python

import unittest
import frappe
class TestUtils(unittest.TestCase):
def test_reset_default_field_value(self):
doc = frappe.get_doc({
"doctype": "Purchase Receipt",
"set_warehouse": "Warehouse 1",
})
# Same values
doc.items = [{"warehouse": "Warehouse 1"}, {"warehouse": "Warehouse 1"}, {"warehouse": "Warehouse 1"}]
doc.reset_default_field_value("set_warehouse", "items", "warehouse")
self.assertEqual(doc.set_warehouse, "Warehouse 1")
# Mixed values
doc.items = [{"warehouse": "Warehouse 1"}, {"warehouse": "Warehouse 2"}, {"warehouse": "Warehouse 1"}]
doc.reset_default_field_value("set_warehouse", "items", "warehouse")
self.assertEqual(doc.set_warehouse, None)