From 8aa0a280b201be9bbd043db3c1f3288853e64da5 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Tue, 15 Oct 2019 19:17:20 +0530 Subject: [PATCH 01/21] Revert "fix: Allow disabled links in issue doctype (#19265)" This reverts commit 29a5756f87ccb07bb52ffc9fbc4db0bee891c295. --- erpnext/support/doctype/issue/issue.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py index cdf5fedcb8..b748e3fa46 100644 --- a/erpnext/support/doctype/issue/issue.py +++ b/erpnext/support/doctype/issue/issue.py @@ -22,7 +22,6 @@ class Issue(Document): return "{0}: {1}".format(_(self.status), self.subject) def validate(self): - self.flags.ignore_disabled = 1 if self.is_new() and self.via_customer_portal: self.flags.create_communication = True From d5166861ded4ec2cb6dcbaab9f9bf41f044174b8 Mon Sep 17 00:00:00 2001 From: Pranav Nachnekar Date: Wed, 23 Oct 2019 07:46:00 +0000 Subject: [PATCH 02/21] fix:setting incorrect field for party bank account Previously ![wrong](https://user-images.githubusercontent.com/6195660/67369702-0671c000-f569-11e9-9916-a1d1a0c3ddd1.gif) Corrected ![corrected](https://user-images.githubusercontent.com/6195660/67369663-f9ed6780-f568-11e9-859b-cbfa9857b39e.gif) --- erpnext/accounts/doctype/payment_entry/payment_entry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index 172d5372a6..1e0b1bcbf1 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -308,7 +308,7 @@ frappe.ui.form.on('Payment Entry', { () => { frm.set_party_account_based_on_party = false; if (r.message.bank_account) { - frm.set_value("bank_account", r.message.bank_account); + frm.set_value("party_bank_account", r.message.bank_account); } } ]); From 233c0bc779effa24f5ec07d19b211fd09defd03f Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Thu, 24 Oct 2019 15:45:32 +0530 Subject: [PATCH 03/21] fix: sync delivery note status in both list view and form view --- erpnext/stock/doctype/delivery_note/delivery_note_list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note_list.js b/erpnext/stock/doctype/delivery_note/delivery_note_list.js index 6fc51ecdd9..0ae7c37b3f 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note_list.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note_list.js @@ -6,9 +6,9 @@ frappe.listview_settings['Delivery Note'] = { return [__("Return"), "darkgrey", "is_return,=,Yes"]; } else if (doc.status === "Closed") { return [__("Closed"), "green", "status,=,Closed"]; - } else if (doc.grand_total !== 0 && flt(doc.per_billed, 2) < 100) { + } else if (flt(doc.per_billed, 2) < 100) { return [__("To Bill"), "orange", "per_billed,<,100"]; - } else if (doc.grand_total === 0 || flt(doc.per_billed, 2) == 100) { + } else if (flt(doc.per_billed, 2) == 100) { return [__("Completed"), "green", "per_billed,=,100"]; } }, From 758635ab91565e1247e82436c2c2059f04498251 Mon Sep 17 00:00:00 2001 From: Sahil Khan Date: Thu, 24 Oct 2019 17:50:19 +0550 Subject: [PATCH 04/21] bumped to version 12.1.7 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 686d5492ca..a06e3db9ae 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '12.1.6' +__version__ = '12.1.7' def get_default_company(user=None): '''Get default company for user''' From 7bdc6120132c23af4e7e334f6a96aeaae06c8ee7 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 24 Oct 2019 18:01:58 +0530 Subject: [PATCH 05/21] chore: Update module name (#19404) --- erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py b/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py index 5c18985f7f..3d1a88e800 100644 --- a/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py +++ b/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py @@ -4,7 +4,7 @@ from frappe.model.utils.rename_field import rename_field def execute(): - frappe.reload_doc('desk', 'doctype', 'auto_repeat') + frappe.reload_doc('automation', 'doctype', 'auto_repeat') doctypes_to_rename = { 'accounts': ['Journal Entry', 'Payment Entry', 'Purchase Invoice', 'Sales Invoice'], @@ -41,4 +41,4 @@ def drop_columns_from_subscription(): if field in frappe.db.get_table_columns("Subscription"): fields_to_drop['Subscription'].append(field) - frappe.model.delete_fields(fields_to_drop, delete=1) \ No newline at end of file + frappe.model.delete_fields(fields_to_drop, delete=1) From e1f95c0529f0109f7cc70674b4bab75971436550 Mon Sep 17 00:00:00 2001 From: Ashish Shah Date: Fri, 25 Oct 2019 12:16:11 +0530 Subject: [PATCH 06/21] fix: allow_items_not_in_stock should be evaluated (#19398) --- erpnext/shopping_cart/cart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py index f850bc1707..a4c10cfb7d 100644 --- a/erpnext/shopping_cart/cart.py +++ b/erpnext/shopping_cart/cart.py @@ -66,7 +66,7 @@ def place_order(): from erpnext.selling.doctype.quotation.quotation import _make_sales_order sales_order = frappe.get_doc(_make_sales_order(quotation.name, ignore_permissions=True)) - if not cart_settings.allow_items_not_in_stock: + if not cint(cart_settings.allow_items_not_in_stock): for item in sales_order.get("items"): item.reserved_warehouse, is_stock_item = frappe.db.get_value("Item", item.item_code, ["website_warehouse", "is_stock_item"]) From 8f67ef8a750a0fac04b85935e6a2d5b937666fca Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 25 Oct 2019 18:55:57 +0530 Subject: [PATCH 07/21] fix: Add patch to replace accounting with accounts in home_settings --- erpnext/patches.txt | 1 + .../replace_accounting_with_accounts_in_home_settings.py | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 erpnext/patches/v12_0/replace_accounting_with_accounts_in_home_settings.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 9f98099257..ee6bdff661 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -640,3 +640,4 @@ erpnext.patches.v12_0.create_default_energy_point_rules erpnext.patches.v12_0.set_produced_qty_field_in_sales_order_for_work_order erpnext.patches.v12_0.generate_leave_ledger_entries erpnext.patches.v12_0.set_default_shopify_app_type +erpnext.patches.v12_0.replace_accounting_with_accounts_in_home_settings diff --git a/erpnext/patches/v12_0/replace_accounting_with_accounts_in_home_settings.py b/erpnext/patches/v12_0/replace_accounting_with_accounts_in_home_settings.py new file mode 100644 index 0000000000..09fc4c1b04 --- /dev/null +++ b/erpnext/patches/v12_0/replace_accounting_with_accounts_in_home_settings.py @@ -0,0 +1,5 @@ +import frappe + +def execute(): + frappe.db.sql("""UPDATE `tabUser` SET `home_settings` = REPLACE(`home_settings`, 'Accounting', 'Accounts')""") + frappe.cache().delete_key('home_settings') \ No newline at end of file From 9f483c1fa93baba04ae2735c58feab88ffbab1b6 Mon Sep 17 00:00:00 2001 From: Jai Chavan <40264279+jaichavan@users.noreply.github.com> Date: Sat, 26 Oct 2019 18:45:01 +0530 Subject: [PATCH 08/21] fix: Spelling of Variance --- .../report/budget_variance_report/budget_variance_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/budget_variance_report/budget_variance_report.py b/erpnext/accounts/report/budget_variance_report/budget_variance_report.py index 146c10c222..8d65ac8714 100644 --- a/erpnext/accounts/report/budget_variance_report/budget_variance_report.py +++ b/erpnext/accounts/report/budget_variance_report/budget_variance_report.py @@ -69,7 +69,7 @@ def get_columns(filters): for year in fiscal_year: for from_date, to_date in get_period_date_ranges(filters["period"], year[0]): if filters["period"] == "Yearly": - labels = [_("Budget") + " " + str(year[0]), _("Actual ") + " " + str(year[0]), _("Varaiance ") + " " + str(year[0])] + labels = [_("Budget") + " " + str(year[0]), _("Actual ") + " " + str(year[0]), _("Variance ") + " " + str(year[0])] for label in labels: columns.append(label+":Float:150") else: From ce5200d70045f02345e84634b1ca3f3d9dc7a7f6 Mon Sep 17 00:00:00 2001 From: Sahil Khan Date: Thu, 24 Oct 2019 17:50:19 +0550 Subject: [PATCH 09/21] bumped to version 12.1.7 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 686d5492ca..a06e3db9ae 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '12.1.6' +__version__ = '12.1.7' def get_default_company(user=None): '''Get default company for user''' From e6f86c934dc8100980ac009b1d6e39a51d711d0b Mon Sep 17 00:00:00 2001 From: Sahil Khan Date: Sat, 26 Oct 2019 20:22:19 +0550 Subject: [PATCH 10/21] bumped to version 12.1.8 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index a06e3db9ae..d031bc5bb1 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '12.1.7' +__version__ = '12.1.8' def get_default_company(user=None): '''Get default company for user''' From 83b58352cec927b8b8baec9ebf23dd45a3749195 Mon Sep 17 00:00:00 2001 From: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> Date: Mon, 28 Oct 2019 12:05:30 +0530 Subject: [PATCH 11/21] fix: Overwrite default cost center if item has default cost center set. (#19405) --- erpnext/selling/doctype/sales_order/sales_order.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index af78ab250d..c4c3c0f81e 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -205,7 +205,7 @@ class SalesOrder(SellingController): if self.coupon_code: from erpnext.accounts.doctype.pricing_rule.utils import update_coupon_code_count update_coupon_code_count(self.coupon_code,'cancelled') - + def update_project(self): if frappe.db.get_single_value('Selling Settings', 'sales_update_frequency') != "Each Transaction": return @@ -661,12 +661,15 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False): if source_parent.project: target.cost_center = frappe.db.get_value("Project", source_parent.project, "cost_center") - if not target.cost_center and target.item_code: + if target.item_code: item = get_item_defaults(target.item_code, source_parent.company) item_group = get_item_group_defaults(target.item_code, source_parent.company) - target.cost_center = item.get("selling_cost_center") \ + cost_center = item.get("selling_cost_center") \ or item_group.get("selling_cost_center") + if cost_center: + target.cost_center = cost_center + doclist = get_mapped_doc("Sales Order", source_name, { "Sales Order": { "doctype": "Sales Invoice", From 9942fcc8cb8d2d45ebd285b4876e2f69c725f897 Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Mon, 28 Oct 2019 12:08:31 +0530 Subject: [PATCH 12/21] fix: Better validation msg for difference account in Stock Entry (#19400) * fix: Better validation msg for difference account * fix: Make primary info bold --- erpnext/stock/doctype/stock_entry/stock_entry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 7fa7d3b0b6..55e02a46ff 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -241,7 +241,9 @@ class StockEntry(StockController): for d in self.get("items"): if not d.expense_account: - frappe.throw(_("Please enter Difference Account")) + frappe.throw(_("Please enter Difference Account or set default Stock Adjustment Account for company {0}") + .format(frappe.bold(self.company))) + elif self.is_opening == "Yes" and frappe.db.get_value("Account", d.expense_account, "report_type") == "Profit and Loss": frappe.throw(_("Difference Account must be a Asset/Liability type account, since this Stock Entry is an Opening Entry"), OpeningEntryAccountError) From 8916916a03cffd22b9c26b8a0df7843d37c9ad01 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 28 Oct 2019 13:00:18 +0530 Subject: [PATCH 13/21] fix: 'NoneType' object is not iterable --- .../account_balance_timeline/account_balance_timeline.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py index bc07b6d807..d098d8421c 100644 --- a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py +++ b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import frappe, json +from frappe import _ from frappe.utils import add_to_date, date_diff, getdate, nowdate, get_last_day, formatdate from erpnext.accounts.report.general_ledger.general_ledger import execute from frappe.core.page.dashboard.dashboard import cache_source, get_from_date_from_timespan @@ -24,6 +25,9 @@ def get(chart_name = None, chart = None, no_cache = None, from_date = None, to_d account = filters.get("account") company = filters.get("company") + if not account and chart: + frappe.throw(_("Account is not set for the dashboard chart {0}").format(chart)) + if not to_date: to_date = nowdate() if not from_date: From 88d2c973913b68c0256e7fb4dcab35428585083b Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 28 Oct 2019 17:37:55 +0530 Subject: [PATCH 14/21] fix: default accounts are not added on creation of company --- erpnext/setup/doctype/company/company.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index e69a6aaded..8b42b19921 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -33,6 +33,10 @@ class Company(NestedSet): return exists def validate(self): + self.update_default_account = False + if self.is_new(): + self.update_default_account = True + self.validate_abbr() self.validate_default_accounts() self.validate_currency() @@ -203,8 +207,8 @@ class Company(NestedSet): "default_expense_account": "Cost of Goods Sold" }) - for default_account in default_accounts: - if self.is_new() or frappe.flags.in_test or frappe.flags.in_demo: + if self.update_default_account or frappe.flags.in_test: + for default_account in default_accounts: self._set_default_account(default_account, default_accounts.get(default_account)) if not self.default_income_account: From 4f7885f1aa63f99320c26c8b87b2d32bfacc35ec Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Tue, 29 Oct 2019 13:20:17 +0530 Subject: [PATCH 15/21] chore: fix unexpected keyword in shopify_settings Signed-off-by: Chinmay D. Pai --- .../doctype/shopify_settings/shopify_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.py b/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.py index a4332b199e..0cad0cca72 100644 --- a/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.py +++ b/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.py @@ -43,7 +43,7 @@ class ShopifySettings(Document): d.raise_for_status() self.update_webhook_table(method, d.json()) except Exception as e: - make_shopify_log(status="Warning", message=e, exception=False) + make_shopify_log(status="Warning", exception=e, rollback=True) def unregister_webhooks(self): session = get_request_session() From 702f9f929b46b3edd25ec53b3b3cb9186beeb10d Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Tue, 29 Oct 2019 13:30:13 +0530 Subject: [PATCH 16/21] chore: rename undefined variable in shopify_log Signed-off-by: Chinmay D. Pai --- erpnext/erpnext_integrations/doctype/shopify_log/shopify_log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/erpnext_integrations/doctype/shopify_log/shopify_log.py b/erpnext/erpnext_integrations/doctype/shopify_log/shopify_log.py index 7d3f572978..a2b6af99b2 100644 --- a/erpnext/erpnext_integrations/doctype/shopify_log/shopify_log.py +++ b/erpnext/erpnext_integrations/doctype/shopify_log/shopify_log.py @@ -39,7 +39,7 @@ def get_message(exception): if hasattr(exception, 'message'): message = exception.message elif hasattr(exception, '__str__'): - message = e.__str__() + message = exception.__str__() else: message = "Something went wrong while syncing" return message From 2a72d1fee4bf8d6baed9632bf6dbf58495bc6fd1 Mon Sep 17 00:00:00 2001 From: ahmadRagheb Date: Tue, 29 Oct 2019 19:49:08 +0200 Subject: [PATCH 17/21] Update salary_slip.py getdate imported twice --- erpnext/hr/doctype/salary_slip/salary_slip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 27a51c30e7..46be4fe287 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe, erpnext import datetime, math -from frappe.utils import add_days, cint, cstr, flt, getdate, rounded, date_diff, money_in_words, getdate +from frappe.utils import add_days, cint, cstr, flt, getdate, rounded, date_diff, money_in_words from frappe.model.naming import make_autoname from frappe import msgprint, _ From e127d937f745e58b857d425d2eacc497d49e75cd Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 30 Oct 2019 13:31:05 +0530 Subject: [PATCH 18/21] fix(ExpenseClaim): List filter config for Rejected and Unpaid (#19434) --- erpnext/hr/doctype/expense_claim/expense_claim_list.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/hr/doctype/expense_claim/expense_claim_list.js b/erpnext/hr/doctype/expense_claim/expense_claim_list.js index 0e25e66687..6195ad414a 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim_list.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim_list.js @@ -2,11 +2,11 @@ frappe.listview_settings['Expense Claim'] = { add_fields: ["total_claimed_amount", "docstatus"], get_indicator: function(doc) { if(doc.status == "Paid") { - return [__("Paid"), "green", "status,=,'Paid'"]; + return [__("Paid"), "green", "status,=,Paid"]; }else if(doc.status == "Unpaid") { - return [__("Unpaid"), "orange"]; + return [__("Unpaid"), "orange", "status,=,Unpaid"]; } else if(doc.status == "Rejected") { - return [__("Rejected"), "grey"]; + return [__("Rejected"), "grey", "status,=,Rejected"]; } } }; From 5c9d92eabf6cc06eb745ca77ca4d2374650ddab8 Mon Sep 17 00:00:00 2001 From: Anurag Mishra <32095923+Anurag810@users.noreply.github.com> Date: Wed, 30 Oct 2019 14:18:16 +0530 Subject: [PATCH 19/21] fix: On Specific case if no item code in name (#19419) --- erpnext/manufacturing/doctype/bom/bom.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 225ae29429..c15b52ea38 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -39,9 +39,11 @@ class BOM(WebsiteGenerator): names = [d[-1][1:] for d in filter(lambda x: len(x) > 1 and x[-1], names)] # split by (-) if cancelled - names = [cint(name.split('-')[-1]) for name in names] - - idx = max(names) + 1 + if names: + names = [cint(name.split('-')[-1]) for name in names] + idx = max(names) + 1 + else: + idx = 1 else: idx = 1 From 7638788c2f3f3fab80f2ef782bf843b17f428b46 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Wed, 30 Oct 2019 14:23:41 +0530 Subject: [PATCH 20/21] fix: calculate pending leaves (#19411) --- .../hr/doctype/leave_application/leave_application.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 97de40ffee..b73028e50a 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -503,14 +503,17 @@ def get_leave_allocation_records(employee, date, leave_type=None): def get_pending_leaves_for_period(employee, leave_type, from_date, to_date): ''' Returns leaves that are pending approval ''' - return frappe.db.get_value("Leave Application", + leaves = frappe.get_all("Leave Application", filters={ "employee": employee, "leave_type": leave_type, - "from_date": ("<=", from_date), - "to_date": (">=", to_date), "status": "Open" - }, fieldname=['SUM(total_leave_days)']) or flt(0) + }, + or_filters={ + "from_date": ["between", (from_date, to_date)], + "to_date": ["between", (from_date, to_date)] + }, fields=['SUM(total_leave_days) as leaves'])[0] + return leaves['leaves'] if leaves['leaves'] else 0.0 def get_remaining_leaves(allocation, leaves_taken, date, expiry): ''' Returns minimum leaves remaining after comparing with remaining days for allocation expiry ''' From 83c7b5b44b40d3a61ec5e9f36dcfec88949a0515 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Wed, 30 Oct 2019 14:25:50 +0530 Subject: [PATCH 21/21] fix(bom): maintain a default bom for an item (#19407) --- erpnext/manufacturing/doctype/bom/bom.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index c15b52ea38..c849f5b7f2 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -292,7 +292,8 @@ class BOM(WebsiteGenerator): return valuation_rate def manage_default_bom(self): - """ Uncheck others if current one is selected as default, + """ Uncheck others if current one is selected as default or + check the current one as default if it the only bom for the selected item, update default bom in item master """ if self.is_default and self.is_active: @@ -301,6 +302,9 @@ class BOM(WebsiteGenerator): item = frappe.get_doc("Item", self.item) if item.default_bom != self.name: frappe.db.set_value('Item', self.item, 'default_bom', self.name) + elif not frappe.db.exists(dict(doctype='BOM', docstatus=1, item=self.item, is_default=1)) \ + and self.is_active: + frappe.db.set(self, "is_default", 1) else: frappe.db.set(self, "is_default", 0) item = frappe.get_doc("Item", self.item)