Moved flags like ignore_mandatory, ignore_validate etc to doc.flags

This commit is contained in:
Anand Doshi 2015-02-10 14:41:27 +05:30
parent 2813f38c5a
commit 6dfd430a2f
29 changed files with 54 additions and 53 deletions

View File

@ -40,7 +40,7 @@ def create_charts(chart_name, company):
})
if root_account:
account.ignore_mandatory = True
account.flags.ignore_mandatory = True
account.insert()

View File

@ -152,7 +152,7 @@ class SalesInvoice(SellingController):
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):

View File

@ -81,7 +81,7 @@ def save_entries(gl_map, adv_adj, update_outstanding):
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()

View File

@ -209,7 +209,7 @@ def update_against_doc(d, jv_obj):
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):

View File

@ -48,8 +48,7 @@ class SellingController(StockController):
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")

View File

@ -58,7 +58,7 @@ class Employee(Document):
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")

View File

@ -131,7 +131,7 @@ class BOM(Document):
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 @@ class BOM(Document):
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."))

View File

@ -394,7 +394,7 @@ class ProductionPlanningTool(Document):
"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)

View File

@ -28,7 +28,7 @@ def update_hr_permissions():
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

View File

@ -31,9 +31,9 @@ def execute():
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()

View File

@ -6,11 +6,11 @@ import frappe
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
pass

View File

@ -9,7 +9,7 @@ def execute():
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()

View File

@ -110,7 +110,7 @@ class TimeLog(Document):
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 @@ class TimeLog(Document):
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:

View File

@ -57,7 +57,7 @@ class TimeLogBatch(Document):
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()

View File

@ -61,7 +61,7 @@ class Customer(TransactionBase):
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()

View File

@ -24,7 +24,7 @@ class Quotation(SellingController):
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 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
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 @@ def _make_customer(source_name, ignore_permissions=False):
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")

View File

@ -102,7 +102,7 @@ class Company(Document):
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 @@ class Company(Document):
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)

View File

@ -20,7 +20,7 @@ def after_install():
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',

View File

@ -136,7 +136,7 @@ def install(country=None):
{'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 @@ def install(country=None):
# 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()

View File

@ -41,7 +41,7 @@ def place_order():
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 @@ def place_order():
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 @@ def update_cart(item_code, qty, with_doc):
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 @@ def update_cart_address(address_fieldname, address_name):
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 @@ def _get_cart_quotation(party=None):
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 @@ def update_party(fullname, company_name=None, mobile_no=None, phone=None):
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 @@ def get_lead_or_customer():
})
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 @@ def apply_shipping_rule(shipping_rule):
apply_cart_settings(quotation=quotation)
quotation.ignore_permissions = True
quotation.flags.ignore_permissions = True
quotation.save()
return get_cart_quotation(quotation)

View File

@ -9,6 +9,8 @@ def boot_session(bootinfo):
"""boot session - send website info if guest"""
import frappe
print "erpnext boot session"
bootinfo.custom_css = frappe.db.get_value('Style Settings', None, 'custom_css') or ''
bootinfo.website_settings = frappe.get_doc('Website Settings')

View File

@ -216,7 +216,7 @@ class TestMaterialRequest(unittest.TestCase):
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)

View File

@ -51,7 +51,7 @@ class PriceList(Document):
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"]:

View File

@ -278,7 +278,7 @@ def make_serial_no(serial_no, sle):
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

View File

@ -54,7 +54,7 @@ class Warehouse(Document):
"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))

View File

@ -49,7 +49,7 @@ def set_as_cancel(voucher_type, voucher_no):
def make_entry(args):
args.update({"doctype": "Stock Ledger Entry"})
sle = frappe.get_doc(args)
sle.ignore_permissions = 1
sle.flags.ignore_permissions = 1
sle.insert()
sle.submit()
return sle.name
@ -149,7 +149,7 @@ def update_entries_after(args, allow_zero_rate=False, verbose=1):
"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,

View File

@ -64,11 +64,11 @@ def get_bin(item_code, warehouse):
"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):

View File

@ -53,7 +53,7 @@ def save_address(fields, address_fieldname=None):
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:

View File

@ -179,8 +179,8 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin
}
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()