Fixed conflict while merging v4 into v5
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
index 790ba1d..9df3b88 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
@@ -40,7 +40,7 @@
 					})
 
 					if root_account:
-						account.ignore_mandatory = True
+						account.flags.ignore_mandatory = True
 
 					account.insert()
 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 63aef26..132304f 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -152,7 +152,7 @@
 			if d.time_log_batch:
 				tlb = frappe.get_doc("Time Log Batch", d.time_log_batch)
 				tlb.sales_invoice = sales_invoice
-				tlb.ignore_validate_update_after_submit = True
+				tlb.flags.ignore_validate_update_after_submit = True
 				tlb.save()
 
 	def validate_time_logs_are_submitted(self):
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index 9d4f86b..5c57a90 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -81,7 +81,7 @@
 def make_entry(args, adv_adj, update_outstanding):
 	args.update({"doctype": "GL Entry"})
 	gle = frappe.get_doc(args)
-	gle.ignore_permissions = 1
+	gle.flags.ignore_permissions = 1
 	gle.insert()
 	gle.run_method("on_update_with_args", adv_adj, update_outstanding)
 	gle.submit()
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 8ecbc8d..415a51a 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -209,7 +209,7 @@
 		ch.docstatus = 1
 
 	# will work as update after submit
-	jv_obj.ignore_validate_update_after_submit = True
+	jv_obj.flags.ignore_validate_update_after_submit = True
 	jv_obj.save()
 
 def remove_against_link_from_jv(ref_type, ref_no, against_field):
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 7e15404..0e56fc7 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -48,8 +48,7 @@
 	def set_missing_lead_customer_details(self):
 		if getattr(self, "customer", None):
 			from erpnext.accounts.party import _get_party_details
-			party_details = _get_party_details(self.customer,
-				ignore_permissions=getattr(self, "ignore_permissions", None))
+			party_details = _get_party_details(self.customer, ignore_permissions=self.flags.ignore_permissions)
 			if not self.meta.get_field("sales_team"):
 				party_details.pop("sales_team")
 
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index 042dcd7..9cd029b 100644
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -58,7 +58,7 @@
 	def update_user(self):
 		# add employee role if missing
 		user = frappe.get_doc("User", self.user_id)
-		user.ignore_permissions = True
+		user.flags.ignore_permissions = True
 
 		if "Employee" not in user.get("user_roles"):
 			user.add_roles("Employee")
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index c2dd677..702fdef 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -131,7 +131,7 @@
 				d.rate = rate
 
 		if self.docstatus == 1:
-			self.ignore_validate_update_after_submit = True
+			self.flags.ignore_validate_update_after_submit = True
 			self.calculate_cost()
 		self.save()
 
@@ -353,7 +353,7 @@
 
 			if act_pbom and act_pbom[0][0]:
 				frappe.throw(_("Cannot deactivate or cancel BOM as it is linked with other BOMs"))
-				
+
 	def validate_operations(self):
 		if self.with_operations and not self.get('operations'):
 			frappe.throw(_("Operations cannot be left blank."))
diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
index 713433e..24204f2 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -394,7 +394,7 @@
 						"sales_order_no": sales_order if sales_order!="No Sales Order" else None
 					})
 
-				pr_doc.ignore_permissions = 1
+				pr_doc.flags.ignore_permissions = 1
 				pr_doc.submit()
 				purchase_request_list.append(pr_doc.name)
 
diff --git a/erpnext/patches/v4_0/apply_user_permissions.py b/erpnext/patches/v4_0/apply_user_permissions.py
index 7dae02f..52e0bb7 100644
--- a/erpnext/patches/v4_0/apply_user_permissions.py
+++ b/erpnext/patches/v4_0/apply_user_permissions.py
@@ -28,7 +28,7 @@
 	for employee in frappe.db.sql_list("""select name from `tabEmployee` where docstatus < 2"""):
 		try:
 			emp = frappe.get_doc("Employee", employee)
