Fixed conflict while merging v4 into v5

This commit is contained in:
Nabin Hait 2015-02-10 16:44:00 +05:30
commit 8fa503e177
28 changed files with 52 additions and 53 deletions

View File

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

View File

@ -152,7 +152,7 @@ class SalesInvoice(SellingController):
if d.time_log_batch: if d.time_log_batch:
tlb = frappe.get_doc("Time Log Batch", d.time_log_batch) tlb = frappe.get_doc("Time Log Batch", d.time_log_batch)
tlb.sales_invoice = sales_invoice tlb.sales_invoice = sales_invoice
tlb.ignore_validate_update_after_submit = True tlb.flags.ignore_validate_update_after_submit = True
tlb.save() tlb.save()
def validate_time_logs_are_submitted(self): 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): def make_entry(args, adv_adj, update_outstanding):
args.update({"doctype": "GL Entry"}) args.update({"doctype": "GL Entry"})
gle = frappe.get_doc(args) gle = frappe.get_doc(args)
gle.ignore_permissions = 1 gle.flags.ignore_permissions = 1
gle.insert() gle.insert()
gle.run_method("on_update_with_args", adv_adj, update_outstanding) gle.run_method("on_update_with_args", adv_adj, update_outstanding)
gle.submit() gle.submit()

View File

@ -209,7 +209,7 @@ def update_against_doc(d, jv_obj):
ch.docstatus = 1 ch.docstatus = 1
# will work as update after submit # 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() jv_obj.save()
def remove_against_link_from_jv(ref_type, ref_no, against_field): 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): def set_missing_lead_customer_details(self):
if getattr(self, "customer", None): if getattr(self, "customer", None):
from erpnext.accounts.party import _get_party_details from erpnext.accounts.party import _get_party_details
party_details = _get_party_details(self.customer, party_details = _get_party_details(self.customer, ignore_permissions=self.flags.ignore_permissions)
ignore_permissions=getattr(self, "ignore_permissions", None))
if not self.meta.get_field("sales_team"): if not self.meta.get_field("sales_team"):
party_details.pop("sales_team") party_details.pop("sales_team")

View File

@ -58,7 +58,7 @@ class Employee(Document):
def update_user(self): def update_user(self):
# add employee role if missing # add employee role if missing
user = frappe.get_doc("User", self.user_id) 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"): if "Employee" not in user.get("user_roles"):
user.add_roles("Employee") user.add_roles("Employee")

View File

