From 17c8b940e3ab44cafb311992f1d8788f745763e5 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 9 Oct 2013 14:52:18 +0530 Subject: [PATCH 1/5] [minor] [fix] removed contact_date_ref --- selling/doctype/opportunity/opportunity.py | 13 ++++--------- selling/doctype/quotation/quotation.py | 16 +--------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py index c8c41e3f39d..dfb124b4482 100644 --- a/selling/doctype/opportunity/opportunity.py +++ b/selling/doctype/opportunity/opportunity.py @@ -70,10 +70,6 @@ class DocType(TransactionBase): return ret def on_update(self): - # Add to calendar - if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date: - webnotes.conn.set(self.doc, 'contact_date_ref',self.doc.contact_date) - self.add_calendar_event() def add_calendar_event(self, opts=None, force=False): @@ -102,12 +98,11 @@ class DocType(TransactionBase): super(DocType, self).add_calendar_event(opts, force) def set_last_contact_date(self): - if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date: - if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date): - self.doc.last_contact_date=self.doc.contact_date_ref + if self.doc.contact_date: + if not self.doc.last_contact_date or (getdate(self.doc.last_contact_date) <= getdate(self.doc.contact_date)): + self.doc.last_contact_date = self.doc.contact_date else: - msgprint("Contact Date Cannot be before Last Contact Date") - raise Exception + webnotes.throw(webnotes._("Contact Date Cannot be before Last Contact Date")) def validate_item_details(self): if not getlist(self.doclist, 'enquiry_details'): diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py index 44a67fa45cd..8eb3654e620 100644 --- a/selling/doctype/quotation/quotation.py +++ b/selling/doctype/quotation/quotation.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cstr, getdate +from webnotes.utils import cstr from webnotes.model.bean import getlist from webnotes.model.code import get_obj from webnotes import _, msgprint @@ -93,19 +93,6 @@ class DocType(SellingController): msgprint("You can not select non sales item "+d.item_code+" in Sales Quotation") raise Exception - #--------------Validation For Last Contact Date----------------- - # ==================================================================================================================== - def set_last_contact_date(self): - #if not self.doc.contact_date_ref: - #self.doc.contact_date_ref=self.doc.contact_date - #self.doc.last_contact_date=self.doc.contact_date_ref - if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date: - if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date): - self.doc.last_contact_date=self.doc.contact_date_ref - else: - msgprint("Contact Date Cannot be before Last Contact Date") - raise Exception - def validate(self): super(DocType, self).validate() @@ -116,7 +103,6 @@ class DocType(SellingController): utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Order Confirmed", "Order Lost", "Cancelled"]) - self.set_last_contact_date() self.validate_order_type() self.validate_for_items() From 3d72addae03b5010942eceff761f688a9a221613 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 9 Oct 2013 15:01:17 +0530 Subject: [PATCH 2/5] [minor] [fix] removed contact_date_ref --- selling/doctype/opportunity/opportunity.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py index dfb124b4482..eaabd0836dc 100644 --- a/selling/doctype/opportunity/opportunity.py +++ b/selling/doctype/opportunity/opportunity.py @@ -98,9 +98,9 @@ class DocType(TransactionBase): super(DocType, self).add_calendar_event(opts, force) def set_last_contact_date(self): - if self.doc.contact_date: - if not self.doc.last_contact_date or (getdate(self.doc.last_contact_date) <= getdate(self.doc.contact_date)): - self.doc.last_contact_date = self.doc.contact_date + if self._prev.contact_date: + if not self.doc.last_contact_date or (getdate(self._prev.contact_date) <= getdate(self.doc.contact_date)): + self.doc.last_contact_date = self._prev.contact_date else: webnotes.throw(webnotes._("Contact Date Cannot be before Last Contact Date")) From 599fe0532a42a2fd458154aac510139e24025498 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 9 Oct 2013 15:16:54 +0530 Subject: [PATCH 3/5] [minor] [fix] removed contact_date_ref --- selling/doctype/opportunity/opportunity.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py index eaabd0836dc..477521ca928 100644 --- a/selling/doctype/opportunity/opportunity.py +++ b/selling/doctype/opportunity/opportunity.py @@ -18,13 +18,6 @@ class DocType(TransactionBase): self.doclist = doclist self.fname = 'enq_details' self.tname = 'Opportunity Item' - - self._prev = webnotes._dict({ - "contact_date": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_date") if \ - (not cint(self.doc.fields.get("__islocal"))) else None, - "contact_by": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_by") if \ - (not cint(self.doc.fields.get("__islocal"))) else None, - }) def get_item_details(self, item_code): item = sql("""select item_name, stock_uom, description_html, description, item_group, brand @@ -99,9 +92,9 @@ class DocType(TransactionBase): def set_last_contact_date(self): if self._prev.contact_date: - if not self.doc.last_contact_date or (getdate(self._prev.contact_date) <= getdate(self.doc.contact_date)): + if getdate(self._prev.contact_date) < getdate(self.doc.contact_date): self.doc.last_contact_date = self._prev.contact_date - else: + elif getdate(self._prev.contact_date) > getdate(self.doc.contact_date): webnotes.throw(webnotes._("Contact Date Cannot be before Last Contact Date")) def validate_item_details(self): @@ -116,6 +109,13 @@ class DocType(TransactionBase): msgprint("Customer is mandatory if 'Opportunity From' is selected as Customer", raise_exception=1) def validate(self): + self._prev = webnotes._dict({ + "contact_date": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_date") if \ + (not cint(self.doc.fields.get("__islocal"))) else None, + "contact_by": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_by") if \ + (not cint(self.doc.fields.get("__islocal"))) else None, + }) + self.set_last_contact_date() self.validate_item_details() self.validate_uom_is_integer("uom", "qty") From 650cfc043489e1a21fadb94424d69e577214ac92 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 9 Oct 2013 15:26:53 +0530 Subject: [PATCH 4/5] [minor] removed last_contact_date in opportunity --- selling/doctype/opportunity/opportunity.py | 24 +++++++-------------- selling/doctype/opportunity/opportunity.txt | 16 +------------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py index 477521ca928..5854758b5b4 100644 --- a/selling/doctype/opportunity/opportunity.py +++ b/selling/doctype/opportunity/opportunity.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cstr, getdate, cint +from webnotes.utils import cstr, cint from webnotes.model.bean import getlist from webnotes import msgprint @@ -19,6 +19,13 @@ class DocType(TransactionBase): self.fname = 'enq_details' self.tname = 'Opportunity Item' + self._prev = webnotes._dict({ + "contact_date": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_date") if \ + (not cint(self.doc.fields.get("__islocal"))) else None, + "contact_by": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_by") if \ + (not cint(self.doc.fields.get("__islocal"))) else None, + }) + def get_item_details(self, item_code): item = sql("""select item_name, stock_uom, description_html, description, item_group, brand from `tabItem` where name = %s""", item_code, as_dict=1) @@ -90,13 +97,6 @@ class DocType(TransactionBase): super(DocType, self).add_calendar_event(opts, force) - def set_last_contact_date(self): - if self._prev.contact_date: - if getdate(self._prev.contact_date) < getdate(self.doc.contact_date): - self.doc.last_contact_date = self._prev.contact_date - elif getdate(self._prev.contact_date) > getdate(self.doc.contact_date): - webnotes.throw(webnotes._("Contact Date Cannot be before Last Contact Date")) - def validate_item_details(self): if not getlist(self.doclist, 'enquiry_details'): msgprint("Please select items for which enquiry needs to be made") @@ -109,14 +109,6 @@ class DocType(TransactionBase): msgprint("Customer is mandatory if 'Opportunity From' is selected as Customer", raise_exception=1) def validate(self): - self._prev = webnotes._dict({ - "contact_date": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_date") if \ - (not cint(self.doc.fields.get("__islocal"))) else None, - "contact_by": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_by") if \ - (not cint(self.doc.fields.get("__islocal"))) else None, - }) - - self.set_last_contact_date() self.validate_item_details() self.validate_uom_is_integer("uom", "qty") self.validate_lead_cust() diff --git a/selling/doctype/opportunity/opportunity.txt b/selling/doctype/opportunity/opportunity.txt index aeedd08bb80..8a68a31e793 100644 --- a/selling/doctype/opportunity/opportunity.txt +++ b/selling/doctype/opportunity/opportunity.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-07 18:50:30", "docstatus": 0, - "modified": "2013-09-25 19:32:29", + "modified": "2013-10-09 15:26:29", "modified_by": "Administrator", "owner": "Administrator" }, @@ -408,20 +408,6 @@ "oldfieldtype": "Date", "read_only": 0 }, - { - "allow_on_submit": 0, - "depends_on": "eval:!doc.__islocal", - "description": "Date on which the lead was last contacted", - "doctype": "DocField", - "fieldname": "last_contact_date", - "fieldtype": "Date", - "label": "Last Contact Date", - "no_copy": 1, - "oldfieldname": "last_contact_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 1 - }, { "doctype": "DocField", "fieldname": "to_discuss", From a0ecfba5f53d280291c9a25fb5fbbd89aca6e366 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 9 Oct 2013 15:28:16 +0530 Subject: [PATCH 5/5] [minor] removed last_contact_date from lead --- selling/doctype/lead/lead.txt | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/selling/doctype/lead/lead.txt b/selling/doctype/lead/lead.txt index 408ad451250..b969906085b 100644 --- a/selling/doctype/lead/lead.txt +++ b/selling/doctype/lead/lead.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-10 11:45:37", "docstatus": 0, - "modified": "2013-09-26 16:30:36", + "modified": "2013-10-09 15:27:54", "modified_by": "Administrator", "owner": "Administrator" }, @@ -174,19 +174,6 @@ "options": "Profile", "search_index": 1 }, - { - "depends_on": "eval:!doc.__islocal", - "description": "Date on which the lead was last contacted", - "doctype": "DocField", - "fieldname": "last_contact_date", - "fieldtype": "Date", - "label": "Last Contact Date", - "no_copy": 1, - "oldfieldname": "last_contact_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 1 - }, { "doctype": "DocField", "fieldname": "col_break123",