-			emp.ignore_mandatory = True
+			emp.flags.ignore_mandatory = True
 			emp.save()
 		except EmployeeUserDisabledError:
 			pass
diff --git a/erpnext/patches/v4_0/global_defaults_to_system_settings.py b/erpnext/patches/v4_0/global_defaults_to_system_settings.py
index 57b21ae..4c3ae76 100644
--- a/erpnext/patches/v4_0/global_defaults_to_system_settings.py
+++ b/erpnext/patches/v4_0/global_defaults_to_system_settings.py
@@ -31,9 +31,9 @@
 
 		system_settings.language = lang
 
-	system_settings.ignore_mandatory = True
+	system_settings.flags.ignore_mandatory = True
 	system_settings.save()
 
 	global_defaults = frappe.get_doc("Global Defaults")
-	global_defaults.ignore_mandatory = True
+	global_defaults.flags.ignore_mandatory = True
 	global_defaults.save()
diff --git a/erpnext/patches/v4_2/recalculate_bom_cost.py b/erpnext/patches/v4_2/recalculate_bom_cost.py
index 3a194ff..ff96cea 100644
--- a/erpnext/patches/v4_2/recalculate_bom_cost.py
+++ b/erpnext/patches/v4_2/recalculate_bom_cost.py
@@ -6,11 +6,11 @@
 
 def execute():
 	for d in frappe.db.sql("select name from `tabBOM` where docstatus < 2"):
-		try:	
+		try:
 			document = frappe.get_doc('BOM', d[0])
 			if document.docstatus == 1:
-				document.ignore_validate_update_after_submit = True
+				document.flags.ignore_validate_update_after_submit = True
 				document.calculate_cost()
 			document.save()
 		except:
-			pass
\ No newline at end of file
+			pass
diff --git a/erpnext/patches/v4_2/reset_bom_costs.py b/erpnext/patches/v4_2/reset_bom_costs.py
index 49f0b2e..0b49112 100644
--- a/erpnext/patches/v4_2/reset_bom_costs.py
+++ b/erpnext/patches/v4_2/reset_bom_costs.py
@@ -9,7 +9,7 @@
 	for d in frappe.db.sql("""select name from `tabBOM` where docstatus < 2""", as_dict=1):
 		try:
 			bom = frappe.get_doc('BOM', d.name)
-			bom.ignore_validate_update_after_submit = True
+			bom.flags.ignore_validate_update_after_submit = True
 			bom.calculate_cost()
 			bom.save()
 			frappe.db.commit()
diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py
index a7401b4..33855af 100644
--- a/erpnext/projects/doctype/time_log/time_log.py
+++ b/erpnext/projects/doctype/time_log/time_log.py
@@ -110,7 +110,7 @@
 					tl.hours, self.production_order, operation[0], operation[1]))
 
 			pro_order = frappe.get_doc("Production Order", self.production_order)
-			pro_order.ignore_validate_update_after_submit = True
+			pro_order.flags.ignore_validate_update_after_submit = True
 			pro_order.update_operation_status()
 			pro_order.calculate_operating_cost()
 			pro_order.set_actual_dates()
