refactor: ignore mandatory fields during setup

This commit is contained in:
Ankush Menat 2022-03-27 11:52:31 +05:30 committed by Ankush Menat
parent 086d31b59f
commit c3e1f0e369
2 changed files with 11 additions and 7 deletions

View File

@ -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)

View File

@ -56,12 +56,11 @@ def set_single_defaults():
)
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