From 87037bdd5644db8d90262ca8f20d07c88f541ee9 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 30 Jan 2017 12:29:54 +0530 Subject: [PATCH] [minor] remove party status as it leads to duplicate notifications fixes #7346, also fix for #7568 --- .../doctype/payment_entry/payment_entry.json | 240 +++++++++++------- .../payment_reconciliation_payment.json | 27 +- .../sales_invoice/test_sales_invoice.py | 34 --- erpnext/accounts/party_status.py | 81 ------ erpnext/buying/doctype/supplier/supplier.json | 39 +-- erpnext/buying/doctype/supplier/supplier.py | 2 - erpnext/controllers/status_updater.py | 2 - erpnext/crm/doctype/lead/lead.py | 7 +- erpnext/hooks.py | 7 - erpnext/patches.txt | 1 + erpnext/patches/v7_0/update_party_status.py | 3 +- erpnext/patches/v7_2/set_party_status.py | 10 + erpnext/selling/doctype/customer/customer.py | 2 - .../doctype/quotation/test_quotation.py | 41 --- erpnext/startup/notifications.py | 8 +- 15 files changed, 194 insertions(+), 310 deletions(-) delete mode 100644 erpnext/accounts/party_status.py create mode 100644 erpnext/patches/v7_2/set_party_status.py diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json index c56a83dcaf..dafa67ab3c 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.json +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json @@ -97,95 +97,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type)", - "fieldname": "party_type", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "in_standard_filter": 1, - "label": "Party Type", - "length": 0, - "no_copy": 0, - "options": "Customer\nSupplier", - "permlevel": 0, - "precision": "", - "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_on_submit": 0, - "bold": 1, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.party_type", - "fieldname": "party", - "fieldtype": "Dynamic Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "in_standard_filter": 1, - "label": "Party", - "length": 0, - "no_copy": 0, - "options": "party_type", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_on_submit": 1, - "bold": 0, - "collapsible": 0, - "columns": 0, - "description": "", - "fieldname": "party_name", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Party Name", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, { "allow_on_submit": 0, "bold": 0, @@ -300,6 +211,152 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.party_type", + "fieldname": "party_section", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Payment From / To", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type)", + "fieldname": "party_type", + "fieldtype": "Select", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "in_standard_filter": 1, + "label": "Party Type", + "length": 0, + "no_copy": 0, + "options": "Customer\nSupplier", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 1, + "collapsible": 0, + "columns": 0, + "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.party_type", + "fieldname": "party", + "fieldtype": "Dynamic Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "in_standard_filter": 1, + "label": "Party", + "length": 0, + "no_copy": 0, + "options": "party_type", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_11", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 1, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.party_type", + "description": "", + "fieldname": "party_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Party Name", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -1561,7 +1618,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-11-07 05:33:40.371480", + "modified": "2017-01-30 00:41:51.348616", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Entry", @@ -1578,7 +1635,6 @@ "export": 1, "if_owner": 0, "import": 1, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -1599,7 +1655,6 @@ "export": 1, "if_owner": 0, "import": 1, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -1617,5 +1672,6 @@ "sort_field": "modified", "sort_order": "DESC", "title_field": "title", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json index f77560c139..57fce65643 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json +++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json @@ -22,6 +22,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Reference Type", "length": 0, "no_copy": 0, @@ -30,6 +31,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -48,7 +50,8 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, - "label": "Reference_name", + "in_standard_filter": 0, + "label": "Reference Name", "length": 0, "no_copy": 0, "options": "reference_type", @@ -57,6 +60,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -75,6 +79,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Posting Date", "length": 0, "no_copy": 0, @@ -82,6 +87,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -100,6 +106,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Is Advance", "length": 0, "no_copy": 0, @@ -107,6 +114,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -125,6 +133,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Reference Row", "length": 0, "no_copy": 0, @@ -132,6 +141,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -150,6 +160,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "", "length": 0, "no_copy": 0, @@ -157,6 +168,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -175,6 +187,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Invoice Number", "length": 0, "no_copy": 0, @@ -183,6 +196,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 1, "search_index": 0, @@ -201,6 +215,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Amount", "length": 0, "no_copy": 0, @@ -208,6 +223,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -226,6 +242,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Allocated amount", "length": 0, "no_copy": 0, @@ -234,6 +251,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 1, "search_index": 0, @@ -252,6 +270,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "", "length": 0, "no_copy": 0, @@ -259,6 +278,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -277,6 +297,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Remark", "length": 0, "no_copy": 0, @@ -284,6 +305,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -302,7 +324,7 @@ "istable": 1, "max_attachments": 0, "menu_index": 0, - "modified": "2016-08-26 02:08:35.879133", + "modified": "2017-01-30 01:04:22.557237", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Payment", @@ -314,5 +336,6 @@ "read_only_onload": 0, "sort_field": "modified", "sort_order": "DESC", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 3eb2f7d7d1..3dfe680883 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -963,40 +963,6 @@ class TestSalesInvoice(unittest.TestCase): si.insert() self.assertEqual(si.get("items")[0].rate, flt((price_list_rate*25)/100 + price_list_rate)) - def test_party_status(self): - from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry - from frappe.utils import random_string - - customer_name = 'test customer for status' - - if frappe.db.exists('Customer', customer_name): - customer = frappe.get_doc('Customer', customer_name) - customer.db_set('status', 'Active') - else: - customer = frappe.get_doc({ - 'doctype': 'Customer', - 'customer_name': customer_name, - 'customer_group': 'Commercial', - 'customer_type': 'Individual', - 'territory': 'Rest of the World' - }).insert() - - self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Active') - - invoice = create_sales_invoice(customer="test customer for status", - debit_to="_Test Receivable - _TC", - currency="USD", conversion_rate=50) - - self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Open') - - pe = get_payment_entry(invoice.doctype, invoice.name) - pe.reference_no = random_string(10) - pe.reference_date = invoice.posting_date - pe.insert() - pe.submit() - - self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Active') - def test_outstanding_amount_after_advance_jv_cancelation(self): from erpnext.accounts.doctype.journal_entry.test_journal_entry \ import test_records as jv_test_records diff --git a/erpnext/accounts/party_status.py b/erpnext/accounts/party_status.py deleted file mode 100644 index 6d9efb190b..0000000000 --- a/erpnext/accounts/party_status.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals - -import frappe - -from frappe.utils import evaluate_filters -from frappe.desk.notifications import get_filters_for - -# NOTE: if you change this also update triggers in erpnext/hooks.py -status_depends_on = { - 'Customer': ('Opportunity', 'Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice', 'Project', 'Issue'), - 'Supplier': ('Supplier Quotation', 'Purchase Order', 'Purchase Receipt', 'Purchase Invoice') -} - -default_status = { - 'Customer': 'Active', - 'Supplier': None -} - -def notify_status(doc, method=None): - '''Notify status to customer, supplier''' - - party_type = None - for key, doctypes in status_depends_on.iteritems(): - if doc.doctype in doctypes: - party_type = key - break - - if not party_type: - return - - name = doc.get(party_type.lower()) - if not name: - return - - party = frappe.get_doc(party_type, name) - filters = get_filters_for(doc.doctype) - party.flags.ignore_mandatory = True - - status = None - if filters: - if evaluate_filters(doc, filters): - # filters match, passed document is open - status = 'Open' - - if status=='Open': - if party.status != 'Open': - # party not open, make it open - party.status = 'Open' - party.save(ignore_permissions=True) - - else: - if party.status == 'Open': - # may be open elsewhere, check - # default status - update_status(party) - - party.update_modified() - party.notify_update() - -def get_party_status(doc): - '''return party status based on open documents''' - status = default_status[doc.doctype] - for doctype in status_depends_on[doc.doctype]: - filters = get_filters_for(doctype) - filters[doc.doctype.lower()] = doc.name - if filters: - open_count = frappe.get_all(doctype, fields='name', filters=filters, limit_page_length=1) - if len(open_count) > 0: - status = 'Open' - break - - return status - -def update_status(doc): - '''Set status as open if there is any open notification''' - status = get_party_status(doc) - if doc.status != status: - doc.db_set('status', status) diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json index 4b8f8c5231..277a5b96a9 100644 --- a/erpnext/buying/doctype/supplier/supplier.json +++ b/erpnext/buying/doctype/supplier/supplier.json @@ -158,35 +158,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "status", - "fieldtype": "Select", - "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Status", - "length": 0, - "no_copy": 0, - "options": "\nOpen", - "permlevel": 0, - "precision": "", - "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, { "allow_on_submit": 0, "bold": 0, @@ -796,7 +767,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-11-07 05:24:30.465053", + "modified": "2017-01-30 00:52:31.193443", "modified_by": "Administrator", "module": "Buying", "name": "Supplier", @@ -813,7 +784,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -834,7 +804,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -855,7 +824,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -876,7 +844,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 0, "read": 1, @@ -897,7 +864,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -918,7 +884,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 0, "read": 1, @@ -939,7 +904,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -957,5 +921,6 @@ "search_fields": "supplier_name, supplier_type", "sort_order": "ASC", "title_field": "supplier_name", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index 7f92767279..704e8285b1 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -11,7 +11,6 @@ from frappe.geo.address_and_contact import (load_address_and_contact, from erpnext.utilities.transaction_base import TransactionBase from erpnext.accounts.party import validate_party_accounts, get_timeline_data # keep this -from erpnext.accounts.party_status import get_party_status class Supplier(TransactionBase): def get_feed(self): @@ -59,7 +58,6 @@ class Supplier(TransactionBase): msgprint(_("Series is mandatory"), raise_exception=1) validate_party_accounts(self) - self.status = get_party_status(self) def on_trash(self): delete_contact_and_address('Supplier', self.name) diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 4fbee58c84..55bcaf387f 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -6,7 +6,6 @@ import frappe from frappe.utils import flt, comma_or, nowdate, getdate from frappe import _ from frappe.model.document import Document -from erpnext.accounts.party_status import notify_status def validate_status(status, options): if status not in options: @@ -287,7 +286,6 @@ class StatusUpdater(Document): target = frappe.get_doc(args["target_parent_dt"], args["name"]) target.set_status(update=True) target.notify_update() - notify_status(target) def _update_modified(self, args, update_modified): args['update_modified'] = '' diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py index 411f59730e..a268ea2235 100644 --- a/erpnext/crm/doctype/lead/lead.py +++ b/erpnext/crm/doctype/lead/lead.py @@ -4,7 +4,8 @@ from __future__ import unicode_literals import frappe from frappe import _ -from frappe.utils import cstr, validate_email_add, cint, comma_and, has_gravatar, nowdate +from frappe.utils import (cstr, validate_email_add, cint, comma_and, has_gravatar, + getdate, nowdate) from frappe.model.mapper import get_mapped_doc from erpnext.controllers.selling_controller import SellingController @@ -45,7 +46,7 @@ class Lead(SellingController): self.image = has_gravatar(self.email_id) - if self.contact_date and self.contact_date < nowdate(): + if self.contact_date and getdate(self.contact_date) < nowdate(): frappe.throw(_("Next Contact Date cannot be in the past")) def on_update(self): @@ -87,7 +88,7 @@ class Lead(SellingController): "lead": self.name, "docstatus": 1, "status": ["!=", "Lost"] - + }) def has_lost_quotation(self): diff --git a/erpnext/hooks.py b/erpnext/hooks.py index dac7c6bde8..8705e98f4d 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -149,13 +149,6 @@ doc_events = { "on_update": "erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings.validate_cart_settings" }, - # bubble transaction notification on master - ('Opportunity', 'Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice', - 'Supplier Quotation', 'Purchase Order', 'Purchase Receipt', - 'Purchase Invoice', 'Project', 'Issue'): { - 'on_change': 'erpnext.accounts.party_status.notify_status' - }, - "Website Settings": { "validate": "erpnext.portal.doctype.products_settings.products_settings.home_page_is_products" }, diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 87c070e069..fcd79e213e 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -369,3 +369,4 @@ erpnext.patches.v7_2.mark_students_active erpnext.patches.v7_2.set_null_value_to_fields erpnext.patches.v7_2.update_guardian_name_in_student_master erpnext.patches.v7_2.update_abbr_in_salary_slips +execute:patches.v7_2.set_party_status \ No newline at end of file diff --git a/erpnext/patches/v7_0/update_party_status.py b/erpnext/patches/v7_0/update_party_status.py index 208b47639b..f3733dbd84 100644 --- a/erpnext/patches/v7_0/update_party_status.py +++ b/erpnext/patches/v7_0/update_party_status.py @@ -1,8 +1,7 @@ import frappe -from erpnext.accounts.party_status import status_depends_on, default_status -from frappe.desk.notifications import get_filters_for def execute(): + return for party_type in ('Customer', 'Supplier'): frappe.reload_doctype(party_type) diff --git a/erpnext/patches/v7_2/set_party_status.py b/erpnext/patches/v7_2/set_party_status.py new file mode 100644 index 0000000000..bb03ccfe6e --- /dev/null +++ b/erpnext/patches/v7_2/set_party_status.py @@ -0,0 +1,10 @@ +import frappe + +def execute(): + # removing Open status for Customer / Supplier as it is duplicate + options = frappe.get_meta('Customer').get_field('status').options.split('\n') + default_option = 'Active' + if not default_option in options: + default_option = option[0] + + frappe.db.sql('update tabCustomer set status=%s where status="Open"', default_option) \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index e14cde07db..e4101af4bf 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -11,7 +11,6 @@ from frappe.desk.reportview import build_match_conditions from erpnext.utilities.transaction_base import TransactionBase from frappe.geo.address_and_contact import load_address_and_contact, delete_contact_and_address from erpnext.accounts.party import validate_party_accounts, get_timeline_data # keep this -from erpnext.accounts.party_status import get_party_status from erpnext import get_default_currency class Customer(TransactionBase): @@ -70,7 +69,6 @@ class Customer(TransactionBase): self.flags.is_new_doc = self.is_new() self.flags.old_lead = self.lead_name validate_party_accounts(self) - self.status = get_party_status(self) self.validate_credit_limit_on_change() def on_update(self): diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index 7a59dd72bf..36cc472574 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -68,47 +68,6 @@ class TestQuotation(unittest.TestCase): self.assertEquals(quotation.get("items")[0].rate, total_margin) si.save() - def test_party_status_open(self): - from erpnext.selling.doctype.customer.test_customer import get_customer_dict - - customer = frappe.get_doc(get_customer_dict('Party Status Test')).insert() - self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Active') - - quotation = frappe.get_doc(get_quotation_dict(customer=customer.name)).insert() - self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Open') - - quotation.submit() - self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Active') - - quotation.cancel() - quotation.delete() - customer.delete() - - def test_party_status_close(self): - from erpnext.selling.doctype.customer.test_customer import get_customer_dict - - customer = frappe.get_doc(get_customer_dict('Party Status Test')).insert() - self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Active') - - # open quotation - quotation = frappe.get_doc(get_quotation_dict(customer=customer.name)).insert() - self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Open') - - # close quotation (submit) - quotation.submit() - - quotation1 = frappe.get_doc(get_quotation_dict(customer=customer.name)).insert() - - # still open - self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Open') - - quotation.cancel() - quotation.delete() - - quotation1.delete() - - customer.delete() - test_records = frappe.get_test_records('Quotation') def get_quotation_dict(customer=None, item_code=None): diff --git a/erpnext/startup/notifications.py b/erpnext/startup/notifications.py index a1b90f96a2..554243f147 100644 --- a/erpnext/startup/notifications.py +++ b/erpnext/startup/notifications.py @@ -11,8 +11,6 @@ def get_notification_config(): "Task": {"status": "Overdue"}, "Project": {"status": "Open"}, "Item": {"total_projected_qty": ("<", 0)}, - "Customer": {"status": "Open"}, - "Supplier": {"status": "Open"}, "Lead": {"status": "Open"}, "Contact": {"status": "Open"}, "Opportunity": {"status": "Open"}, @@ -23,11 +21,11 @@ def get_notification_config(): }, "Journal Entry": {"docstatus": 0}, "Sales Invoice": { - "outstanding_amount": (">", 0), - "docstatus": ("<", 2) + "outstanding_amount": (">", 0), + "docstatus": ("<", 2) }, "Purchase Invoice": { - "outstanding_amount": (">", 0), + "outstanding_amount": (">", 0), "docstatus": ("<", 2) }, "Payment Entry": {"docstatus": 0},