@@ -129,14 +129,14 @@
 			from `tabTime Log`
 			where production_order = %s and operation = %s and docstatus=1""",
 			(self.production_order, self.operation), as_dict=1)[0]
-			
+
 	def validate_project(self):
 		if self.time_log_for == 'Project':
 			if not self.project:
 				frappe.throw(_("Project is Mandatory."))
 		if self.time_log_for == "":
-			self.project = None			
-		
+			self.project = None
+
 	def validate_manufacturing(self):
 		if self.time_log_for == 'Manufacturing':
 			if not self.production_order:
diff --git a/erpnext/projects/doctype/time_log_batch/time_log_batch.py b/erpnext/projects/doctype/time_log_batch/time_log_batch.py
index e878577..d2e83e1 100644
--- a/erpnext/projects/doctype/time_log_batch/time_log_batch.py
+++ b/erpnext/projects/doctype/time_log_batch/time_log_batch.py
@@ -57,7 +57,7 @@
 			tl = frappe.get_doc("Time Log", d.time_log)
 			tl.time_log_batch = time_log_batch
 			tl.sales_invoice = self.sales_invoice
-			tl.ignore_validate_update_after_submit = True
+			tl.flags.ignore_validate_update_after_submit = True
 			tl.save()
 
 @frappe.whitelist()
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 6b8ec9e..8a50de5 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -61,7 +61,7 @@
 			c.customer = self.name
 			c.customer_name = self.customer_name
 			c.is_primary_contact = 1
-			c.ignore_permissions = getattr(self, "ignore_permissions", None)
+			c.flags.ignore_permissions = self.flags.ignore_permissions
 			c.autoname()
 			if not frappe.db.exists("Contact", c.name):
 				c.insert()
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 10a59f4..5a05220 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -24,7 +24,7 @@
 
 	def has_sales_order(self):
 		return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1})
-		
+
 	def validate_for_items(self):
 		chk_dupl_itm = []
 		for d in self.get('items'):
@@ -111,7 +111,7 @@
 			target.customer = customer.name
 			target.customer_name = customer.customer_name
 		target.ignore_pricing_rule = 1
-		target.ignore_permissions = ignore_permissions
+		target.flags.ignore_permissions = ignore_permissions
 		target.run_method("set_missing_values")
 		target.run_method("calculate_taxes_and_totals")
 
@@ -152,7 +152,7 @@
 			from erpnext.selling.doctype.lead.lead import _make_customer
 			customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions)
 			customer = frappe.get_doc(customer_doclist)
-			customer.ignore_permissions = ignore_permissions
+			customer.flags.ignore_permissions = ignore_permissions
 			if quotation[1] == "Shopping Cart":
 				customer.customer_group = frappe.db.get_value("Shopping Cart Settings", None,
 					"default_customer_group")
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 67257bb..6247afd 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -102,7 +102,7 @@
 		for d in self.fld_dict.keys():
 			account.set(d, (d == 'parent_account' and lst[self.fld_dict[d]]) and lst[self.fld_dict[d]] +' - '+ self.abbr or lst[self.fld_dict[d]])
 		if not account.parent_account:
-			account.ignore_mandatory = True
+			account.flags.ignore_mandatory = True
 		account.insert()
 
 	def set_default_accounts(self):
@@ -146,10 +146,10 @@
 		for cc in cc_list:
 			cc.update({"doctype": "Cost Center"})
 			cc_doc = frappe.get_doc(cc)
-			cc_doc.ignore_permissions = True
+			cc_doc.flags.ignore_permissions = True
 
 			if cc.get("cost_center_name") == self.name:
-				cc_doc.ignore_mandatory = True
+				cc_doc.flags.ignore_mandatory = True
 			cc_doc.insert()
 
 		frappe.db.set(self, "cost_center", _("Main") + " - " + self.abbr)
diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py
index fdbbe9e..ce7af6d 100644
--- a/erpnext/setup/install.py
+++ b/erpnext/setup/install.py
@@ -20,7 +20,7 @@
 def feature_setup():
 	"""save global defaults and features setup"""
 	doc = frappe.get_doc("Features Setup", "Features Setup")
-	doc.ignore_permissions = True
+	doc.flags.ignore_permissions = True
 
 	# store value as 1 for all these fields
 	flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
diff --git a/erpnext/setup/page/setup_wizard/install_fixtures.py b/erpnext/setup/page/setup_wizard/install_fixtures.py
index f83ab35..96ea0d9 100644
--- a/erpnext/setup/page/setup_wizard/install_fixtures.py
+++ b/erpnext/setup/page/setup_wizard/install_fixtures.py
@@ -136,7 +136,7 @@
 		{'doctype': 'Activity Type', 'activity_type': _('Execution')},
 		{'doctype': 'Activity Type', 'activity_type': _('Communication')},
 		{'doctype': 'Activity Type', 'activity_type': _('Manufacturing')},
-		
+
 		# Industry Type
 		{'doctype': 'Industry Type', 'industry': _('Accounting')},
 		{'doctype': 'Industry Type', 'industry': _('Advertising')},
@@ -203,6 +203,6 @@
 		# ignore mandatory for root
 		parent_link_field = ("parent_" + scrub(doc.doctype))
 		if doc.meta.get_field(parent_link_field) and not doc.get(parent_link_field):
-			doc.ignore_mandatory = True
+			doc.flags.ignore_mandatory = True
 
 		doc.insert()
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index 3ee089c..5b54485 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -41,7 +41,7 @@
 		if not quotation.get(fieldname):
 			throw(_("{0} is required").format(quotation.meta.get_label(fieldname)))
 
-	quotation.ignore_permissions = True
+	quotation.flags.ignore_permissions = True
 	quotation.submit()
 
 	if quotation.lead:
@@ -53,7 +53,7 @@
 	for item in sales_order.get("items"):
 		item.reserved_warehouse = frappe.db.get_value("Item", item.item_code, "website_warehouse") or None
 
-	sales_order.ignore_permissions = True
+	sales_order.flags.ignore_permissions = True
 	sales_order.insert()
 	sales_order.submit()
 	frappe.local.cookie_manager.delete_cookie("cart_count")
@@ -88,7 +88,7 @@
 		frappe.delete_doc("Quotation", quotation.name, ignore_permissions=True)
 		quotation = _get_cart_quotation()
 	else:
-		quotation.ignore_permissions = True
+		quotation.flags.ignore_permissions = True
 		quotation.save()
 
 	set_cart_count(quotation)
@@ -117,7 +117,7 @@
 
 	apply_cart_settings(quotation=quotation)
 
-	quotation.ignore_permissions = True
+	quotation.flags.ignore_permissions = True
 	quotation.save()
 
 	return get_cart_quotation(quotation)
@@ -175,7 +175,7 @@
 			qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
 				"customer": party.name})
 
-		qdoc.ignore_permissions = True
+		qdoc.flags.ignore_permissions = True
 		qdoc.run_method("set_missing_values")
 		apply_cart_settings(party, qdoc)
 
@@ -201,18 +201,18 @@
 		contact.customer_name = party.customer_name
 		contact.mobile_no = mobile_no
 		contact.phone = phone
-		contact.ignore_permissions = True
+		contact.flags.ignore_permissions = True
 		contact.save()
 
 	party_doc = frappe.get_doc(party.as_dict())
-	party_doc.ignore_permissions = True
+	party_doc.flags.ignore_permissions = True
 	party_doc.save()
 
 	qdoc = _get_cart_quotation(party)
 	if not qdoc.get("__islocal"):
 		qdoc.customer_name = company_name or fullname
 		qdoc.run_method("set_missing_lead_customer_details")
-		qdoc.ignore_permissions = True
+		qdoc.flags.ignore_permissions = True
 		qdoc.save()
 
 def apply_cart_settings(party=None, quotation=None):
@@ -276,7 +276,7 @@
 		})
 
 		if frappe.session.user not in ("Guest", "Administrator"):
-			lead_doc.ignore_permissions = True
+			lead_doc.flags.ignore_permissions = True
 			lead_doc.insert()
 
 		return lead_doc
@@ -303,7 +303,7 @@
 
 	apply_cart_settings(quotation=quotation)
 
-	quotation.ignore_permissions = True
+	quotation.flags.ignore_permissions = True
 	quotation.save()
 
 	return get_cart_quotation(quotation)
diff --git a/erpnext/stock/doctype/material_request/test_material_request.py b/erpnext/stock/doctype/material_request/test_material_request.py
index 6fe73fc..ded9a0a 100644
--- a/erpnext/stock/doctype/material_request/test_material_request.py
+++ b/erpnext/stock/doctype/material_request/test_material_request.py
@@ -216,7 +216,7 @@
 
 		mr.update_status('Submitted')
 
-		se.ignore_validate_update_after_submit = True
+		se.flags.ignore_validate_update_after_submit = True
 		se.submit()
 		mr.update_status('Stopped')
 		self.assertRaises(frappe.InvalidStatusError, se.cancel)
diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py
index 5f46869..35bd8dc 100644
--- a/erpnext/stock/doctype/price_list/price_list.py
+++ b/erpnext/stock/doctype/price_list/price_list.py
@@ -51,7 +51,7 @@
 
 			if self.name == b.get(price_list_fieldname):
 				b.set(price_list_fieldname, None)
-				b.ignore_permissions = True
+				b.flags.ignore_permissions = True
 				b.save()
 
 		for module in ["Selling", "Buying"]:
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index d55daa0..59871dd 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -278,7 +278,7 @@
 	sr = frappe.new_doc("Serial No")
 	sr.warehouse = None
 	sr.dont_update_if_missing.append("warehouse")
-	sr.ignore_permissions = True
+	sr.flags.ignore_permissions = True
 
 	sr.serial_no = serial_no
 	sr.item_code = sle.item_code
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index 2c81c4c..48a0587 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -54,7 +54,7 @@
 						"warehouse": self.name,
 						"freeze_account": "No"
 					})
-					ac_doc.ignore_permissions = True
+					ac_doc.flags.ignore_permissions = True
 					ac_doc.insert()
 					msgprint(_("Account head {0} created").format(ac_doc.name))
 
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 55d8a07..a77a629 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -49,7 +49,7 @@
 def make_entry(args, allow_negative_stock=False):
 	args.update({"doctype": "Stock Ledger Entry"})
 	sle = frappe.get_doc(args)
-	sle.ignore_permissions = 1
+	sle.flags.ignore_permissions = 1
 	sle.allow_negative_stock=allow_negative_stock
 	sle.insert()
 	sle.submit()
@@ -153,7 +153,7 @@
 			"item_code": args["item_code"],
 			"warehouse": args["warehouse"],
 		})
-		bin_wrapper.ignore_permissions = 1
+		bin_wrapper.flags.ignore_permissions = 1
 		bin_wrapper.insert()
 
 	frappe.db.sql("""update `tabBin` set valuation_rate=%s, actual_qty=%s,
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index 291999a..ceb0ebf 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -64,11 +64,11 @@
 			"item_code": item_code,
 			"warehouse": warehouse,
 		})
