mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-14 02:31:21 +00:00
refactor: simplify conditional logic
Command: `sourcery review --fix --enable de-morgan .`
This commit is contained in:
@@ -185,7 +185,10 @@ class AuthorizationControl(TransactionBase):
|
||||
|
||||
# Remove user specific rules from global authorization rules
|
||||
for r in based_on:
|
||||
if r in final_based_on and not r in ["Itemwise Discount", "Item Group wise Discount"]:
|
||||
if r in final_based_on and r not in [
|
||||
"Itemwise Discount",
|
||||
"Item Group wise Discount",
|
||||
]:
|
||||
final_based_on.remove(r)
|
||||
|
||||
# Check for authorization set on particular roles
|
||||
@@ -213,7 +216,10 @@ class AuthorizationControl(TransactionBase):
|
||||
|
||||
# Remove role specific rules from global authorization rules
|
||||
for r in based_on:
|
||||
if r in final_based_on and not r in ["Itemwise Discount", "Item Group wise Discount"]:
|
||||
if r in final_based_on and r not in [
|
||||
"Itemwise Discount",
|
||||
"Item Group wise Discount",
|
||||
]:
|
||||
final_based_on.remove(r)
|
||||
|
||||
# Check for global authorization
|
||||
|
||||
@@ -44,7 +44,7 @@ class Department(NestedSet):
|
||||
|
||||
def before_rename(self, old, new, merge=False):
|
||||
# renaming consistency with abbreviation
|
||||
if not frappe.get_cached_value("Company", self.company, "abbr") in new:
|
||||
if frappe.get_cached_value("Company", self.company, "abbr") not in new:
|
||||
new = get_abbreviated_name(new, self.company)
|
||||
|
||||
return new
|
||||
|
||||
@@ -689,7 +689,7 @@ class EmailDigest(Document):
|
||||
]
|
||||
|
||||
def get_root_type_accounts(self, root_type):
|
||||
if not root_type in self._accounts:
|
||||
if root_type not in self._accounts:
|
||||
self._accounts[root_type] = [
|
||||
d.name
|
||||
for d in frappe.db.get_all(
|
||||
|
||||
@@ -187,7 +187,7 @@ class Employee(NestedSet):
|
||||
throw(_("Please enter relieving date."))
|
||||
|
||||
def validate_for_enabled_user_id(self, enabled):
|
||||
if not self.status == "Active":
|
||||
if self.status != "Active":
|
||||
return
|
||||
|
||||
if enabled is None:
|
||||
|
||||
@@ -197,7 +197,7 @@ def add_standard_navbar_items():
|
||||
|
||||
for item in erpnext_navbar_items:
|
||||
current_labels = [item.get("item_label") for item in current_navbar_items]
|
||||
if not item.get("item_label") in current_labels:
|
||||
if item.get("item_label") not in current_labels:
|
||||
navbar_settings.append("help_dropdown", item)
|
||||
|
||||
for item in current_navbar_items:
|
||||
|
||||
Reference in New Issue
Block a user