From 2d62c500c477fe7624426b807dd9b23c455c6e47 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 1 Sep 2021 15:02:06 +0530 Subject: [PATCH] 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 4903c50e17..ccfb29f355 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 27f14b1dbd..ad781d6859 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 @@ class AppointmentBookingSettings(Document): 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 d847cbb5c9..c053559186 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 74a131015b..7ed838d4e1 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):