-		bin_obj.ignore_permissions = 1
+		bin_obj.flags.ignore_permissions = 1
 		bin_obj.insert()
 	else:
 		bin_obj = frappe.get_doc('Bin', bin)
-	bin_obj.ignore_permissions = True
+	bin_obj.flags.ignore_permissions = True
 	return bin_obj
 
 def update_bin(args, allow_negative_stock=False):
diff --git a/erpnext/templates/pages/address.py b/erpnext/templates/pages/address.py
index 46dde92..d031494 100644
--- a/erpnext/templates/pages/address.py
+++ b/erpnext/templates/pages/address.py
@@ -53,7 +53,7 @@
 		party_fieldname: party.name,
 		(party_fieldname + "_name"): party.get(party_fieldname + "_name")
 	})
-	doc.ignore_permissions = True
+	doc.flags.ignore_permissions = True
 	doc.save()
 
 	if address_fieldname:
diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py
index df7d82b..3143ba7 100644
--- a/erpnext/utilities/repost_stock.py
+++ b/erpnext/utilities/repost_stock.py
@@ -179,8 +179,8 @@
 		}
 
 		sle_doc = frappe.get_doc(sle_dict)
-		sle_doc.ignore_validate = True
-		sle_doc.ignore_links = True
+		sle_doc.flags.ignore_validate = True
+		sle_doc.flags.ignore_links = True
 		sle_doc.insert()
 
 		args = sle_dict.copy()