refactor: ignore mandatory fields during setup
diff --git a/erpnext/selling/doctype/selling_settings/test_selling_settings.py b/erpnext/selling/doctype/selling_settings/test_selling_settings.py
index fc6754a..7290e68 100644
--- a/erpnext/selling/doctype/selling_settings/test_selling_settings.py
+++ b/erpnext/selling/doctype/selling_settings/test_selling_settings.py
@@ -1,9 +1,14 @@
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
-# import frappe
import unittest
+import frappe
+
class TestSellingSettings(unittest.TestCase):
- pass
+ def test_defaults_populated(self):
+ # Setup default values are not populated on migrate, this test checks
+ # if setup was completed correctly
+ default = frappe.db.get_single_value("Selling Settings", "maintain_same_rate_action")
+ self.assertEqual("Stop", default)
diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py
index 2b055d2..8dae23d 100644
--- a/erpnext/setup/install.py
+++ b/erpnext/setup/install.py
@@ -56,12 +56,11 @@
)
if default_values:
try:
- b = frappe.get_doc(dt, dt)
+ doc = frappe.get_doc(dt, dt)
for fieldname, value in default_values:
- b.set(fieldname, value)
- b.save()
- except frappe.MandatoryError:
- pass
+ doc.set(fieldname, value)
+ doc.flags.ignore_mandatory = True
+ doc.save()
except frappe.ValidationError:
pass