From a175e06149b130dce7433a95c532d98e4d59d3f6 Mon Sep 17 00:00:00 2001 From: racitup Date: Mon, 20 Jan 2020 18:56:35 +0000 Subject: [PATCH 01/12] fix: pymysql.err.InternalError about t2.bank_account_no due to removal of field from Journal Entry Account table: #20343 --- .../doctype/bank_reconciliation/bank_reconciliation.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index 90cdf834c59..3613a1ef696 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -21,10 +21,6 @@ class BankReconciliation(Document): if not self.include_reconciled_entries: condition = " and (clearance_date is null or clearance_date='0000-00-00')" - account_cond = "" - if self.bank_account_no: - account_cond = " and t2.bank_account_no = {0}".format(frappe.db.escape(self.bank_account_no)) - journal_entries = frappe.db.sql(""" select "Journal Entry" as payment_document, t1.name as payment_entry, @@ -36,10 +32,10 @@ class BankReconciliation(Document): where t2.parent = t1.name and t2.account = %s and t1.docstatus=1 and t1.posting_date >= %s and t1.posting_date <= %s - and ifnull(t1.is_opening, 'No') = 'No' {0} {1} + and ifnull(t1.is_opening, 'No') = 'No' {0} group by t2.account, t1.name order by t1.posting_date ASC, t1.name DESC - """.format(condition, account_cond), (self.bank_account, self.from_date, self.to_date), as_dict=1) + """.format(condition), (self.bank_account, self.from_date, self.to_date), as_dict=1) if self.bank_account_no: condition = " and bank_account = %(bank_account_no)s" From feaa82a8eab5b5c415cdbff718b6eb64b1aaf9d6 Mon Sep 17 00:00:00 2001 From: racitup Date: Mon, 20 Jan 2020 19:41:08 +0000 Subject: [PATCH 02/12] fix: KeyError about bank_account_no due to non-existent field: #20343 --- .../doctype/bank_reconciliation/bank_reconciliation.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index 3613a1ef696..d5ba49abd0f 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -68,11 +68,10 @@ class BankReconciliation(Document): from `tabSales Invoice Payment` sip, `tabSales Invoice` si, `tabAccount` account where sip.account=%(account)s and si.docstatus=1 and sip.parent = si.name - and account.name = sip.account and si.posting_date >= %(from)s and si.posting_date <= %(to)s {0} + and account.name = sip.account and si.posting_date >= %(from)s and si.posting_date <= %(to)s order by si.posting_date ASC, si.name DESC - """.format(condition), - {"account":self.bank_account, "from":self.from_date, "to":self.to_date}, as_dict=1) + """, {"account":self.bank_account, "from":self.from_date, "to":self.to_date}, as_dict=1) entries = sorted(list(payment_entries)+list(journal_entries+list(pos_entries)), key=lambda k: k['posting_date'] or getdate(nowdate())) From a05450821182bce276f1242761b5b2a670b03663 Mon Sep 17 00:00:00 2001 From: racitup Date: Tue, 21 Jan 2020 00:47:10 +0000 Subject: [PATCH 03/12] fix: Plaid automatic_synchronization TypeError on filter & add info log message #20343 --- .../doctype/plaid_settings/plaid_settings.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py index a04d6c5be73..9e22dc07bb6 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py @@ -133,8 +133,11 @@ def sync_transactions(bank, bank_account): try: transactions = get_transactions(bank=bank, bank_account=bank_account, start_date=start_date, end_date=end_date) + result = [] if transactions: + frappe.logger().info("Plaid is adding {} Bank Transactions from '{}' between {} and {}".format( + len(transactions), bank_account, start_date, end_date)) for transaction in transactions: result.append(new_bank_transaction(transaction)) @@ -201,7 +204,7 @@ def automatic_synchronization(): settings = frappe.get_doc("Plaid Settings", "Plaid Settings") if settings.enabled == 1 and settings.automatic_sync == 1: - plaid_accounts = frappe.get_all("Bank Account", filter={"integration_id": ["!=", ""]}, fields=["name", "bank"]) + plaid_accounts = frappe.get_all("Bank Account", filters={"integration_id": ["!=", ""]}, fields=["name", "bank"]) for plaid_account in plaid_accounts: frappe.enqueue("erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.sync_transactions", bank=plaid_account.bank, bank_account=plaid_account.name) From bee017e17c78aed52dee5ebf4f92fa4184dfa08e Mon Sep 17 00:00:00 2001 From: racitup Date: Tue, 21 Jan 2020 15:07:47 +0000 Subject: [PATCH 04/12] fix: Plaid transaction import order, transaction_id duplicate check, added transaction category tags --- .../doctype/plaid_settings/plaid_settings.py | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py index 9e22dc07bb6..970793f7468 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py @@ -10,6 +10,7 @@ from frappe.model.document import Document from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account from erpnext.erpnext_integrations.doctype.plaid_settings.plaid_connector import PlaidConnector from frappe.utils import getdate, formatdate, today, add_months +from frappe.desk.doctype.tag.tag import add_tag class PlaidSettings(Document): pass @@ -135,11 +136,11 @@ def sync_transactions(bank, bank_account): transactions = get_transactions(bank=bank, bank_account=bank_account, start_date=start_date, end_date=end_date) result = [] - if transactions: - frappe.logger().info("Plaid is adding {} Bank Transactions from '{}' between {} and {}".format( - len(transactions), bank_account, start_date, end_date)) - for transaction in transactions: - result.append(new_bank_transaction(transaction)) + for transaction in reversed(transactions): + result += new_bank_transaction(transaction) + + frappe.logger().info("Plaid added {} new Bank Transactions from '{}' between {} and {}".format( + len(result), bank_account, start_date, end_date)) frappe.db.set_value("Bank Account", bank_account, "last_integration_date", getdate(end_date)) @@ -178,6 +179,13 @@ def new_bank_transaction(transaction): status = "Pending" if transaction["pending"] == "True" else "Settled" + try: + tags = [] + tags += transaction["category"] + tags += ["Plaid Cat. {}".format(transaction["category_id"])] + except KeyError: + pass + if not frappe.db.exists("Bank Transaction", dict(transaction_id=transaction["transaction_id"])): try: new_transaction = frappe.get_doc({ @@ -188,11 +196,16 @@ def new_bank_transaction(transaction): "debit": debit, "credit": credit, "currency": transaction["iso_currency_code"], + "transaction_id": transaction["transaction_id"], + "reference_number": transaction["payment_meta"]["reference_number"], "description": transaction["name"] }) new_transaction.insert() new_transaction.submit() + for tag in tags: + add_tag(tag, "Bank Transaction", new_transaction.name) + result.append(new_transaction.name) except Exception: From a1e3202054235d7b7ab30ec3b3b3cb78eabf86b0 Mon Sep 17 00:00:00 2001 From: racitup Date: Wed, 22 Jan 2020 04:32:15 +0000 Subject: [PATCH 05/12] fix: Bank Reconciliation Bank Account and Bank Account No field names --- .../bank_reconciliation.js | 6 +++--- .../bank_reconciliation.json | 18 +++++++--------- .../bank_reconciliation.py | 21 ++++++++----------- .../rename_bank_reconciliation_fields.py | 16 ++++++++++++++ 4 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 erpnext/patches/v12_0/rename_bank_reconciliation_fields.py diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js index 7c94455b9ba..19fadbf6ded 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js @@ -3,16 +3,16 @@ frappe.ui.form.on("Bank Reconciliation", { setup: function(frm) { - frm.add_fetch("bank_account", "account_currency", "account_currency"); + frm.add_fetch("account", "account_currency", "account_currency"); }, onload: function(frm) { let default_bank_account = frappe.defaults.get_user_default("Company")? locals[":Company"][frappe.defaults.get_user_default("Company")]["default_bank_account"]: ""; - frm.set_value("bank_account", default_bank_account); + frm.set_value("account", default_bank_account); - frm.set_query("bank_account", function() { + frm.set_query("account", function() { return { "filters": { "account_type": ["in",["Bank","Cash"]], diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json index e2f967daccb..b85ef3e9c4d 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json @@ -19,10 +19,9 @@ "bold": 0, "collapsible": 0, "columns": 0, - "description": "Select account head of the bank where cheque was deposited.", - "fetch_from": "bank_account_no.account", + "fetch_from": "bank_account.account", "fetch_if_empty": 1, - "fieldname": "bank_account", + "fieldname": "account", "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, @@ -31,7 +30,7 @@ "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 0, - "label": "Bank Account", + "label": "Account", "length": 0, "no_copy": 0, "options": "Account", @@ -164,7 +163,6 @@ "length": 0, "no_copy": 0, "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -183,8 +181,9 @@ "bold": 0, "collapsible": 0, "columns": 0, + "description": "Select the Bank Account to reconcile.", "fetch_if_empty": 0, - "fieldname": "bank_account_no", + "fieldname": "bank_account", "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, @@ -193,12 +192,11 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Bank Account No", + "label": "Bank Account", "length": 0, "no_copy": 0, "options": "Bank Account", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -450,7 +448,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2019-04-09 18:41:06.110453", + "modified": "2020-01-22 00:00:00.000000", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Reconciliation", @@ -483,4 +481,4 @@ "track_changes": 0, "track_seen": 0, "track_views": 0 -} \ No newline at end of file +} diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index d5ba49abd0f..804bcd8bdf0 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -30,15 +30,12 @@ class BankReconciliation(Document): from `tabJournal Entry` t1, `tabJournal Entry Account` t2 where - t2.parent = t1.name and t2.account = %s and t1.docstatus=1 - and t1.posting_date >= %s and t1.posting_date <= %s - and ifnull(t1.is_opening, 'No') = 'No' {0} + t2.parent = t1.name and t2.account = %(account)s and t1.docstatus=1 + and t1.posting_date >= %(from)s and t1.posting_date <= %(to)s + and ifnull(t1.is_opening, 'No') = 'No' %(condition)s group by t2.account, t1.name order by t1.posting_date ASC, t1.name DESC - """.format(condition), (self.bank_account, self.from_date, self.to_date), as_dict=1) - - if self.bank_account_no: - condition = " and bank_account = %(bank_account_no)s" + """, {"condition":condition, "account":self.account, "from":self.from_date, "to":self.to_date}, as_dict=1) payment_entries = frappe.db.sql(""" select @@ -51,12 +48,12 @@ class BankReconciliation(Document): from `tabPayment Entry` where (paid_from=%(account)s or paid_to=%(account)s) and docstatus=1 - and posting_date >= %(from)s and posting_date <= %(to)s {0} + and posting_date >= %(from)s and posting_date <= %(to)s + and bank_account = %(bank_account)s order by posting_date ASC, name DESC - """.format(condition), - {"account":self.bank_account, "from":self.from_date, - "to":self.to_date, "bank_account_no": self.bank_account_no}, as_dict=1) + """, {"account":self.account, "from":self.from_date, + "to":self.to_date, "bank_account": self.bank_account}, as_dict=1) pos_entries = [] if self.include_pos_transactions: @@ -71,7 +68,7 @@ class BankReconciliation(Document): and account.name = sip.account and si.posting_date >= %(from)s and si.posting_date <= %(to)s order by si.posting_date ASC, si.name DESC - """, {"account":self.bank_account, "from":self.from_date, "to":self.to_date}, as_dict=1) + """, {"account":self.account, "from":self.from_date, "to":self.to_date}, as_dict=1) entries = sorted(list(payment_entries)+list(journal_entries+list(pos_entries)), key=lambda k: k['posting_date'] or getdate(nowdate())) diff --git a/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py b/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py new file mode 100644 index 00000000000..8918b9df7a0 --- /dev/null +++ b/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py @@ -0,0 +1,16 @@ +import frappe + +def _rename_single_field(**kwargs): + count = frappe.db.sql("SELECT COUNT(*) FROM tabSingles WHERE doctype='{doctype}' AND field='{new_name}';".format(**kwargs))[0][0] + if count == 0: + frappe.db.sql("UPDATE tabSingles SET field='{new_name}' WHERE doctype='{doctype}' AND field='{old_name}';".format(**kwargs)) + +def execute(): + BR = "Bank Reconciliation" + AC = "account" + BA = "bank_account" + BAN = "bank_account_no" + + _rename_single_field(doctype = BR, old_name = BA , new_name = AC) + _rename_single_field(doctype = BR, old_name = BAN, new_name = BA) + frappe.reload_doc("Accounts", "doctype", BR) From eef73a0d920598f5722ae324aed18a274b23be47 Mon Sep 17 00:00:00 2001 From: racitup Date: Fri, 24 Jan 2020 23:40:16 +0000 Subject: [PATCH 06/12] manually added patch for bank reconciliation fields since develop branch was in a different place #20380 --- erpnext/patches.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 17c9a20766d..bbb875a3191 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -648,3 +648,4 @@ erpnext.patches.v12_0.update_owner_fields_in_acc_dimension_custom_fields erpnext.patches.v12_0.remove_denied_leaves_from_leave_ledger erpnext.patches.v12_0.update_price_or_product_discount erpnext.patches.v12_0.add_export_type_field_in_party_master +erpnext.patches.v12_0.rename_bank_reconciliation_fields # 2020-01-22 From 814001a90fcf84e910136cfead34973cdef434e5 Mon Sep 17 00:00:00 2001 From: racitup Date: Wed, 22 Jan 2020 04:41:41 +0000 Subject: [PATCH 07/12] fix: attempt at pymysql InternalError 1054 about clearance_date in field list when removing payments from bank transactions --- .../bank_transaction_payments.json | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/bank_transaction_payments/bank_transaction_payments.json b/erpnext/accounts/doctype/bank_transaction_payments/bank_transaction_payments.json index a75e866997d..ab3f60d32c0 100644 --- a/erpnext/accounts/doctype/bank_transaction_payments/bank_transaction_payments.json +++ b/erpnext/accounts/doctype/bank_transaction_payments/bank_transaction_payments.json @@ -110,6 +110,15 @@ "set_only_once": 0, "translatable": 0, "unique": 0 + }, + { + "depends_on": "eval:doc.docstatus==1", + "fieldname": "clearance_date", + "fieldtype": "Date", + "label": "Clearance Date", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 } ], "has_web_view": 0, @@ -122,7 +131,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-12-06 10:57:02.635141", + "modified": "2020-01-22 00:00:00.000000", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Transaction Payments", @@ -138,4 +147,4 @@ "track_changes": 1, "track_seen": 0, "track_views": 0 -} \ No newline at end of file +} From 08661250d231f07a5068db3903a6bb16134c5eed Mon Sep 17 00:00:00 2001 From: racitup Date: Thu, 30 Jan 2020 14:48:42 +0000 Subject: [PATCH 08/12] Ignore codacy SQL injection warning (internal code only) and add copyright notice --- erpnext/patches/v12_0/rename_bank_reconciliation_fields.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py b/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py index 8918b9df7a0..01b1dde6073 100644 --- a/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py +++ b/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py @@ -1,9 +1,12 @@ +# Copyright (c) 2020, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + import frappe def _rename_single_field(**kwargs): - count = frappe.db.sql("SELECT COUNT(*) FROM tabSingles WHERE doctype='{doctype}' AND field='{new_name}';".format(**kwargs))[0][0] + count = frappe.db.sql("SELECT COUNT(*) FROM tabSingles WHERE doctype='{doctype}' AND field='{new_name}';".format(**kwargs))[0][0] #nosec if count == 0: - frappe.db.sql("UPDATE tabSingles SET field='{new_name}' WHERE doctype='{doctype}' AND field='{old_name}';".format(**kwargs)) + frappe.db.sql("UPDATE tabSingles SET field='{new_name}' WHERE doctype='{doctype}' AND field='{old_name}';".format(**kwargs)) #nosec def execute(): BR = "Bank Reconciliation" From f5bff5f15d69b44ec86c8c39f539eb3e0c2dd055 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 7 Feb 2020 15:25:43 +0530 Subject: [PATCH 09/12] fix: Styling and minor fixes --- .../bank_reconciliation/bank_reconciliation.py | 6 +++--- .../doctype/plaid_settings/plaid_settings.json | 7 ++++--- .../v12_0/rename_bank_reconciliation_fields.py | 11 +++-------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index 804bcd8bdf0..52bbe3327a8 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -35,7 +35,7 @@ class BankReconciliation(Document): and ifnull(t1.is_opening, 'No') = 'No' %(condition)s group by t2.account, t1.name order by t1.posting_date ASC, t1.name DESC - """, {"condition":condition, "account":self.account, "from":self.from_date, "to":self.to_date}, as_dict=1) + """, {"condition":condition, "account": self.account, "from": self.from_date, "to": self.to_date}, as_dict=1) payment_entries = frappe.db.sql(""" select @@ -52,8 +52,8 @@ class BankReconciliation(Document): and bank_account = %(bank_account)s order by posting_date ASC, name DESC - """, {"account":self.account, "from":self.from_date, - "to":self.to_date, "bank_account": self.bank_account}, as_dict=1) + """, {"account": self.account, "from":self.from_date, + "to": self.to_date, "bank_account": self.bank_account}, as_dict=1) pos_entries = [] if self.include_pos_transactions: diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.json b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.json index df77ad8bc93..d8203d7390f 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.json +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.json @@ -49,9 +49,10 @@ }, { "fieldname": "plaid_env", - "fieldtype": "Data", + "fieldtype": "Select", "in_list_view": 1, - "label": "Plaid Environment" + "label": "Plaid Environment", + "options": "sandbox\ndevelopment\nproduction" }, { "fieldname": "column_break_2", @@ -69,7 +70,7 @@ ], "issingle": 1, "links": [], - "modified": "2020-01-05 10:00:22.137832", + "modified": "2020-02-07 15:21:11.616231", "modified_by": "Administrator", "module": "ERPNext Integrations", "name": "Plaid Settings", diff --git a/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py b/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py index 01b1dde6073..caeda8ae61b 100644 --- a/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py +++ b/erpnext/patches/v12_0/rename_bank_reconciliation_fields.py @@ -9,11 +9,6 @@ def _rename_single_field(**kwargs): frappe.db.sql("UPDATE tabSingles SET field='{new_name}' WHERE doctype='{doctype}' AND field='{old_name}';".format(**kwargs)) #nosec def execute(): - BR = "Bank Reconciliation" - AC = "account" - BA = "bank_account" - BAN = "bank_account_no" - - _rename_single_field(doctype = BR, old_name = BA , new_name = AC) - _rename_single_field(doctype = BR, old_name = BAN, new_name = BA) - frappe.reload_doc("Accounts", "doctype", BR) + _rename_single_field(doctype = "Bank Reconciliation", old_name = "bank_account" , new_name = "account") + _rename_single_field(doctype = "Bank Reconciliation", old_name = "bank_account_no", new_name = "bank_account") + frappe.reload_doc("Accounts", "doctype", "Bank Reconciliation") From efbfeb2d89830c32720e3fd3feb1c2707046e862 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Mon, 17 Feb 2020 10:50:05 +0530 Subject: [PATCH 10/12] fix: filters for quality_procedure tree --- .../doctype/quality_procedure/quality_procedure_tree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/quality_management/doctype/quality_procedure/quality_procedure_tree.js b/erpnext/quality_management/doctype/quality_procedure/quality_procedure_tree.js index dbdbbab3925..6df6f656aa1 100644 --- a/erpnext/quality_management/doctype/quality_procedure/quality_procedure_tree.js +++ b/erpnext/quality_management/doctype/quality_procedure/quality_procedure_tree.js @@ -4,7 +4,7 @@ frappe.treeview_settings["Quality Procedure"] = { add_tree_node: 'erpnext.quality_management.doctype.quality_procedure.quality_procedure.add_node', filters: [ { - fieldname: "quality_procedure", + fieldname: "parent_quality_procedure", fieldtype: "Link", options: "Quality Procedure", label: __("Quality Procedure"), From 1ed737cf6488389114abd833d6660b4178b1b101 Mon Sep 17 00:00:00 2001 From: marination Date: Tue, 18 Feb 2020 21:35:59 +0530 Subject: [PATCH 11/12] fix: Set Query on warehouse fields in Stock Settings --- erpnext/stock/doctype/stock_settings/stock_settings.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.js b/erpnext/stock/doctype/stock_settings/stock_settings.js index 49ce3d8ef7a..755c4307187 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.js +++ b/erpnext/stock/doctype/stock_settings/stock_settings.js @@ -3,6 +3,15 @@ frappe.ui.form.on('Stock Settings', { refresh: function(frm) { + let filters = function() { + return { + filters : { + is_group : 0 + } + }; + } + frm.set_query("default_warehouse", filters); + frm.set_query("sample_retention_warehouse", filters); } }); From 0119d15adb491d87dc8739c4cfa7a39c3e4caafe Mon Sep 17 00:00:00 2001 From: marination Date: Wed, 19 Feb 2020 11:05:58 +0530 Subject: [PATCH 12/12] fix: Server side validation for Warehouses --- erpnext/stock/doctype/stock_settings/stock_settings.js | 6 +++--- erpnext/stock/doctype/stock_settings/stock_settings.py | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.js b/erpnext/stock/doctype/stock_settings/stock_settings.js index 755c4307187..cc0e2cfc425 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.js +++ b/erpnext/stock/doctype/stock_settings/stock_settings.js @@ -5,11 +5,11 @@ frappe.ui.form.on('Stock Settings', { refresh: function(frm) { let filters = function() { return { - filters : { + filters : { is_group : 0 - } + } }; - } + }; frm.set_query("default_warehouse", filters); frm.set_query("sample_retention_warehouse", filters); diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.py b/erpnext/stock/doctype/stock_settings/stock_settings.py index 65de2e58d3a..93b5eee75c2 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.py +++ b/erpnext/stock/doctype/stock_settings/stock_settings.py @@ -30,9 +30,17 @@ class StockSettings(Document): frappe.make_property_setter({'fieldname': name, 'property': 'hidden', 'value': 0 if self.show_barcode_field else 1}) + self.validate_warehouses() self.cant_change_valuation_method() self.validate_clean_description_html() + def validate_warehouses(self): + warehouse_fields = ["default_warehouse", "sample_retention_warehouse"] + for field in warehouse_fields: + if frappe.db.get_value("Warehouse", self.get(field), "is_group"): + frappe.throw(_("Group Warehouses cannot be used in transactions. Please change the value of {0}") \ + .format(frappe.bold(self.meta.get_field(field).label)), title =_("Incorrect Warehouse")) + def cant_change_valuation_method(self): db_valuation_method = frappe.db.get_single_value("Stock Settings", "valuation_method")