From fd0f1cb8b7bb48b44bc27ca7f25d26a1037cf03d Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 13 Apr 2015 16:21:58 +0530 Subject: [PATCH] [opportunity] not submittable --- erpnext/controllers/status_updater.py | 6 ++---- .../crm/doctype/opportunity/opportunity.json | 20 +++++++++---------- .../crm/doctype/opportunity/opportunity.py | 13 ++++-------- erpnext/patches.txt | 2 +- .../v5_0/opportunity_not_submittable.py | 10 ++++++++++ 5 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 erpnext/patches/v5_0/opportunity_not_submittable.py diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 3f2ac7379a..3461e552f5 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -13,12 +13,10 @@ status_map = { ["Opportunity", "has_opportunity"], ], "Opportunity": [ - ["Draft", None], - ["Submitted", "eval:self.docstatus==1"], + ["Open", None], ["Lost", "eval:self.status=='Lost'"], ["Quotation", "has_quotation"], - ["Converted", "has_ordered_quotation"], - ["Cancelled", "eval:self.docstatus==2"], + ["Converted", "has_ordered_quotation"] ], "Quotation": [ ["Draft", None], diff --git a/erpnext/crm/doctype/opportunity/opportunity.json b/erpnext/crm/doctype/opportunity/opportunity.json index 0b25ad626a..3592cc124e 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.json +++ b/erpnext/crm/doctype/opportunity/opportunity.json @@ -119,10 +119,10 @@ "no_copy": 1, "oldfieldname": "status", "oldfieldtype": "Select", - "options": "Draft\nSubmitted\nQuotation\nLost\nCancelled\nReplied\nOpen", + "options": "Open\nQuotation\nLost\nReplied", "permlevel": 0, "print_hide": 1, - "read_only": 1, + "read_only": 0, "reqd": 1 }, { @@ -406,17 +406,17 @@ ], "icon": "icon-info-sign", "idx": 1, - "is_submittable": 1, - "modified": "2015-04-02 22:03:52.841173", + "is_submittable": 0, + "modified": "2015-04-13 06:50:43.198407", "modified_by": "Administrator", "module": "CRM", "name": "Opportunity", "owner": "Administrator", "permissions": [ { - "amend": 1, + "amend": 0, "apply_user_permissions": 1, - "cancel": 1, + "cancel": 0, "create": 1, "delete": 1, "email": 1, @@ -426,12 +426,12 @@ "report": 1, "role": "Sales User", "share": 1, - "submit": 1, + "submit": 0, "write": 1 }, { - "amend": 1, - "cancel": 1, + "amend": 0, + "cancel": 0, "create": 1, "delete": 1, "email": 1, @@ -441,7 +441,7 @@ "report": 1, "role": "Sales Manager", "share": 1, - "submit": 1, + "submit": 0, "write": 1 } ], diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index 71f95ade36..41bf9d517c 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -28,6 +28,10 @@ class Opportunity(TransactionBase): def set_subject(self, subject): self.title = subject + def after_insert(self): + if self.lead: + frappe.get_doc("Lead", self.lead).set_status(update=True) + def validate(self): self._prev = frappe._dict({ "contact_date": frappe.db.get_value("Opportunity", self.name, "contact_date") if \ @@ -51,15 +55,6 @@ class Opportunity(TransactionBase): from erpnext.accounts.utils import validate_fiscal_year validate_fiscal_year(self.transaction_date, self.fiscal_year, _("Opportunity Date"), self) - def on_submit(self): - if self.lead: - frappe.get_doc("Lead", self.lead).set_status(update=True) - - def on_cancel(self): - if self.has_quotation(): - frappe.throw(_("Cannot Cancel Opportunity as Quotation Exists")) - self.set_status(update=True) - def declare_enquiry_lost(self,arg): if not self.has_quotation(): frappe.db.set(self, 'status', 'Lost') diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 6d93df851b..d989a9051a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -137,4 +137,4 @@ erpnext.patches.v5_0.newsletter execute:frappe.delete_doc("DocType", "Chart of Accounts") execute:frappe.delete_doc("DocType", "Style Settings") erpnext.patches.v5_0.update_opportunity - +erpnext.patches.v5_0.opportunity_not_submittable diff --git a/erpnext/patches/v5_0/opportunity_not_submittable.py b/erpnext/patches/v5_0/opportunity_not_submittable.py new file mode 100644 index 0000000000..e29d66f284 --- /dev/null +++ b/erpnext/patches/v5_0/opportunity_not_submittable.py @@ -0,0 +1,10 @@ +# 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 + +def execute(): + frappe.reload_doctype("Opportunity") + frappe.db.sql("update tabDocPerm set submit=0, cancel=0, amend=0 where parent='Opportunity'") + frappe.db.sql("update tabOpportunity set docstatus=0 where docstatus=1")