From 694ae81618a3620624d8429c05438c7be0abdcc5 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 14:40:56 +0530 Subject: [PATCH 01/11] fix: remove bare excepts --- erpnext/accounts/deferred_revenue.py | 4 ++-- .../accounts/doctype/pricing_rule/utils.py | 2 +- .../process_statement_of_accounts.py | 2 +- erpnext/accounts/party.py | 2 +- erpnext/assets/doctype/asset/asset.py | 2 +- .../social_media_post/social_media_post.py | 10 +++++----- erpnext/demo/demo.py | 2 +- .../course_scheduling_tool.py | 2 +- erpnext/education/utils.py | 2 +- .../tally_migration/tally_migration.py | 20 +++++++++---------- .../healthcare/doctype/lab_test/lab_test.py | 2 +- .../daily_work_summary/daily_work_summary.py | 2 +- .../leave_control_panel.py | 2 +- .../doctype/membership/membership.py | 6 +++--- ...efaults_to_child_table_for_multicompany.py | 2 +- .../v12_0/update_is_cancelled_field.py | 2 +- ..._from_payroll_period_to_income_tax_slab.py | 4 ++-- .../v4_2/update_requested_and_ordered_qty.py | 2 +- erpnext/setup/setup_wizard/setup_wizard.py | 2 +- erpnext/setup/utils.py | 2 +- .../doctype/delivery_note/delivery_note.py | 2 +- erpnext/stock/doctype/serial_no/serial_no.py | 2 +- erpnext/stock/reorder_item.py | 2 +- erpnext/stock/stock_balance.py | 4 ++-- 24 files changed, 42 insertions(+), 42 deletions(-) diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py index 0c81d83ed8e8..173b1eee9a5c 100644 --- a/erpnext/accounts/deferred_revenue.py +++ b/erpnext/accounts/deferred_revenue.py @@ -359,7 +359,7 @@ def make_gl_entries(doc, credit_account, debit_account, against, try: make_gl_entries(gl_entries, cancel=(doc.docstatus == 2), merge_entries=True) frappe.db.commit() - except: + except Exception: frappe.db.rollback() traceback = frappe.get_traceback() frappe.log_error(message=traceback) @@ -430,7 +430,7 @@ def book_revenue_via_journal_entry(doc, credit_account, debit_account, against, if submit: journal_entry.submit() - except: + except Exception: frappe.db.rollback() traceback = frappe.get_traceback() frappe.log_error(message=traceback) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 5467cb0bc5b0..6f24587ac7be 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -81,7 +81,7 @@ def filter_pricing_rule_based_on_condition(pricing_rules, doc=None): try: if frappe.safe_eval(pricing_rule.condition, None, doc.as_dict()): filtered_pricing_rules.append(pricing_rule) - except: + except Exception: pass else: filtered_pricing_rules.append(pricing_rule) diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py index a12ea4033df5..30b1edcec8dc 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py @@ -158,7 +158,7 @@ def get_recipients_and_cc(customer, doc): if doc.cc_to != '': try: cc=[frappe.get_value('User', doc.cc_to, 'email')] - except: + except Exception: pass return recipients, cc diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index de7dde9dd1fb..b78ea4285095 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -648,7 +648,7 @@ def get_default_contact(doctype, name): if out: try: return out[0][0] - except: + except Exception: return None else: return None diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 7afb43b36c83..b292109fb72d 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -546,7 +546,7 @@ def get_cwip_account(self, cwip_enabled=False): cwip_account = None try: cwip_account = get_asset_account("capital_work_in_progress_account", self.name, self.asset_category, self.company) - except: + except Exception: # if no cwip account found in category or company and "cwip is enabled" then raise else silently pass if cwip_enabled: raise diff --git a/erpnext/crm/doctype/social_media_post/social_media_post.py b/erpnext/crm/doctype/social_media_post/social_media_post.py index 95320bff5352..8e441edba857 100644 --- a/erpnext/crm/doctype/social_media_post/social_media_post.py +++ b/erpnext/crm/doctype/social_media_post/social_media_post.py @@ -26,7 +26,7 @@ def submit(self): if self.scheduled_time: self.post_status = "Scheduled" super(SocialMediaPost, self).submit() - + def on_cancel(self): self.db_set('post_status', 'Cancelled') @@ -35,11 +35,11 @@ def delete_post(self): if self.twitter and self.twitter_post_id: twitter = frappe.get_doc("Twitter Settings") twitter.delete_tweet(self.twitter_post_id) - + if self.linkedin and self.linkedin_post_id: linkedin = frappe.get_doc("LinkedIn Settings") linkedin.delete_post(self.linkedin_post_id) - + self.db_set('post_status', 'Deleted') @frappe.whitelist() @@ -51,7 +51,7 @@ def get_post(self): if self.twitter and self.twitter_post_id: twitter = frappe.get_doc("Twitter Settings") response['twitter'] = twitter.get_tweet(self.twitter_post_id) - + return response @frappe.whitelist() @@ -67,7 +67,7 @@ def post(self): self.db_set("linkedin_post_id", linkedin_post.headers['X-RestLi-Id']) self.db_set("post_status", "Posted") - except: + except Exception: self.db_set("post_status", "Error") title = _("Error while POSTING {0}").format(self.name) frappe.log_error(message=frappe.get_traceback(), title=title) diff --git a/erpnext/demo/demo.py b/erpnext/demo/demo.py index e89b6895a086..a4e4220c3a9d 100644 --- a/erpnext/demo/demo.py +++ b/erpnext/demo/demo.py @@ -88,7 +88,7 @@ def simulate(domain='Manufacturing', days=100): elif domain=='Education': edu.work() - except: + except Exception: frappe.db.set_global('demo_last_date', current_date) raise finally: diff --git a/erpnext/education/doctype/course_scheduling_tool/course_scheduling_tool.py b/erpnext/education/doctype/course_scheduling_tool/course_scheduling_tool.py index 0f2ea96a583b..66587f055f6b 100644 --- a/erpnext/education/doctype/course_scheduling_tool/course_scheduling_tool.py +++ b/erpnext/education/doctype/course_scheduling_tool/course_scheduling_tool.py @@ -95,7 +95,7 @@ def delete_course_schedule(self, rescheduled, reschedule_errors): if self.day == calendar.day_name[getdate(d.schedule_date).weekday()]: frappe.delete_doc("Course Schedule", d.name) rescheduled.append(d.name) - except: + except Exception: reschedule_errors.append(d.name) return rescheduled, reschedule_errors diff --git a/erpnext/education/utils.py b/erpnext/education/utils.py index 3070e6a3e8a3..7ce821225375 100644 --- a/erpnext/education/utils.py +++ b/erpnext/education/utils.py @@ -219,7 +219,7 @@ def get_quiz(quiz_name, course): try: quiz = frappe.get_doc("Quiz", quiz_name) questions = quiz.get_questions() - except: + except Exception: frappe.throw(_("Quiz {0} does not exist").format(quiz_name), frappe.DoesNotExistError) return None diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py index 907a22333b79..77dba8beea21 100644 --- a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py +++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py @@ -266,7 +266,7 @@ def get_stock_items_uoms(collection): self.is_master_data_processed = 1 - except: + except Exception: self.publish("Process Master Data", _("Process Failed"), -1, 5) self.log() @@ -302,14 +302,14 @@ def create_parties_and_addresses(parties_file_url, addresses_file_url): try: party_doc = frappe.get_doc(party) party_doc.insert() - except: + except Exception: self.log(party_doc) addresses_file = frappe.get_doc("File", {"file_url": addresses_file_url}) for address in json.loads(addresses_file.get_content()): try: address_doc = frappe.get_doc(address) address_doc.insert(ignore_mandatory=True) - except: + except Exception: self.log(address_doc) def create_items_uoms(items_file_url, uoms_file_url): @@ -319,7 +319,7 @@ def create_items_uoms(items_file_url, uoms_file_url): try: uom_doc = frappe.get_doc(uom) uom_doc.insert() - except: + except Exception: self.log(uom_doc) items_file = frappe.get_doc("File", {"file_url": items_file_url}) @@ -327,7 +327,7 @@ def create_items_uoms(items_file_url, uoms_file_url): try: item_doc = frappe.get_doc(item) item_doc.insert() - except: + except Exception: self.log(item_doc) try: @@ -346,7 +346,7 @@ def create_items_uoms(items_file_url, uoms_file_url): self.is_master_data_imported = 1 frappe.db.commit() - except: + except Exception: self.publish("Import Master Data", _("Process Failed"), -1, 5) frappe.db.rollback() self.log() @@ -370,7 +370,7 @@ def get_vouchers(collection): if processed_voucher: vouchers.append(processed_voucher) frappe.db.commit() - except: + except Exception: frappe.db.rollback() self.log(voucher) return vouchers @@ -494,7 +494,7 @@ def get_party(party): self.is_day_book_data_processed = 1 - except: + except Exception: self.publish("Process Day Book Data", _("Process Failed"), -1, 5) self.log() @@ -564,7 +564,7 @@ def create_price_list(): is_last = True frappe.enqueue_doc(self.doctype, self.name, "_import_vouchers", queue="long", timeout=3600, start=index+1, total=total, is_last=is_last) - except: + except Exception: self.log() finally: @@ -583,7 +583,7 @@ def _import_vouchers(self, start, total, is_last=False): voucher_doc.submit() self.publish("Importing Vouchers", _("{} of {}").format(index, total), index, total) frappe.db.commit() - except: + except Exception: frappe.db.rollback() self.log(voucher_doc) diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.py b/erpnext/healthcare/doctype/lab_test/lab_test.py index 74495a859105..03e16f557555 100644 --- a/erpnext/healthcare/doctype/lab_test/lab_test.py +++ b/erpnext/healthcare/doctype/lab_test/lab_test.py @@ -48,7 +48,7 @@ def set_secondary_uom_result(self): if item.result_value and item.secondary_uom and item.conversion_factor: try: item.secondary_uom_result = float(item.result_value) * float(item.conversion_factor) - except: + except Exception: item.secondary_uom_result = '' frappe.msgprint(_('Row #{0}: Result for Secondary UOM not calculated').format(item.idx), title = _('Warning')) diff --git a/erpnext/hr/doctype/daily_work_summary/daily_work_summary.py b/erpnext/hr/doctype/daily_work_summary/daily_work_summary.py index 1cc23812f75f..76c7a14693b6 100644 --- a/erpnext/hr/doctype/daily_work_summary/daily_work_summary.py +++ b/erpnext/hr/doctype/daily_work_summary/daily_work_summary.py @@ -82,7 +82,7 @@ def get_message_details(self): crop=True ) d.image = thumbnail_image - except: + except Exception: d.image = original_image if d.sender in did_not_reply: diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py index 74014020fc62..642ab6a81325 100644 --- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py +++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py @@ -51,7 +51,7 @@ def allocate_leave(self): la.docstatus = 1 la.save() leave_allocated_for.append(d[0]) - except: + except Exception: pass if leave_allocated_for: msgprint(_("Leaves Allocated Successfully for {0}").format(comma_and(leave_allocated_for))) diff --git a/erpnext/non_profit/doctype/membership/membership.py b/erpnext/non_profit/doctype/membership/membership.py index b584116df3cc..9eb973bfee6e 100644 --- a/erpnext/non_profit/doctype/membership/membership.py +++ b/erpnext/non_profit/doctype/membership/membership.py @@ -207,7 +207,7 @@ def get_member_based_on_subscription(subscription_id, email=None, customer_id=No try: return frappe.get_doc("Member", members[0]["name"]) - except: + except Exception: return None @@ -393,7 +393,7 @@ def notify_failure(log): """.format(get_link_to_form("Error Log", log.name)) sendmail_to_system_managers("[Important] [ERPNext] Razorpay membership webhook failed , please check.", content) - except: + except Exception: pass @@ -402,7 +402,7 @@ def get_plan_from_razorpay_id(plan_id): try: return plan[0]["name"] - except: + except Exception: return None diff --git a/erpnext/patches/v11_0/move_item_defaults_to_child_table_for_multicompany.py b/erpnext/patches/v11_0/move_item_defaults_to_child_table_for_multicompany.py index 6da70b4ce386..83617f77fd00 100644 --- a/erpnext/patches/v11_0/move_item_defaults_to_child_table_for_multicompany.py +++ b/erpnext/patches/v11_0/move_item_defaults_to_child_table_for_multicompany.py @@ -30,7 +30,7 @@ def execute(): buying_cost_center, selling_cost_center, expense_account, income_account, default_supplier FROM `tabItem`; ''', companies[0].name) - except: + except Exception: pass else: item_details = frappe.db.sql(""" SELECT name, default_warehouse, diff --git a/erpnext/patches/v12_0/update_is_cancelled_field.py b/erpnext/patches/v12_0/update_is_cancelled_field.py index 4bbec44aa429..f69dcc95794a 100644 --- a/erpnext/patches/v12_0/update_is_cancelled_field.py +++ b/erpnext/patches/v12_0/update_is_cancelled_field.py @@ -11,5 +11,5 @@ def execute(): frappe.reload_doc("stock", "doctype", "stock_ledger_entry") frappe.reload_doc("stock", "doctype", "serial_no") - except: + except Exception: pass diff --git a/erpnext/patches/v13_0/move_tax_slabs_from_payroll_period_to_income_tax_slab.py b/erpnext/patches/v13_0/move_tax_slabs_from_payroll_period_to_income_tax_slab.py index 1a91d218ba39..426292067ab5 100644 --- a/erpnext/patches/v13_0/move_tax_slabs_from_payroll_period_to_income_tax_slab.py +++ b/erpnext/patches/v13_0/move_tax_slabs_from_payroll_period_to_income_tax_slab.py @@ -86,7 +86,7 @@ def execute(): try: employee_other_income.submit() migrated.append([proof.employee, proof.payroll_period]) - except: + except Exception: pass if not frappe.db.table_exists("Employee Tax Exemption Declaration"): @@ -108,5 +108,5 @@ def execute(): try: employee_other_income.submit() - except: + except Exception: pass diff --git a/erpnext/patches/v4_2/update_requested_and_ordered_qty.py b/erpnext/patches/v4_2/update_requested_and_ordered_qty.py index 7bb49e64dfe5..8a31c73e1e42 100644 --- a/erpnext/patches/v4_2/update_requested_and_ordered_qty.py +++ b/erpnext/patches/v4_2/update_requested_and_ordered_qty.py @@ -20,5 +20,5 @@ def execute(): }) if count % 200 == 0: frappe.db.commit() - except: + except Exception: frappe.db.rollback() diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py index f63d2695aa34..9275d1b383da 100644 --- a/erpnext/setup/setup_wizard/setup_wizard.py +++ b/erpnext/setup/setup_wizard/setup_wizard.py @@ -106,7 +106,7 @@ def fin(args): def make_sample_data(domains): try: sample_data.make_sample_data(domains) - except: + except Exception: # clear message if frappe.message_log: frappe.message_log.pop() diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py index e49259e1a250..409f776a4e02 100644 --- a/erpnext/setup/utils.py +++ b/erpnext/setup/utils.py @@ -109,7 +109,7 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No value = response.json()["result"] cache.setex(name=key, time=21600, value=flt(value)) return flt(value) - except: + except Exception: frappe.log_error(title="Get Exchange Rate") frappe.msgprint(_("Unable to find exchange rate for {0} to {1} for key date {2}. Please create a Currency Exchange record manually").format(from_currency, to_currency, transaction_date)) return 0.0 diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index f99a01b8202b..9113b59ce071 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -331,7 +331,7 @@ def make_return_invoice(self): credit_note_link = frappe.utils.get_link_to_form('Sales Invoice', return_invoice.name) frappe.msgprint(_("Credit Note {0} has been created automatically").format(credit_note_link)) - except: + except Exception: frappe.throw(_("Could not create Credit Note automatically, please uncheck 'Issue Credit Note' and submit again")) def update_billed_amount_based_on_so(so_detail, update_modified=True): diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index 70312bc543b5..319597f83993 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -573,7 +573,7 @@ def auto_fetch_serial_number(qty, item_code, warehouse, posting_date=None, batch if batch_nos: try: filters["batch_no"] = json.loads(batch_nos) if (type(json.loads(batch_nos)) == list) else [json.loads(batch_nos)] - except: + except Exception: filters["batch_no"] = [batch_nos] if posting_date: diff --git a/erpnext/stock/reorder_item.py b/erpnext/stock/reorder_item.py index 4c721acdc122..4d8dcc68d258 100644 --- a/erpnext/stock/reorder_item.py +++ b/erpnext/stock/reorder_item.py @@ -166,7 +166,7 @@ def _log_exception(): mr.submit() mr_list.append(mr) - except: + except Exception: _log_exception() if mr_list: diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py index 8917bfeae4f9..e5819d6bef79 100644 --- a/erpnext/stock/stock_balance.py +++ b/erpnext/stock/stock_balance.py @@ -29,7 +29,7 @@ def repost(only_actual=False, allow_negative_stock=False, allow_zero_rate=False, try: repost_stock(d[0], d[1], allow_zero_rate, only_actual, only_bin, allow_negative_stock) frappe.db.commit() - except: + except Exception: frappe.db.rollback() if allow_negative_stock: @@ -247,5 +247,5 @@ def reset_serial_no_status_and_warehouse(serial_nos=None): sr.via_stock_ledger = True sr.save() - except: + except Exception: pass From 010060d92e80a2394e50d3cba87ef6ca948d6906 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 14:49:47 +0530 Subject: [PATCH 02/11] chore: correct indentation --- .../employee_leave_balance_summary.py | 2 +- .../report/bom_stock_calculated/bom_stock_calculated.py | 2 +- erpnext/utilities/product.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py b/erpnext/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py index e86fa2b1c42c..0fb3f5eebaa5 100644 --- a/erpnext/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py +++ b/erpnext/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py @@ -65,7 +65,7 @@ def get_data(filters, leave_types): for leave_type in leave_types: remaining = 0 if leave_type in available_leave["leave_allocation"]: - # opening balance + # opening balance remaining = available_leave["leave_allocation"][leave_type]['remaining_leaves'] row += [remaining] diff --git a/erpnext/manufacturing/report/bom_stock_calculated/bom_stock_calculated.py b/erpnext/manufacturing/report/bom_stock_calculated/bom_stock_calculated.py index ffd9242e1b86..d7ebfd6b82bc 100644 --- a/erpnext/manufacturing/report/bom_stock_calculated/bom_stock_calculated.py +++ b/erpnext/manufacturing/report/bom_stock_calculated/bom_stock_calculated.py @@ -7,7 +7,7 @@ from frappe.utils.data import comma_and def execute(filters=None): -# if not filters: filters = {} + # if not filters: filters = {} columns = get_columns() summ_data = [] diff --git a/erpnext/utilities/product.py b/erpnext/utilities/product.py index 70b41767d6d2..f6c53cacd9e7 100644 --- a/erpnext/utilities/product.py +++ b/erpnext/utilities/product.py @@ -127,7 +127,7 @@ def get_price(item_code, price_list, customer_group, company, qty=1): return price_obj def get_non_stock_item_status(item_code, item_warehouse_field): -#if item belongs to product bundle, check if bundle items are in stock + #if item belongs to product bundle, check if bundle items are in stock if frappe.db.exists("Product Bundle", item_code): items = frappe.get_doc("Product Bundle", item_code).get_all_children() bundle_warehouse = frappe.db.get_value('Item', item_code, item_warehouse_field) From 9fec0a5c68cf9f8187babe3665973f794392311e Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 14:53:21 +0530 Subject: [PATCH 03/11] refactor: itemgetter instead of assigned lambda --- erpnext/stock/report/stock_ageing/stock_ageing.py | 3 ++- erpnext/stock/report/stock_balance/stock_balance.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/report/stock_ageing/stock_ageing.py b/erpnext/stock/report/stock_ageing/stock_ageing.py index 8a9f0a5e583b..11d50cd12a50 100644 --- a/erpnext/stock/report/stock_ageing/stock_ageing.py +++ b/erpnext/stock/report/stock_ageing/stock_ageing.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe from frappe import _ +from operator import itemgetter from frappe.utils import date_diff, flt, cint from six import iteritems from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos @@ -12,7 +13,7 @@ def execute(filters=None): columns = get_columns(filters) item_details = get_fifo_queue(filters) to_date = filters["to_date"] - _func = lambda x: x[1] + _func = itemgetter(1) data = [] for item, item_dict in iteritems(item_details): diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py index fc3d719a7809..f530ac240eea 100644 --- a/erpnext/stock/report/stock_balance/stock_balance.py +++ b/erpnext/stock/report/stock_balance/stock_balance.py @@ -2,6 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals +from operator import itemgetter import frappe, erpnext from frappe import _ from frappe.utils import flt, cint, getdate, now, date_diff @@ -44,7 +45,7 @@ def execute(filters=None): data = [] conversion_factors = {} - _func = lambda x: x[1] + _func = itemgetter(1) for (company, item, warehouse) in sorted(iwb_map): if item_map.get(item): From 2d62c500c477fe7624426b807dd9b23c455c6e47 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 15:02:06 +0530 Subject: [PATCH 04/11] fix: undefined variables --- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 9 ++++----- .../appointment_booking_settings.py | 4 ++-- erpnext/hr/report/vehicle_expenses/vehicle_expenses.py | 2 -- .../sanctioned_loan_amount/sanctioned_loan_amount.py | 1 + 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 4903c50e17b3..ccfb29f35562 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -203,13 +203,13 @@ def apply_pricing_rule(args, doc=None): serialized_items = dict() for item_code, val in query_items: serialized_items.setdefault(item_code, val) - + for item in item_list: args_copy = copy.deepcopy(args) args_copy.update(item) data = get_pricing_rule_for_item(args_copy, item.get('price_list_rate'), doc=doc) out.append(data) - + if serialized_items.get(item.get('item_code')) and not item.get("serial_no") and set_serial_nos_based_on_fifo and not args.get('is_return'): out[0].update(get_serial_no_for_item(args_copy)) @@ -315,9 +315,8 @@ def update_args_for_pricing_rule(args): if not (args.item_group and args.brand): try: args.item_group, args.brand = frappe.get_cached_value("Item", args.item_code, ["item_group", "brand"]) - except TypeError: - # invalid item_code - return item_details + except frappe.DoesNotExistError: + return if not args.item_group: frappe.throw(_("Item Group not mentioned in item master for item {0}").format(args.item_code)) diff --git a/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.py b/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.py index 27f14b1dbd89..ad781d685996 100644 --- a/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.py +++ b/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.py @@ -28,10 +28,10 @@ def validate_availability_of_slots(self): to_time = datetime.datetime.strptime( self.min_date+record.to_time, self.format_string) timedelta = to_time-from_time - self.validate_from_and_to_time(from_time, to_time) + self.validate_from_and_to_time(from_time, to_time, record) self.duration_is_divisible(from_time, to_time) - def validate_from_and_to_time(self, from_time, to_time): + def validate_from_and_to_time(self, from_time, to_time, record): if from_time > to_time: err_msg = _('From Time cannot be later than To Time for {0}').format(record.day_of_week) frappe.throw(_(err_msg)) diff --git a/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py b/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py index d847cbb5c9b2..c05355918607 100644 --- a/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py +++ b/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py @@ -96,8 +96,6 @@ def get_columns(): } ] - return columns - def get_vehicle_log_data(filters): start_date, end_date = get_period_dates(filters) diff --git a/erpnext/loan_management/doctype/sanctioned_loan_amount/sanctioned_loan_amount.py b/erpnext/loan_management/doctype/sanctioned_loan_amount/sanctioned_loan_amount.py index 74a131015b55..7ed838d4e133 100644 --- a/erpnext/loan_management/doctype/sanctioned_loan_amount/sanctioned_loan_amount.py +++ b/erpnext/loan_management/doctype/sanctioned_loan_amount/sanctioned_loan_amount.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document class SanctionedLoanAmount(Document): From 7d9819f35241501c47336dbbb0b1009d7409bb18 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 15:24:25 +0530 Subject: [PATCH 05/11] fix: remove duplicate imports --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 1 - erpnext/agriculture/doctype/disease/disease.py | 1 - erpnext/agriculture/doctype/soil_texture/soil_texture.py | 1 - erpnext/agriculture/doctype/water_analysis/water_analysis.py | 1 - erpnext/assets/doctype/asset/asset.py | 2 +- .../healthcare/doctype/patient_encounter/patient_encounter.py | 1 - erpnext/hr/doctype/leave_period/leave_period.py | 2 +- .../doctype/loan_interest_accrual/loan_interest_accrual.py | 2 +- .../loan_management/doctype/loan_repayment/loan_repayment.py | 3 +-- erpnext/selling/page/point_of_sale/point_of_sale.py | 4 ++-- .../service_level_agreement/service_level_agreement.py | 1 - 11 files changed, 6 insertions(+), 13 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index fe3ed1670d2b..93546c3be742 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -24,7 +24,6 @@ from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import get_party_tax_withholding_details from frappe.model.utils import get_fetch_values from frappe.contacts.doctype.address.address import get_address_display -from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import get_party_tax_withholding_details from erpnext.healthcare.utils import manage_invoice_submit_cancel diff --git a/erpnext/agriculture/doctype/disease/disease.py b/erpnext/agriculture/doctype/disease/disease.py index affa57046e55..8e6ceb4b1dea 100644 --- a/erpnext/agriculture/doctype/disease/disease.py +++ b/erpnext/agriculture/doctype/disease/disease.py @@ -6,7 +6,6 @@ import frappe from frappe import _ from frappe.model.document import Document -from frappe import _ class Disease(Document): def validate(self): diff --git a/erpnext/agriculture/doctype/soil_texture/soil_texture.py b/erpnext/agriculture/doctype/soil_texture/soil_texture.py index 209b2c8598f0..d7a5f0917939 100644 --- a/erpnext/agriculture/doctype/soil_texture/soil_texture.py +++ b/erpnext/agriculture/doctype/soil_texture/soil_texture.py @@ -7,7 +7,6 @@ from frappe import _ from frappe.model.document import Document from frappe.utils import flt, cint -from frappe import _ class SoilTexture(Document): soil_edit_order = [2, 1, 0] diff --git a/erpnext/agriculture/doctype/water_analysis/water_analysis.py b/erpnext/agriculture/doctype/water_analysis/water_analysis.py index cb2691d45556..ece07002868d 100644 --- a/erpnext/agriculture/doctype/water_analysis/water_analysis.py +++ b/erpnext/agriculture/doctype/water_analysis/water_analysis.py @@ -6,7 +6,6 @@ import frappe from frappe import _ from frappe.model.document import Document -from frappe import _ class WaterAnalysis(Document): @frappe.whitelist() diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index b292109fb72d..f1bf31a8e699 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -11,7 +11,7 @@ from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account from erpnext.assets.doctype.asset.depreciation \ import get_disposal_account_and_cost_center, get_depreciation_accounts -from erpnext.accounts.general_ledger import make_gl_entries, make_reverse_gl_entries +from erpnext.accounts.general_ledger import make_reverse_gl_entries from erpnext.accounts.utils import get_account_currency from erpnext.controllers.accounts_controller import AccountsController diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py index 7a745ae468e4..c935274070f3 100644 --- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py +++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py @@ -7,7 +7,6 @@ from frappe import _ from frappe.model.document import Document from frappe.utils import cstr, getdate, add_days -from frappe import _ from frappe.model.mapper import get_mapped_doc diff --git a/erpnext/hr/doctype/leave_period/leave_period.py b/erpnext/hr/doctype/leave_period/leave_period.py index 28a33f6fac86..86dccfc2225d 100644 --- a/erpnext/hr/doctype/leave_period/leave_period.py +++ b/erpnext/hr/doctype/leave_period/leave_period.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe from frappe import _ -from frappe.utils import getdate, cstr, add_days, date_diff, getdate, ceil +from frappe.utils import getdate, cstr, add_days, date_diff, ceil from frappe.model.document import Document from erpnext.hr.utils import validate_overlap from frappe.utils.background_jobs import enqueue diff --git a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py index d75213ce78d3..b5b30486de45 100644 --- a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py +++ b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py @@ -7,7 +7,7 @@ from frappe import _ from frappe.model.document import Document from frappe.utils import (nowdate, getdate, now_datetime, get_datetime, flt, date_diff, get_last_day, cint, - get_first_day, get_datetime, add_days) + get_first_day, add_days) from erpnext.controllers.accounts_controller import AccountsController from erpnext.accounts.general_ledger import make_gl_entries diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py index b67b4c4842b4..6c74a9bf5ab5 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py @@ -6,10 +6,9 @@ import frappe, erpnext import json from frappe import _ -from frappe.utils import flt, getdate, cint from six import iteritems from frappe.model.document import Document -from frappe.utils import date_diff, add_days, getdate, add_months, get_first_day, get_datetime +from frappe.utils import flt, cint, date_diff, add_days, getdate, add_months, get_first_day, get_datetime from erpnext.controllers.accounts_controller import AccountsController from erpnext.accounts.general_ledger import make_gl_entries from erpnext.loan_management.doctype.loan_security_shortfall.loan_security_shortfall import update_shortfall_status diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py index 03c46bb2ae0c..8c652c9d7c64 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.py +++ b/erpnext/selling/page/point_of_sale/point_of_sale.py @@ -2,7 +2,8 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, json +import json +import frappe from frappe.utils.nestedset import get_root_of from frappe.utils import cint from erpnext.accounts.doctype.pos_profile.pos_profile import get_item_groups @@ -209,7 +210,6 @@ def check_opening_entry(user): @frappe.whitelist() def create_opening_voucher(pos_profile, company, balance_details): - import json balance_details = json.loads(balance_details) new_pos_opening = frappe.get_doc({ diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py index 8c1c1ef0de00..b1d77cefc14d 100644 --- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py +++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py @@ -13,7 +13,6 @@ from datetime import datetime from frappe.utils.safe_exec import get_safe_globals from erpnext.support.doctype.issue.issue import get_holidays -from frappe.utils.safe_exec import get_safe_globals class ServiceLevelAgreement(Document): def validate(self): From 55b24345a01a0e040d98b3004afa4b980b2ba06a Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 15:24:49 +0530 Subject: [PATCH 06/11] fix: remove unused format from query doctype is not used in query and parent alone is enough to identify packed items. --- erpnext/controllers/sales_and_purchase_return.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 01486fcd65df..f673a9b6e57c 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -63,7 +63,7 @@ def validate_returned_items(doc): if doc.doctype in ("Delivery Note", "Sales Invoice"): for d in frappe.db.sql("""select item_code, qty, serial_no, batch_no from `tabPacked Item` - where parent = %s""".format(doc.doctype), doc.return_against, as_dict=1): + where parent = %s""", doc.return_against, as_dict=1): valid_items = get_ref_item_dict(valid_items, d) already_returned_items = get_already_returned_items(doc) From e46567192ae9f6d33cf9b7188ac0acd8a97b8c2f Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 15:25:49 +0530 Subject: [PATCH 07/11] fix: invalid escape sequences in regex --- erpnext/accounts/report/financial_statements.py | 2 +- .../doctype/amazon_mws_settings/xml_utils.py | 2 +- erpnext/regional/report/eway_bill/eway_bill.py | 2 +- .../fichier_des_ecritures_comptables_[fec].py | 2 +- erpnext/setup/doctype/naming_series/naming_series.py | 5 +++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 39ff80451810..f5309cd6fdaf 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -339,7 +339,7 @@ def sort_accounts(accounts, is_root=False, key="name"): """Sort root types as Asset, Liability, Equity, Income, Expense""" def compare_accounts(a, b): - if re.split('\W+', a[key])[0].isdigit(): + if re.split(r'\W+', a[key])[0].isdigit(): # if chart of accounts is numbered, then sort by number return cmp(a[key], b[key]) elif is_root: diff --git a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/xml_utils.py b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/xml_utils.py index 99ede8f31dec..52ba0239bb55 100644 --- a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/xml_utils.py +++ b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/xml_utils.py @@ -88,7 +88,7 @@ def _namespace_split(self, tag, value): ns = http://cs.sfsu.edu/csc867/myscheduler name = patients """ - result = re.compile("\{(.*)\}(.*)").search(tag) + result = re.compile(r"\{(.*)\}(.*)").search(tag) if result: value.namespace, tag = result.groups() diff --git a/erpnext/regional/report/eway_bill/eway_bill.py b/erpnext/regional/report/eway_bill/eway_bill.py index 4f777fcf7e3f..09d5f7916793 100644 --- a/erpnext/regional/report/eway_bill/eway_bill.py +++ b/erpnext/regional/report/eway_bill/eway_bill.py @@ -41,7 +41,7 @@ def get_data(filters): } # Regular expression set to remove all the special characters - special_characters = "[$%^*()+\\[\]{};':\"\\|<>.?]" + special_characters = r"[$%^*()+\\[\]{};':\"\\|<>.?]" for row in data: set_defaults(row) diff --git a/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py b/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py index e903c9f00a4d..697058def524 100644 --- a/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py +++ b/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py @@ -116,7 +116,7 @@ def get_result_as_list(data, filters): if d.get("voucher_no").startswith("{0}-".format(JournalCode)) or d.get("voucher_no").startswith("{0}/".format(JournalCode)): EcritureNum = re.split("-|/", d.get("voucher_no"))[1] else: - EcritureNum = re.search("{0}(\d+)".format(JournalCode), d.get("voucher_no"), re.IGNORECASE).group(1) + EcritureNum = re.search(r"{0}(\d+)".format(JournalCode), d.get("voucher_no"), re.IGNORECASE).group(1) EcritureDate = format_datetime(d.get("GlPostDate"), "yyyyMMdd") diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py index c1f9433b4112..c5d57479612c 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.py +++ b/erpnext/setup/doctype/naming_series/naming_series.py @@ -79,7 +79,8 @@ def set_series_for(self, doctype, ol): options = self.scrub_options_list(ol) # validate names - for i in options: self.validate_series_name(i) + for i in options: + self.validate_series_name(i) if options and self.user_must_always_select: options = [''] + options @@ -138,7 +139,7 @@ def check_duplicate(self): def validate_series_name(self, n): import re - if not re.match("^[\w\- /.#{}]*$", n, re.UNICODE): + if not re.match(r"^[\w\- \/.#{}]+$", n, re.UNICODE): throw(_('Special Characters except "-", "#", ".", "/", "{" and "}" not allowed in naming series')) @frappe.whitelist() From 0afff86da727dfa81c126820130e76fb2e4cf712 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 15:43:41 +0530 Subject: [PATCH 08/11] ci: add pre-commit config --- .pre-commit-config.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000000..0721d43c0734 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +exclude: 'node_modules|.git' +default_stages: [commit] +fail_fast: false + + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + files: "erpnext.*" + - id: end-of-file-fixer + files: "erpnext.*" + exclude: ".*json$|.*txt$" + - id: check-yaml + - id: no-commit-to-branch + args: ['--branch', 'develop'] + - id: check-merge-conflict + - id: check-ast + + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + additional_dependencies: [flake8-isort] + exclude: ".*setup.py$" + +ci: + autoupdate_schedule: weekly + skip: [] + submodules: false From 65279c2471cd9e945c41a8f31f869b15885ed79e Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 15:52:16 +0530 Subject: [PATCH 09/11] ci: add strict config for flake8 --- .github/helper/.flake8_strict | 72 +++++++++++++++++++ .../workflows/{semgrep.yml => linters.yml} | 15 +++- .pre-commit-config.yaml | 6 +- 3 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 .github/helper/.flake8_strict rename .github/workflows/{semgrep.yml => linters.yml} (56%) diff --git a/.github/helper/.flake8_strict b/.github/helper/.flake8_strict new file mode 100644 index 000000000000..c17871dfa94d --- /dev/null +++ b/.github/helper/.flake8_strict @@ -0,0 +1,72 @@ +[flake8] +ignore = + B007, + B950, + E101, + E111, + E114, + E116, + E117, + E121, + E122, + E123, + E124, + E125, + E126, + E127, + E128, + E131, + E201, + E202, + E203, + E211, + E221, + E222, + E223, + E224, + E225, + E226, + E228, + E231, + E241, + E242, + E251, + E261, + E262, + E265, + E266, + E271, + E272, + E273, + E274, + E301, + E302, + E303, + E305, + E306, + E401, + E402, + E501, + E502, + E701, + E702, + E703, + E741, + F401, + F403, + W191, + W291, + W292, + W293, + W391, + W503, + W504, + E711, + E129, + F841, + E713, + E712, + + +max-line-length = 200 +exclude=.github/helper/semgrep_rules,test_*.py diff --git a/.github/workflows/semgrep.yml b/.github/workflows/linters.yml similarity index 56% rename from .github/workflows/semgrep.yml rename to .github/workflows/linters.yml index e27b406df05c..c2363397c474 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/linters.yml @@ -1,11 +1,12 @@ -name: Semgrep +name: Linters on: pull_request: { } jobs: - semgrep: - name: Frappe Linter + + linters: + name: linters runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -16,3 +17,11 @@ jobs: config: >- r/python.lang.correctness .github/helper/semgrep_rules + + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install and Run Pre-commit + uses: pre-commit/action@v2.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0721d43c0734..df15b687c362 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,9 +9,7 @@ repos: hooks: - id: trailing-whitespace files: "erpnext.*" - - id: end-of-file-fixer - files: "erpnext.*" - exclude: ".*json$|.*txt$" + exclude: ".*json$|.*txt$|.*csv|.*md" - id: check-yaml - id: no-commit-to-branch args: ['--branch', 'develop'] @@ -22,7 +20,7 @@ repos: rev: 3.9.2 hooks: - id: flake8 - additional_dependencies: [flake8-isort] + args: ['--config', '.github/helper/.flake8_strict'] exclude: ".*setup.py$" ci: From b147b85e6ac19a9220cd1e2958a6ebd99373283a Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 16:45:57 +0530 Subject: [PATCH 10/11] chore: whitespace / eof fixes --- erpnext/accounts/custom/address.py | 2 +- .../doctype/bank_transaction/bank_transaction.py | 6 +++--- .../doctype/finance_book/test_finance_book.py | 2 +- .../accounts/doctype/party_link/party_link.py | 4 ++-- .../doctype/payment_entry/payment_entry.py | 2 +- .../period_closing_voucher.py | 4 ++-- .../sales_taxes_and_charges_template.js | 1 - .../tax_withholding_category.py | 2 +- erpnext/controllers/taxes_and_totals.py | 2 +- erpnext/crm/doctype/lead/lead.py | 1 - .../linkedin_settings/linkedin_settings.py | 6 +++--- erpnext/crm/doctype/prospect/prospect.py | 2 +- .../social_media_post/social_media_post.js | 4 ++-- .../doctype/twitter_settings/twitter_settings.py | 16 ++++++++-------- .../erpnext_integrations/taxjar_integration.py | 16 ++++++++-------- .../doctype/therapy_plan/test_therapy_plan.py | 2 +- .../page/patient_history/patient_history.js | 2 +- .../patient_history/patient_history_sidebar.html | 1 - .../doctype/employee/test_employee_reminders.py | 16 ++++++++-------- .../doctype/expense_claim/test_expense_claim.py | 13 ++++++------- erpnext/hr/utils.py | 12 ++++++------ erpnext/manufacturing/doctype/bom/bom.js | 2 +- .../manufacturing/doctype/operation/operation.js | 2 +- erpnext/manufacturing/doctype/routing/routing.js | 1 - .../doctype/workstation/workstation.js | 2 +- .../custom_fields_for_taxjar_integration.py | 6 +++--- .../rename_stop_to_send_birthday_reminders.py | 12 ++++++------ ...ance_date_for_intracompany_payment_entries.py | 6 +++--- ...set_operation_time_based_on_operating_cost.py | 2 +- .../v13_0/validate_options_for_data_field.py | 6 +++--- .../patches/v14_0/delete_einvoicing_doctypes.py | 2 +- erpnext/public/js/utils.js | 4 ++-- erpnext/regional/india/utils.py | 1 - erpnext/regional/united_states/setup.py | 4 ++-- .../selling/doctype/customer/test_customer.py | 2 +- erpnext/setup/doctype/company/company.js | 4 ++-- erpnext/stock/doctype/stock_entry/stock_entry.js | 1 - erpnext/stock/doctype/stock_entry/stock_entry.py | 2 +- .../tests/test_stock_entry_for_manufacture.js | 1 - .../stock_reconciliation/stock_reconciliation.js | 1 - .../doctype/stock_settings/stock_settings.js | 1 - erpnext/stock/doctype/warehouse/warehouse.js | 1 - .../process_loss_report/process_loss_report.py | 3 +-- .../templates/emails/anniversary_reminder.html | 2 +- 44 files changed, 86 insertions(+), 98 deletions(-) diff --git a/erpnext/accounts/custom/address.py b/erpnext/accounts/custom/address.py index 834227bb5860..628b71347231 100644 --- a/erpnext/accounts/custom/address.py +++ b/erpnext/accounts/custom/address.py @@ -31,7 +31,7 @@ def on_update(self): customers = frappe.db.get_all("Customer", filters=filters, as_list=True) for customer_name in customers: frappe.db.set_value("Customer", customer_name[0], "primary_address", address_display) - + @frappe.whitelist() def get_shipping_address(company, address = None): filters = [ diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py index 7ea71fc103a3..235af2d86284 100644 --- a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py +++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py @@ -21,7 +21,7 @@ def on_update_after_submit(self): self.update_allocations() self.clear_linked_payment_entries() self.set_status(update=True) - + def on_cancel(self): self.clear_linked_payment_entries(for_cancel=True) self.set_status(update=True) @@ -45,7 +45,7 @@ def update_allocations(self): frappe.db.set_value(self.doctype, self.name, "status", "Reconciled") self.reload() - + def clear_linked_payment_entries(self, for_cancel=False): for payment_entry in self.payment_entries: if payment_entry.payment_document in ["Payment Entry", "Journal Entry", "Purchase Invoice", "Expense Claim"]: @@ -77,7 +77,7 @@ def clear_sales_invoice(self, payment_entry, for_cancel=False): def get_reconciled_bank_transactions(payment_entry): reconciled_bank_transactions = frappe.get_all( - 'Bank Transaction Payments', + 'Bank Transaction Payments', filters = { 'payment_entry': payment_entry.payment_entry }, diff --git a/erpnext/accounts/doctype/finance_book/test_finance_book.py b/erpnext/accounts/doctype/finance_book/test_finance_book.py index 2ba21397ad0c..bb9a46d88ca2 100644 --- a/erpnext/accounts/doctype/finance_book/test_finance_book.py +++ b/erpnext/accounts/doctype/finance_book/test_finance_book.py @@ -40,4 +40,4 @@ def create_finance_book(): else: finance_book = frappe.get_doc("Finance Book", "_Test Finance Book") - return finance_book \ No newline at end of file + return finance_book diff --git a/erpnext/accounts/doctype/party_link/party_link.py b/erpnext/accounts/doctype/party_link/party_link.py index 7d58506ce74b..9cbba352736e 100644 --- a/erpnext/accounts/doctype/party_link/party_link.py +++ b/erpnext/accounts/doctype/party_link/party_link.py @@ -10,14 +10,14 @@ def validate(self): if self.primary_role not in ['Customer', 'Supplier']: frappe.throw(_("Allowed primary roles are 'Customer' and 'Supplier'. Please select one of these roles only."), title=_("Invalid Primary Role")) - + existing_party_link = frappe.get_all('Party Link', { 'primary_party': self.secondary_party }, pluck="primary_role") if existing_party_link: frappe.throw(_('{} {} is already linked with another {}') .format(self.secondary_role, self.secondary_party, existing_party_link[0])) - + existing_party_link = frappe.get_all('Party Link', { 'secondary_party': self.primary_party }, pluck="primary_role") diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index a5fcad4996ae..f9fa63d82317 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -484,7 +484,7 @@ def set_amounts(self): def validate_amounts(self): self.validate_received_amount() - + def validate_received_amount(self): if self.paid_from_account_currency == self.paid_to_account_currency: if self.paid_amount != self.received_amount: diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index 289278ea8d5c..ebe55f6a6e9c 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -54,7 +54,7 @@ def make_gl_entries(self): if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries make_gl_entries(gl_entries) - + def get_gl_entries(self): gl_entries = [] pl_accounts = self.get_pl_balances() @@ -77,7 +77,7 @@ def get_gl_entries(self): gl_entries += gle_for_net_pl_bal return gl_entries - + def get_pnl_gl_entry(self, pl_accounts): company_cost_center = frappe.db.get_value("Company", self.company, "cost_center") gl_entries = [] diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js b/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js index 97a6fdd3366d..066c4eae4364 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js @@ -4,4 +4,3 @@ cur_frm.cscript.tax_table = "Sales Taxes and Charges"; {% include "erpnext/public/js/controllers/accounts.js" %} - diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py index 0cb872c4b817..5772ac23b8d0 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -240,7 +240,7 @@ def get_deducted_tax(taxable_vouchers, fiscal_year, tax_details): def get_tds_amount(ldc, parties, inv, tax_details, fiscal_year_details, tax_deducted, vouchers): tds_amount = 0 invoice_filters = { - 'name': ('in', vouchers), + 'name': ('in', vouchers), 'docstatus': 1, 'apply_tds': 1 } diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 7c6d3552f123..993c354f7a74 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -686,7 +686,7 @@ def set_total_amount_to_default_mop(self, total_amount_to_pay): 'mode_of_payment': default_mode_of_payment.mode_of_payment, 'amount': total_amount_to_pay, 'default': 1 - }) + }) def get_itemised_tax_breakup_html(doc): if not doc.taxes: diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py index aa6c07b1be94..e82ae8f37262 100644 --- a/erpnext/crm/doctype/lead/lead.py +++ b/erpnext/crm/doctype/lead/lead.py @@ -371,4 +371,3 @@ def add_lead_to_prospect(lead, prospect): prospect.save(ignore_permissions=True) frappe.msgprint(_('Lead {0} has been added to prospect {1}.').format(frappe.bold(lead), frappe.bold(prospect.name)), title=_('Lead Added'), indicator='green') - \ No newline at end of file diff --git a/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py b/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py index 9b88d78c1ff2..c56eed84cef2 100644 --- a/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py +++ b/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py @@ -146,7 +146,7 @@ def http_post(self, url, headers=None, body=None, data=None): except Exception as e: self.api_error(response) - + return response def get_headers(self): @@ -168,7 +168,7 @@ def delete_post(self, post_id): raise except Exception: self.api_error(response) - + def get_post(self, post_id): url = "https://api.linkedin.com/v2/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity=urn:li:organization:{0}&shares[0]=urn:li:share:{1}".format(self.company_id, post_id) @@ -176,7 +176,7 @@ def get_post(self, post_id): response = requests.get(url=url, headers=self.get_headers()) if response.status_code !=200: raise - + except Exception: self.api_error(response) diff --git a/erpnext/crm/doctype/prospect/prospect.py b/erpnext/crm/doctype/prospect/prospect.py index 5f5815de5ed8..3fa6fe853742 100644 --- a/erpnext/crm/doctype/prospect/prospect.py +++ b/erpnext/crm/doctype/prospect/prospect.py @@ -15,7 +15,7 @@ def validate(self): def on_update(self): self.link_with_lead_contact_and_address() - + def on_trash(self): self.unlink_dynamic_links() diff --git a/erpnext/crm/doctype/social_media_post/social_media_post.js b/erpnext/crm/doctype/social_media_post/social_media_post.js index a8f5deea5350..6874caac71fb 100644 --- a/erpnext/crm/doctype/social_media_post/social_media_post.js +++ b/erpnext/crm/doctype/social_media_post/social_media_post.js @@ -80,10 +80,10 @@ frappe.ui.form.on('Social Media Post', { refresh: function(frm) { frm.trigger('text'); - + if (frm.doc.docstatus === 1) { if (!['Posted', 'Deleted'].includes(frm.doc.post_status)) { - frm.trigger('add_post_btn'); + frm.trigger('add_post_btn'); } if (frm.doc.post_status !='Deleted') { frm.add_custom_button(('Delete Post'), function() { diff --git a/erpnext/crm/doctype/twitter_settings/twitter_settings.py b/erpnext/crm/doctype/twitter_settings/twitter_settings.py index 47756560ec5f..9c37ffd77156 100644 --- a/erpnext/crm/doctype/twitter_settings/twitter_settings.py +++ b/erpnext/crm/doctype/twitter_settings/twitter_settings.py @@ -53,10 +53,10 @@ def get_access_token(self, oauth_token, oauth_verifier): frappe.throw(_('Invalid Consumer Key or Consumer Secret Key')) def get_api(self): - # authentication of consumer key and secret - auth = tweepy.OAuthHandler(self.consumer_key, self.get_password(fieldname="consumer_secret")) - # authentication of access token and secret - auth.set_access_token(self.access_token, self.access_token_secret) + # authentication of consumer key and secret + auth = tweepy.OAuthHandler(self.consumer_key, self.get_password(fieldname="consumer_secret")) + # authentication of access token and secret + auth.set_access_token(self.access_token, self.access_token_secret) return tweepy.API(auth) @@ -90,20 +90,20 @@ def send_tweet(self, text, media_id=None): def delete_tweet(self, tweet_id): api = self.get_api() - try: + try: api.destroy_status(tweet_id) except TweepError as e: self.api_error(e) def get_tweet(self, tweet_id): api = self.get_api() - try: + try: response = api.get_status(tweet_id, trim_user=True, include_entities=True) except TweepError as e: self.api_error(e) - + return response._json - + def api_error(self, e): content = json.loads(e.response.content) content = content["errors"][0] diff --git a/erpnext/erpnext_integrations/taxjar_integration.py b/erpnext/erpnext_integrations/taxjar_integration.py index 83764ae50d83..574fe254c900 100644 --- a/erpnext/erpnext_integrations/taxjar_integration.py +++ b/erpnext/erpnext_integrations/taxjar_integration.py @@ -15,7 +15,7 @@ "SE", "SI", "SK", "US"] SUPPORTED_STATE_CODES = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', - 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', + 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'] @@ -66,7 +66,7 @@ def create_transaction(doc, method): try: if doc.is_return: client.create_refund(tax_dict) - else: + else: client.create_order(tax_dict) except taxjar.exceptions.TaxJarResponseError as err: frappe.throw(_(sanitize_error_response(err))) @@ -108,7 +108,7 @@ def get_tax_data(doc): if to_shipping_state not in SUPPORTED_STATE_CODES: to_shipping_state = get_state_code(to_address, 'Shipping') - + tax_dict = { 'from_country': from_country_code, 'from_zip': from_address.pincode, @@ -125,7 +125,7 @@ def get_tax_data(doc): 'plugin': 'erpnext', 'line_items': line_items } - return tax_dict + return tax_dict def get_state_code(address, location): if address is not None: @@ -134,16 +134,16 @@ def get_state_code(address, location): frappe.throw(_("Please enter a valid State in the {0} Address").format(location)) else: frappe.throw(_("Please enter a valid State in the {0} Address").format(location)) - + return state_code def get_line_item_dict(item): - return dict( + return dict( id = item.get('idx'), quantity = item.get('qty'), unit_price = item.get('rate'), product_tax_code = item.get('product_tax_category') - ) + ) def set_sales_tax(doc, method): if not TAXJAR_CALCULATE_TAX: @@ -202,7 +202,7 @@ def check_sales_tax_exemption(doc): break doc.run_method("calculate_taxes_and_totals") return True - else: + else: return False def validate_tax_request(tax_dict): diff --git a/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py b/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py index 983fba9f5ff9..54e00ea48eea 100644 --- a/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py +++ b/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py @@ -31,7 +31,7 @@ def test_status(self): self.assertEqual(frappe.db.get_value('Therapy Plan', plan.name, 'status'), 'Completed') patient, practitioner = create_healthcare_docs() - appointment = create_appointment(patient, practitioner, nowdate()) + appointment = create_appointment(patient, practitioner, nowdate()) session = make_therapy_session(plan.name, plan.patient, 'Basic Rehab', '_Test Company', appointment.name) session = frappe.get_doc(session) diff --git a/erpnext/healthcare/page/patient_history/patient_history.js b/erpnext/healthcare/page/patient_history/patient_history.js index bf947cac2156..ed2dc52cb117 100644 --- a/erpnext/healthcare/page/patient_history/patient_history.js +++ b/erpnext/healthcare/page/patient_history/patient_history.js @@ -452,4 +452,4 @@ class PatientHistory { } }); } -} \ No newline at end of file +} diff --git a/erpnext/healthcare/page/patient_history/patient_history_sidebar.html b/erpnext/healthcare/page/patient_history/patient_history_sidebar.html index 4560e7e1254d..fc7eab05401c 100644 --- a/erpnext/healthcare/page/patient_history/patient_history_sidebar.html +++ b/erpnext/healthcare/page/patient_history/patient_history_sidebar.html @@ -18,4 +18,3 @@
- diff --git a/erpnext/hr/doctype/employee/test_employee_reminders.py b/erpnext/hr/doctype/employee/test_employee_reminders.py index 7e560f512d1e..f46a3d1f6251 100644 --- a/erpnext/hr/doctype/employee/test_employee_reminders.py +++ b/erpnext/hr/doctype/employee/test_employee_reminders.py @@ -18,7 +18,7 @@ def setUpClass(cls): # Create a test holiday list test_holiday_dates = cls.get_test_holiday_dates() test_holiday_list = make_holiday_list( - 'TestHolidayRemindersList', + 'TestHolidayRemindersList', holiday_dates=[ {'holiday_date': test_holiday_dates[0], 'description': 'test holiday1'}, {'holiday_date': test_holiday_dates[1], 'description': 'test holiday2'}, @@ -49,8 +49,8 @@ def setUpClass(cls): def get_test_holiday_dates(cls): today_date = getdate() return [ - today_date, - today_date-timedelta(days=4), + today_date, + today_date-timedelta(days=4), today_date-timedelta(days=3), today_date+timedelta(days=1), today_date+timedelta(days=3), @@ -63,7 +63,7 @@ def setUp(self): def test_is_holiday(self): from erpnext.hr.doctype.employee.employee import is_holiday - + self.assertTrue(is_holiday(self.test_employee.name)) self.assertTrue(is_holiday(self.test_employee.name, date=self.test_holiday_dates[1])) self.assertFalse(is_holiday(self.test_employee.name, date=getdate()-timedelta(days=1))) @@ -118,7 +118,7 @@ def test_work_anniversary_reminders(self): email_queue = frappe.db.sql("""select * from `tabEmail Queue`""", as_dict=True) self.assertTrue("Subject: Work Anniversary Reminder" in email_queue[0].message) - + def test_send_holidays_reminder_in_advance(self): from erpnext.hr.utils import get_holidays_for_employee from erpnext.hr.doctype.employee.employee_reminders import send_holidays_reminder_in_advance @@ -133,10 +133,10 @@ def test_send_holidays_reminder_in_advance(self): holidays = get_holidays_for_employee( self.test_employee.get('name'), getdate(), getdate() + timedelta(days=3), - only_non_weekly=True, + only_non_weekly=True, raise_exception=False ) - + send_holidays_reminder_in_advance( self.test_employee.get('name'), holidays @@ -158,7 +158,7 @@ def test_advance_holiday_reminders_monthly(self): email_queue = frappe.db.sql("""select * from `tabEmail Queue`""", as_dict=True) self.assertTrue(len(email_queue) > 0) - + def test_advance_holiday_reminders_weekly(self): from erpnext.hr.doctype.employee.employee_reminders import send_reminders_in_advance_weekly # Get HR settings and enable advance holiday reminders diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py index b5fc1fbe758f..d61c590ac984 100644 --- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py @@ -144,20 +144,20 @@ def test_multiple_payment_entries_against_expense(self): expense_claim = make_expense_claim(payable_account, 5500, 5500, "_Test Company", "Travel Expenses - _TC") expense_claim.save() expense_claim.submit() - + # Payment entry 1: paying 500 make_payment_entry(expense_claim, payable_account,500) outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim) self.assertEqual(outstanding_amount, 5000) self.assertEqual(total_amount_reimbursed, 500) - + # Payment entry 1: paying 2000 make_payment_entry(expense_claim, payable_account,2000) outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim) self.assertEqual(outstanding_amount, 3000) self.assertEqual(total_amount_reimbursed, 2500) - - # Payment entry 1: paying 3000 + + # Payment entry 1: paying 3000 make_payment_entry(expense_claim, payable_account,3000) outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim) self.assertEqual(outstanding_amount, 0) @@ -221,7 +221,7 @@ def get_outstanding_and_total_reimbursed_amounts(expense_claim): outstanding_amount = flt(frappe.db.get_value("Expense Claim", expense_claim.name, "total_sanctioned_amount")) - \ flt(frappe.db.get_value("Expense Claim", expense_claim.name, "total_amount_reimbursed")) total_amount_reimbursed = flt(frappe.db.get_value("Expense Claim", expense_claim.name, "total_amount_reimbursed")) - + return outstanding_amount,total_amount_reimbursed def make_payment_entry(expense_claim, payable_account, amt): @@ -234,5 +234,4 @@ def make_payment_entry(expense_claim, payable_account, amt): pe.paid_to = payable_account pe.references[0].allocated_amount = amt pe.insert() - pe.submit() - + pe.submit() diff --git a/erpnext/hr/utils.py b/erpnext/hr/utils.py index 15b237d93cd6..eb35e4295cee 100644 --- a/erpnext/hr/utils.py +++ b/erpnext/hr/utils.py @@ -337,9 +337,9 @@ def get_sal_slip_total_benefit_given(employee, payroll_period, component=False): def get_holiday_dates_for_employee(employee, start_date, end_date): """return a list of holiday dates for the given employee between start_date and end_date""" - # return only date - holidays = get_holidays_for_employee(employee, start_date, end_date) - + # return only date + holidays = get_holidays_for_employee(employee, start_date, end_date) + return [cstr(h.holiday_date) for h in holidays] @@ -352,7 +352,7 @@ def get_holidays_for_employee(employee, start_date, end_date, raise_exception=Tr `raise_exception` (bool) `only_non_weekly` (bool) - return: list of dicts with `holiday_date` and `description` + return: list of dicts with `holiday_date` and `description` """ holiday_list = get_holiday_list_for_employee(employee, raise_exception=raise_exception) @@ -368,11 +368,11 @@ def get_holidays_for_employee(employee, start_date, end_date, raise_exception=Tr filters['weekly_off'] = False holidays = frappe.get_all( - 'Holiday', + 'Holiday', fields=['description', 'holiday_date'], filters=filters ) - + return holidays @erpnext.allow_regional diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index 05123d5f8562..8a9241391abe 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -714,4 +714,4 @@ function trigger_process_loss_qty_prompt(frm, cdt, cdn, item_code) { __("Set Process Loss Item Quantity"), __("Set Quantity") ); -} \ No newline at end of file +} diff --git a/erpnext/manufacturing/doctype/operation/operation.js b/erpnext/manufacturing/doctype/operation/operation.js index 95643bf49fca..ea73fd6e2734 100644 --- a/erpnext/manufacturing/doctype/operation/operation.js +++ b/erpnext/manufacturing/doctype/operation/operation.js @@ -29,4 +29,4 @@ frappe.tour['Operation'] = [ title: "Sub Operations", description: __("If an operation is divided into sub operations, they can be added here.") } -]; \ No newline at end of file +]; diff --git a/erpnext/manufacturing/doctype/routing/routing.js b/erpnext/manufacturing/doctype/routing/routing.js index c17a8e959dbb..33a313e32f51 100644 --- a/erpnext/manufacturing/doctype/routing/routing.js +++ b/erpnext/manufacturing/doctype/routing/routing.js @@ -82,4 +82,3 @@ frappe.tour['Routing'] = [ description: __("Enter the Operation, the table will fetch the Operation details like Hourly Rate, Workstation automatically.\n\n After that, set the Operation Time in minutes and the table will calculate the Operation Costs based on the Hourly Rate and Operation Time.") } ]; - diff --git a/erpnext/manufacturing/doctype/workstation/workstation.js b/erpnext/manufacturing/doctype/workstation/workstation.js index 4f5231e449c1..5b9cedb6f986 100644 --- a/erpnext/manufacturing/doctype/workstation/workstation.js +++ b/erpnext/manufacturing/doctype/workstation/workstation.js @@ -41,4 +41,4 @@ frappe.tour['Workstation'] = [ }, -]; \ No newline at end of file +]; diff --git a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py index 1d57550d37e1..125be9b842df 100644 --- a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py +++ b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py @@ -14,9 +14,9 @@ def execute(): 'Sales Invoice Item': [ dict(fieldname='product_tax_category', fieldtype='Link', insert_after='description', options='Product Tax Category', label='Product Tax Category', fetch_from='item_code.product_tax_category'), - dict(fieldname='tax_collectable', fieldtype='Currency', insert_after='net_amount', + dict(fieldname='tax_collectable', fieldtype='Currency', insert_after='net_amount', label='Tax Collectable', read_only=1), - dict(fieldname='taxable_amount', fieldtype='Currency', insert_after='tax_collectable', + dict(fieldname='taxable_amount', fieldtype='Currency', insert_after='tax_collectable', label='Taxable Amount', read_only=1) ], 'Item': [ @@ -26,4 +26,4 @@ def execute(): } create_custom_fields(custom_fields, update=True) add_permissions() - frappe.enqueue('erpnext.regional.united_states.setup.add_product_tax_categories', now=True) \ No newline at end of file + frappe.enqueue('erpnext.regional.united_states.setup.add_product_tax_categories', now=True) diff --git a/erpnext/patches/v13_0/rename_stop_to_send_birthday_reminders.py b/erpnext/patches/v13_0/rename_stop_to_send_birthday_reminders.py index 1787a5602548..014f026060c7 100644 --- a/erpnext/patches/v13_0/rename_stop_to_send_birthday_reminders.py +++ b/erpnext/patches/v13_0/rename_stop_to_send_birthday_reminders.py @@ -7,17 +7,17 @@ def execute(): try: # Rename the field rename_field('HR Settings', 'stop_birthday_reminders', 'send_birthday_reminders') - + # Reverse the value old_value = frappe.db.get_single_value('HR Settings', 'send_birthday_reminders') frappe.db.set_value( - 'HR Settings', - 'HR Settings', - 'send_birthday_reminders', + 'HR Settings', + 'HR Settings', + 'send_birthday_reminders', 1 if old_value == 0 else 0 ) - + except Exception as e: if e.args[0] != 1054: - raise \ No newline at end of file + raise diff --git a/erpnext/patches/v13_0/reset_clearance_date_for_intracompany_payment_entries.py b/erpnext/patches/v13_0/reset_clearance_date_for_intracompany_payment_entries.py index 1da5275761bd..1caa17f45ee6 100644 --- a/erpnext/patches/v13_0/reset_clearance_date_for_intracompany_payment_entries.py +++ b/erpnext/patches/v13_0/reset_clearance_date_for_intracompany_payment_entries.py @@ -35,11 +35,11 @@ def get_reconciled_bank_transactions(intra_company_pe): for payment_entry in intra_company_pe: reconciled_bank_transactions[payment_entry] = frappe.get_all( - 'Bank Transaction Payments', + 'Bank Transaction Payments', filters = { 'payment_entry': payment_entry - }, + }, pluck='parent' ) - return reconciled_bank_transactions \ No newline at end of file + return reconciled_bank_transactions diff --git a/erpnext/patches/v13_0/set_operation_time_based_on_operating_cost.py b/erpnext/patches/v13_0/set_operation_time_based_on_operating_cost.py index 4acbdd63a001..4fdd82f97b35 100644 --- a/erpnext/patches/v13_0/set_operation_time_based_on_operating_cost.py +++ b/erpnext/patches/v13_0/set_operation_time_based_on_operating_cost.py @@ -12,4 +12,4 @@ def execute(): WHERE time_in_mins = 0 AND operating_cost > 0 AND hour_rate > 0 AND docstatus = 1 AND parenttype = "BOM" - ''') \ No newline at end of file + ''') diff --git a/erpnext/patches/v13_0/validate_options_for_data_field.py b/erpnext/patches/v13_0/validate_options_for_data_field.py index 568d1a4b0cb8..03f9929c5c60 100644 --- a/erpnext/patches/v13_0/validate_options_for_data_field.py +++ b/erpnext/patches/v13_0/validate_options_for_data_field.py @@ -3,11 +3,11 @@ from __future__ import unicode_literals import frappe -from frappe.model import data_field_options +from frappe.model import data_field_options def execute(): - for field in frappe.get_all('Custom Field', + for field in frappe.get_all('Custom Field', fields = ['name'], filters = { 'fieldtype': 'Data', @@ -16,7 +16,7 @@ def execute(): if field not in data_field_options: frappe.db.sql(""" - UPDATE + UPDATE `tabCustom Field` SET options=NULL diff --git a/erpnext/patches/v14_0/delete_einvoicing_doctypes.py b/erpnext/patches/v14_0/delete_einvoicing_doctypes.py index b77d2440eb14..6e5775b3ac26 100644 --- a/erpnext/patches/v14_0/delete_einvoicing_doctypes.py +++ b/erpnext/patches/v14_0/delete_einvoicing_doctypes.py @@ -6,4 +6,4 @@ def execute(): frappe.delete_doc('Report', 'E-Invoice Summary', ignore_missing=True) frappe.delete_doc('Print Format', 'GST E-Invoice', ignore_missing=True) frappe.delete_doc('Custom Field', 'Sales Invoice-eway_bill_cancelled', ignore_missing=True) - frappe.delete_doc('Custom Field', 'Sales Invoice-irn_cancelled', ignore_missing=True) \ No newline at end of file + frappe.delete_doc('Custom Field', 'Sales Invoice-irn_cancelled', ignore_missing=True) diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 9caf1defe979..e0610eb8c010 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -86,9 +86,9 @@ $.extend(erpnext, { proceed_save_with_reminders_frequency_change: () => { frappe.ui.hide_open_dialog(); - + frappe.call({ - method: 'erpnext.hr.doctype.hr_settings.hr_settings.set_proceed_with_frequency_change', + method: 'erpnext.hr.doctype.hr_settings.hr_settings.set_proceed_with_frequency_change', callback: () => { cur_frm.save(); } diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index ce5aa10902ee..ac31f7761927 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -887,4 +887,3 @@ def delete_gst_settings_for_company(doc, method): gst_settings.remove(d) gst_settings.save() - diff --git a/erpnext/regional/united_states/setup.py b/erpnext/regional/united_states/setup.py index c0cec3aef925..9c183af1d130 100644 --- a/erpnext/regional/united_states/setup.py +++ b/erpnext/regional/united_states/setup.py @@ -63,9 +63,9 @@ def make_custom_fields(update=True): 'Sales Invoice Item': [ dict(fieldname='product_tax_category', fieldtype='Link', insert_after='description', options='Product Tax Category', label='Product Tax Category', fetch_from='item_code.product_tax_category'), - dict(fieldname='tax_collectable', fieldtype='Currency', insert_after='net_amount', + dict(fieldname='tax_collectable', fieldtype='Currency', insert_after='net_amount', label='Tax Collectable', read_only=1), - dict(fieldname='taxable_amount', fieldtype='Currency', insert_after='tax_collectable', + dict(fieldname='taxable_amount', fieldtype='Currency', insert_after='tax_collectable', label='Taxable Amount', read_only=1) ], 'Item': [ diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index 5b337313d3d0..3d3dffa84030 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -374,4 +374,4 @@ def create_internal_customer(customer_name, represents_company, allowed_to_inter else: customer_name = frappe.db.get_value("Customer", customer_name) - return customer_name \ No newline at end of file + return customer_name diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index 56700af79e9b..8403193df53c 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -55,10 +55,10 @@ frappe.ui.form.on("Company", { {"fieldtype": "Button", "label": "Update", "fieldname": "update"}, ] }); - + dialog.fields_dict.update.$input.click(function() { var args = dialog.get_values(); - if (!args) return; + if (!args) return; frappe.show_alert(__("Update in progress. It might take a while.")); return frappe.call({ method: "erpnext.setup.doctype.company.company.enqueue_replace_abbr", diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 8f34794db9ae..908020d02ba7 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -1101,4 +1101,3 @@ function check_should_not_attach_bom_items(bom_no) { } $.extend(cur_frm.cscript, new erpnext.stock.StockEntry({frm: cur_frm})); - diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 760cb7db6668..c7e22c2f22b8 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -1582,7 +1582,7 @@ def set_material_request_transfer_status(self, status): if material_request and material_request not in material_requests: material_requests.append(material_request) frappe.db.set_value('Material Request', material_request, 'transfer_status', status) - + def update_items_for_process_loss(self): process_loss_dict = {} for d in self.get("items"): diff --git a/erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_manufacture.js b/erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_manufacture.js index 285ae4f59e82..e51c90cf51f1 100644 --- a/erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_manufacture.js +++ b/erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_manufacture.js @@ -24,4 +24,3 @@ QUnit.test("test manufacture from bom", function(assert) { () => done() ]); }); - diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index aa502a432dfb..84f65a077e0c 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -302,4 +302,3 @@ erpnext.stock.StockReconciliation = class StockReconciliation extends erpnext.st }; cur_frm.cscript = new erpnext.stock.StockReconciliation({frm: cur_frm}); - diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.js b/erpnext/stock/doctype/stock_settings/stock_settings.js index 6167becdaac0..cc0e2cfc4254 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.js +++ b/erpnext/stock/doctype/stock_settings/stock_settings.js @@ -15,4 +15,3 @@ frappe.ui.form.on('Stock Settings', { frm.set_query("sample_retention_warehouse", filters); } }); - diff --git a/erpnext/stock/doctype/warehouse/warehouse.js b/erpnext/stock/doctype/warehouse/warehouse.js index 4e1679c41169..9243e1ed84fb 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.js +++ b/erpnext/stock/doctype/warehouse/warehouse.js @@ -86,4 +86,3 @@ function convert_to_group_or_ledger(frm){ }) } - diff --git a/erpnext/stock/report/process_loss_report/process_loss_report.py b/erpnext/stock/report/process_loss_report/process_loss_report.py index 3d48ebde1a50..ebb32f18c293 100644 --- a/erpnext/stock/report/process_loss_report/process_loss_report.py +++ b/erpnext/stock/report/process_loss_report/process_loss_report.py @@ -92,7 +92,7 @@ def get_query_args(filters: Filters) -> QueryArgs: def run_query(query_args: QueryArgs) -> Data: return frappe.db.sql(""" - SELECT + SELECT wo.name, wo.status, wo.production_item, wo.qty, wo.produced_qty, wo.process_loss_qty, (wo.produced_qty - wo.process_loss_qty) as actual_produced_qty, @@ -130,4 +130,3 @@ def get_filter_conditions(filters: Filters) -> QueryArgs: {"work_order_filter": f"AND wo.name='{work_order_name}'"} ) return filter_conditions - diff --git a/erpnext/templates/emails/anniversary_reminder.html b/erpnext/templates/emails/anniversary_reminder.html index ac9f7e4993a3..db338ddcb089 100644 --- a/erpnext/templates/emails/anniversary_reminder.html +++ b/erpnext/templates/emails/anniversary_reminder.html @@ -22,4 +22,4 @@ {{ reminder_text }}

{{ message }}

- \ No newline at end of file + From a641b326c50f06f20dfc9a3ca8d4f90752c196bc Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 18:43:38 +0530 Subject: [PATCH 11/11] chore: ignore whitespace changes in blame --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 566323a9e97d..e762580ed767 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -16,3 +16,4 @@ # Whitespace fix throughout codebase 4551d7d6029b6f587f6c99d4f8df5519241c6a86 +b147b85e6ac19a9220cd1e2958a6ebd99373283a