@ -131,7 +131,7 @@ class BOM(Document):
d.rate = rate d.rate = rate
if self.docstatus == 1: if self.docstatus == 1:
self.ignore_validate_update_after_submit = True self.flags.ignore_validate_update_after_submit = True
self.calculate_cost() self.calculate_cost()
self.save() self.save()
@ -353,7 +353,7 @@ class BOM(Document):
if act_pbom and act_pbom[0][0]: if act_pbom and act_pbom[0][0]:
frappe.throw(_("Cannot deactivate or cancel BOM as it is linked with other BOMs")) frappe.throw(_("Cannot deactivate or cancel BOM as it is linked with other BOMs"))
def validate_operations(self): def validate_operations(self):
if self.with_operations and not self.get('operations'): if self.with_operations and not self.get('operations'):
frappe.throw(_("Operations cannot be left blank.")) 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 "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() pr_doc.submit()
purchase_request_list.append(pr_doc.name) 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"""): for employee in frappe.db.sql_list("""select name from `tabEmployee` where docstatus < 2"""):
try: try:
emp = frappe.get_doc("Employee", employee) emp = frappe.get_doc("Employee", employee)
emp.ignore_mandatory = True emp.flags.ignore_mandatory = True
emp.save() emp.save()
except EmployeeUserDisabledError: except EmployeeUserDisabledError:
pass pass

View File

@ -31,9 +31,9 @@ def execute():
system_settings.language = lang system_settings.language = lang
system_settings.ignore_mandatory = True system_settings.flags.ignore_mandatory = True
system_settings.save() system_settings.save()
global_defaults = frappe.get_doc("Global Defaults") global_defaults = frappe.get_doc("Global Defaults")
global_defaults.ignore_mandatory = True global_defaults.flags.ignore_mandatory = True
global_defaults.save() global_defaults.save()

View File

@ -6,11 +6,11 @@ import frappe
def execute(): def execute():
for d in frappe.db.sql("select name from `tabBOM` where docstatus < 2"): for d in frappe.db.sql("select name from `tabBOM` where docstatus < 2"):
try: try:
document = frappe.get_doc('BOM', d[0]) document = frappe.get_doc('BOM', d[0])
if document.docstatus == 1: if document.docstatus == 1:
document.ignore_validate_update_after_submit = True document.flags.ignore_validate_update_after_submit = True
document.calculate_cost() document.calculate_cost()
document.save() document.save()
except: 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): for d in frappe.db.sql("""select name from `tabBOM` where docstatus < 2""", as_dict=1):
try: try:
bom = frappe.get_doc('BOM', d.name) 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.calculate_cost()
bom.save() bom.save()
frappe.db.commit() frappe.db.commit()

View File

@ -110,7 +110,7 @@ class TimeLog(Document):
tl.hours, self.production_order, operation[0], operation[1])) tl.hours, self.production_order, operation[0], operation[1]))
pro_order = frappe.get_doc("Production Order", self.production_order) 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.update_operation_status()
pro_order.calculate_operating_cost() pro_order.calculate_operating_cost()
pro_order.set_actual_dates() pro_order.set_actual_dates()
@ -129,14 +129,14 @@ class TimeLog(Document):
from `tabTime Log` from `tabTime Log`
where production_order = %s and operation = %s and docstatus=1""", where production_order = %s and operation = %s and docstatus=1""",
(self.production_order, self.operation), as_dict=1)[0] (self.production_order, self.operation), as_dict=1)[0]
def validate_project(self): def validate_project(self):
if self.time_log_for == 'Project': if self.time_log_for == 'Project':
if not self.project: if not self.project:
frappe.throw(_("Project is Mandatory.")) frappe.throw(_("Project is Mandatory."))
if self.time_log_for == "": if self.time_log_for == "":
self.project = None self.project = None
def validate_manufacturing(self): def validate_manufacturing(self):
if self.time_log_for == 'Manufacturing': if self.time_log_for == 'Manufacturing':
if not self.production_order: if not self.production_order:

View File

@ -57,7 +57,7 @@ class TimeLogBatch(Document):
tl = frappe.get_doc("Time Log", d.time_log) tl = frappe.get_doc("Time Log", d.time_log)
tl.time_log_batch = time_log_batch tl.time_log_batch = time_log_batch
tl.sales_invoice = self.sales_invoice tl.sales_invoice = self.sales_invoice
tl.ignore_validate_update_after_submit = True tl.flags.ignore_validate_update_after_submit = True
tl.save() tl.save()
@frappe.whitelist() @frappe.whitelist()

View File

@ -61,7 +61,7 @@ class Customer(TransactionBase):
c.customer = self.name c.customer = self.name
c.customer_name = self.customer_name c.customer_name = self.customer_name
c.is_primary_contact = 1 c.is_primary_contact = 1
c.ignore_permissions = getattr(self, "ignore_permissions", None) c.flags.ignore_permissions = self.flags.ignore_permissions
c.autoname() c.autoname()
if not frappe.db.exists("Contact", c.name): if not frappe.db.exists("Contact", c.name):
c.insert() c.insert()

View File

@ -24,7 +24,7 @@ class Quotation(SellingController):
def has_sales_order(self): def has_sales_order(self):
return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1}) return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1})
def validate_for_items(self): def validate_for_items(self):
chk_dupl_itm = [] chk_dupl_itm = []
for d in self.get('items'): 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 = customer.name
target.customer_name = customer.customer_name target.customer_name = customer.customer_name
target.ignore_pricing_rule = 1 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("set_missing_values")
target.run_method("calculate_taxes_and_totals") 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 from erpnext.selling.doctype.lead.lead import _make_customer
customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions) customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions)
customer = frappe.get_doc(customer_doclist) customer = frappe.get_doc(customer_doclist)
customer.ignore_permissions = ignore_permissions customer.flags.ignore_permissions = ignore_permissions
if quotation[1] == "Shopping Cart": if quotation[1] == "Shopping Cart":
customer.customer_group = frappe.db.get_value("Shopping Cart Settings", None, customer.customer_group = frappe.db.get_value("Shopping Cart Settings", None,
"default_customer_group") "default_customer_group")

View File

@ -102,7 +102,7 @@ class Company(Document):
for d in self.fld_dict.keys(): 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]]) 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: if not account.parent_account:
account.ignore_mandatory = True account.flags.ignore_mandatory = True
account.insert() account.insert()
def set_default_accounts(self): def set_default_accounts(self):
@ -146,10 +146,10 @@ class Company(Document):
for cc in cc_list: for cc in cc_list:
cc.update({"doctype": "Cost Center"}) cc.update({"doctype": "Cost Center"})
cc_doc = frappe.get_doc(cc) 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: if cc.get("cost_center_name") == self.name:
cc_doc.ignore_mandatory = True cc_doc.flags.ignore_mandatory = True
cc_doc.insert() cc_doc.insert()
frappe.db.set(self, "cost_center", _("Main") + " - " + self.abbr) frappe.db.set(self, "cost_center", _("Main") + " - " + self.abbr)

View File

@ -20,7 +20,7 @@ def after_install():
def feature_setup(): def feature_setup():
"""save global defaults and features setup""" """save global defaults and features setup"""
doc = frappe.get_doc("Features Setup", "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 # store value as 1 for all these fields
flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode', 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': _('Execution')},
{'doctype': 'Activity Type', 'activity_type': _('Communication')}, {'doctype': 'Activity Type', 'activity_type': _('Communication')},
{'doctype': 'Activity Type', 'activity_type': _('Manufacturing')}, {'doctype': 'Activity Type', 'activity_type': _('Manufacturing')},
# Industry Type # Industry Type
{'doctype': 'Industry Type', 'industry': _('Accounting')}, {'doctype': 'Industry Type', 'industry': _('Accounting')},
{'doctype': 'Industry Type', 'industry': _('Advertising')}, {'doctype': 'Industry Type', 'industry': _('Advertising')},
@ -203,6 +203,6 @@ def install(country=None):
# ignore mandatory for root # ignore mandatory for root
parent_link_field = ("parent_" + scrub(doc.doctype)) parent_link_field = ("parent_" + scrub(doc.doctype))
if doc.meta.get_field(parent_link_field) and not doc.get(parent_link_field): 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() doc.insert()

View File

@ -41,7 +41,7 @@ def place_order():
if not quotation.get(fieldname): if not quotation.get(fieldname):
throw(_("{0} is required").format(quotation.meta.get_label(fieldname))) throw(_("{0} is required").format(quotation.meta.get_label(fieldname)))
quotation.ignore_permissions = True quotation.flags.ignore_permissions = True
quotation.submit() quotation.submit()
if quotation.lead: if quotation.lead:
@ -53,7 +53,7 @@ def place_order():
for item in sales_order.get("items"): for item in sales_order.get("items"):
item.reserved_warehouse = frappe.db.get_value("Item", item.item_code, "website_warehouse") or None 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.insert()
sales_order.submit() sales_order.submit()
frappe.local.cookie_manager.delete_cookie("cart_count") 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) frappe.delete_doc("Quotation", quotation.name, ignore_permissions=True)
quotation = _get_cart_quotation() quotation = _get_cart_quotation()
else: else:
quotation.ignore_permissions = True quotation.flags.ignore_permissions = True
quotation.save() quotation.save()
set_cart_count(quotation) set_cart_count(quotation)
@ -117,7 +117,7 @@ def update_cart_address(address_fieldname, address_name):
apply_cart_settings(quotation=quotation) apply_cart_settings(quotation=quotation)
quotation.ignore_permissions = True quotation.flags.ignore_permissions = True
quotation.save() quotation.save()
return get_cart_quotation(quotation) 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, qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
"customer": party.name}) "customer": party.name})
qdoc.ignore_permissions = True qdoc.flags.ignore_permissions = True
qdoc.run_method("set_missing_values") qdoc.run_method("set_missing_values")
apply_cart_settings(party, qdoc) 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.customer_name = party.customer_name
contact.mobile_no = mobile_no contact.mobile_no = mobile_no
contact.phone = phone contact.phone = phone
contact.ignore_permissions = True contact.flags.ignore_permissions = True
contact.save() contact.save()
party_doc = frappe.get_doc(party.as_dict()) party_doc = frappe.get_doc(party.as_dict())
party_doc.ignore_permissions = True party_doc.flags.ignore_permissions = True
party_doc.save() party_doc.save()
qdoc = _get_cart_quotation(party) qdoc = _get_cart_quotation(party)
if not qdoc.get("__islocal"): if not qdoc.get("__islocal"):
qdoc.customer_name = company_name or fullname qdoc.customer_name = company_name or fullname
qdoc.run_method("set_missing_lead_customer_details") qdoc.run_method("set_missing_lead_customer_details")
qdoc.ignore_permissions = True qdoc.flags.ignore_permissions = True
qdoc.save() qdoc.save()
def apply_cart_settings(party=None, quotation=None): 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"): if frappe.session.user not in ("Guest", "Administrator"):
lead_doc.ignore_permissions = True lead_doc.flags.ignore_permissions = True
lead_doc.insert() lead_doc.insert()
return lead_doc return lead_doc
@ -303,7 +303,7 @@ def apply_shipping_rule(shipping_rule):
apply_cart_settings(quotation=quotation) apply_cart_settings(quotation=quotation)
quotation.ignore_permissions = True quotation.flags.ignore_permissions = True
quotation.save() quotation.save()
return get_cart_quotation(quotation) return get_cart_quotation(quotation)

View File

@ -216,7 +216,7 @@ class TestMaterialRequest(unittest.TestCase):
mr.update_status('Submitted') mr.update_status('Submitted')
se.ignore_validate_update_after_submit = True se.flags.ignore_validate_update_after_submit = True
se.submit() se.submit()
mr.update_status('Stopped') mr.update_status('Stopped')
self.assertRaises(frappe.InvalidStatusError, se.cancel) self.assertRaises(frappe.InvalidStatusError, se.cancel)

View File

@ -51,7 +51,7 @@ class PriceList(Document):
if self.name == b.get(price_list_fieldname): if self.name == b.get(price_list_fieldname):
b.set(price_list_fieldname, None) b.set(price_list_fieldname, None)
b.ignore_permissions = True b.flags.ignore_permissions = True
b.save() b.save()
for module in ["Selling", "Buying"]: 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 = frappe.new_doc("Serial No")
sr.warehouse = None sr.warehouse = None
sr.dont_update_if_missing.append("warehouse") sr.dont_update_if_missing.append("warehouse")
sr.ignore_permissions = True sr.flags.ignore_permissions = True
sr.serial_no = serial_no sr.serial_no = serial_no
sr.item_code = sle.item_code sr.item_code = sle.item_code

View File

@ -54,7 +54,7 @@ class Warehouse(Document):
"warehouse": self.name, "warehouse": self.name,
"freeze_account": "No" "freeze_account": "No"
}) })
ac_doc.ignore_permissions = True ac_doc.flags.ignore_permissions = True
ac_doc.insert() ac_doc.insert()
msgprint(_("Account head {0} created").format(ac_doc.name)) 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, allow_negative_stock=False): def make_entry(args, allow_negative_stock=False):
args.update({"doctype": "Stock Ledger Entry"}) args.update({"doctype": "Stock Ledger Entry"})
sle = frappe.get_doc(args) sle = frappe.get_doc(args)
sle.ignore_permissions = 1 sle.flags.ignore_permissions = 1
sle.allow_negative_stock=allow_negative_stock sle.allow_negative_stock=allow_negative_stock
sle.insert() sle.insert()
sle.submit() sle.submit()
@ -153,7 +153,7 @@ def update_entries_after(args, allow_zero_rate=False, allow_negative_stock=False
"item_code": args["item_code"], "item_code": args["item_code"],
"warehouse": args["warehouse"], "warehouse": args["warehouse"],
}) })
bin_wrapper.ignore_permissions = 1 bin_wrapper.flags.ignore_permissions = 1
bin_wrapper.insert() bin_wrapper.insert()
frappe.db.sql("""update `tabBin` set valuation_rate=%s, actual_qty=%s, 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, "item_code": item_code,
"warehouse": warehouse, "warehouse": warehouse,
}) })
bin_obj.ignore_permissions = 1 bin_obj.flags.ignore_permissions = 1
bin_obj.insert() bin_obj.insert()
else: else:
bin_obj = frappe.get_doc('Bin', bin) bin_obj = frappe.get_doc('Bin', bin)
bin_obj.ignore_permissions = True bin_obj.flags.ignore_permissions = True
return bin_obj return bin_obj
def update_bin(args, allow_negative_stock=False): def update_bin(args, allow_negative_stock=False):

View File

@ -53,7 +53,7 @@ def save_address(fields, address_fieldname=None):
party_fieldname: party.name, party_fieldname: party.name,
(party_fieldname + "_name"): party.get(party_fieldname + "_name") (party_fieldname + "_name"): party.get(party_fieldname + "_name")
}) })
doc.ignore_permissions = True doc.flags.ignore_permissions = True
doc.save() doc.save()
if address_fieldname: 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 = frappe.get_doc(sle_dict)
sle_doc.ignore_validate = True sle_doc.flags.ignore_validate = True
sle_doc.ignore_links = True sle_doc.flags.ignore_links = True
sle_doc.insert() sle_doc.insert()
args = sle_dict.copy() args = sle_dict.copy()