From 3333ca1721fd362d6a317f32fae92d31066f94fe Mon Sep 17 00:00:00 2001 From: Ravi Dey Date: Mon, 4 Jul 2011 16:23:19 +0530 Subject: [PATCH 01/10] support ticket updates --- home/__init__.py | 46 +++++++- .../doctype/support_ticket/__init__.py | 3 +- .../doctype/support_ticket/support_ticket.js | 37 +++++- .../doctype/support_ticket/support_ticket.py | 9 ++ .../doctype/support_ticket/support_ticket.txt | 106 +++++++++--------- 5 files changed, 142 insertions(+), 59 deletions(-) diff --git a/home/__init__.py b/home/__init__.py index 4978791d72b..862d48601a9 100644 --- a/home/__init__.py +++ b/home/__init__.py @@ -1,4 +1,5 @@ import webnotes +from webnotes import msgprint feed_dict = { # Project @@ -29,12 +30,45 @@ feed_dict = { # Support 'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'], 'Maintenance Visit':['To %(customer_name)s', '#4169E1'], - 'Support Ticket': ['[%(status)s] %(subject)s', '#000080'] + #'Support Ticket': ['[%(status)s] %(subject)s', '#000080'] + 'Support Ticket': '#000080' } +feed_dict_color = { + # Project + 'Project': '#000080', + + # Sales + 'Lead': '#000080', + 'Quotation': '#4169E1', + 'Sales Order': '#4169E1', + + # Purchase + 'Supplier': '#6495ED', + 'Purchase Order': '#4169E1', + + # Stock + 'Delivery Note': '#4169E1', + + # Accounts + 'Journal Voucher': '#4169E1', + 'Payable Voucher': '#4169E1', + 'Receivable Voucher': '#4169E1', + + # HR + 'Expense Voucher': '#4169E1', + 'Salary Slip': '#4169E1', + 'Leave Transaction': '#4169E1', + + # Support + 'Customer Issue': '#000080', + 'Maintenance Visit': '#4169E1', + 'Support Ticket': '#000080' +} def make_feed(doc, subject, color): "makes a new Feed record" + #msgprint(subject) from webnotes.model.doc import Document webnotes.conn.sql("delete from tabFeed where doc_type=%s and doc_name=%s", (doc.doctype, doc.name)) f = Document('Feed') @@ -46,8 +80,14 @@ def make_feed(doc, subject, color): def update_feed(doc): "adds a new feed" - subject, color = feed_dict.get(doc.doctype, [None, None]) + prop_rec = webnotes.conn.sql("select value from `tabProperty Setter` where doc_type = %s and property = 'subject'", (doc.doctype)) + if prop_rec: + subject = prop_rec[0][0] + else: + rec = webnotes.conn.sql("select subject from tabDocType where name=%s", (doc.doctype)) + subject = rec[0][0] + + subject, color = [subject, feed_dict_color.get(doc.doctype)] if subject: subject = subject % doc.fields make_feed(doc, subject, color) - diff --git a/maintenance/doctype/support_ticket/__init__.py b/maintenance/doctype/support_ticket/__init__.py index 398ee7f5a48..959a751d474 100644 --- a/maintenance/doctype/support_ticket/__init__.py +++ b/maintenance/doctype/support_ticket/__init__.py @@ -54,7 +54,8 @@ class SupportMailbox(POP3Mailbox): d.save(1) # update feed - update_feed(d) + update_feed(d) + def get_support_mails(): """ diff --git a/maintenance/doctype/support_ticket/support_ticket.js b/maintenance/doctype/support_ticket/support_ticket.js index 3e43edc4f7c..584f41278a1 100644 --- a/maintenance/doctype/support_ticket/support_ticket.js +++ b/maintenance/doctype/support_ticket/support_ticket.js @@ -33,8 +33,14 @@ $.extend(cur_frm.cscript, { refresh: function(doc) { cs.make_listing(doc); - if(!doc.__islocal) { - // can't change the main message & subject once set + if(!doc.__islocal) { + + if(doc.allocated_to) + set_field_permlevel('status',2); + if(user==doc.allocated_to && doc.status!='Closed') cur_frm.add_custom_button('Close Ticket', cs['Close Ticket']); + if(doc.status=='Closed') cur_frm.add_custom_button('Re-Open Ticket', cs['Re-Open Ticket']); + + // can't change the main message & subject once set set_field_permlevel('subject',2); set_field_permlevel('description',2); set_field_permlevel('raised_by',2); @@ -87,10 +93,37 @@ $.extend(cur_frm.cscript, { } if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback); if(doc.customer) unhide_field(['customer_name','address_display','contact_display','contact_mobile','contact_email']); + }, + + 'Close Ticket': function() { + var doc = cur_frm.doc + + var answer = confirm("Close Ticket "+doc.name+"?\n\nAllocated To: "+doc.allocated_to+"\n\nSubject: "+doc.subject+""); + if(answer) { + if(doc.name) + $c_obj([doc],'close_ticket','',function(r,rt) { + cur_frm.refresh(); + }); + } + }, + + 'Re-Open Ticket': function() { + var doc = cur_frm.doc + + var answer = confirm("Re-Open Ticket "+doc.name+"?\n\nAllocated To: "+doc.allocated_to+"\n\nSubject: "+doc.subject+""); + if(answer) { + if(doc.name) + $c_obj([doc],'reopen_ticket','',function(r,rt) { + cur_frm.refresh(); + }); + } } + + }) + EmailMessage = function(parent, args, list, idx) { var me = this; $.extend(this, args); diff --git a/maintenance/doctype/support_ticket/support_ticket.py b/maintenance/doctype/support_ticket/support_ticket.py index c4af0ed05fc..75defbeb346 100644 --- a/maintenance/doctype/support_ticket/support_ticket.py +++ b/maintenance/doctype/support_ticket/support_ticket.py @@ -1,6 +1,7 @@ import webnotes from utilities.transaction_base import TransactionBase +from home import update_feed class DocType(TransactionBase): def __init__(self, doc, doclist=[]): @@ -46,3 +47,11 @@ class DocType(TransactionBase): d.mail = response d.content_type = content_type d.save(1) + + def close_ticket(self): + webnotes.conn.set(self.doc,'status','Closed') + update_feed(self.doc) + + def reopen_ticket(self): + webnotes.conn.set(self.doc,'status','Open') + update_feed(self.doc) diff --git a/maintenance/doctype/support_ticket/support_ticket.txt b/maintenance/doctype/support_ticket/support_ticket.txt index 267dade230c..2b0fa9bf71a 100644 --- a/maintenance/doctype/support_ticket/support_ticket.txt +++ b/maintenance/doctype/support_ticket/support_ticket.txt @@ -1,6 +1,6 @@ [ { - '_last_update': '1308914721', + '_last_update': '1309771514', 'allow_attach': None, 'allow_copy': None, 'allow_email': None, @@ -29,7 +29,7 @@ 'istable': None, 'max_attachments': None, 'menu_index': None, - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'module': 'Maintenance', 'name': 'Support Ticket', @@ -53,7 +53,7 @@ 'subject': '%(subject)s', 'tag_fields': 'status,allocated_to', 'use_template': None, - 'version': 143 + 'version': 148 }, { 'amend': 0, @@ -65,7 +65,7 @@ 'execute': None, 'idx': 1, 'match': None, - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'PERM00823', 'owner': 'Administrator', @@ -88,7 +88,7 @@ 'execute': None, 'idx': 2, 'match': 'customer', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'PERM00824', 'owner': 'Administrator', @@ -111,7 +111,7 @@ 'execute': None, 'idx': 3, 'match': None, - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'PERM00825', 'owner': 'Administrator', @@ -134,7 +134,7 @@ 'execute': None, 'idx': 4, 'match': 'allocated_to', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'PERM00826', 'owner': 'Administrator', @@ -157,7 +157,7 @@ 'execute': None, 'idx': 5, 'match': None, - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'PERM00827', 'owner': 'Administrator', @@ -186,7 +186,7 @@ 'idx': 1, 'in_filter': 0, 'label': 'Status', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04803', 'no_column': None, @@ -201,7 +201,7 @@ 'permlevel': 1, 'print_hide': None, 'report_hide': None, - 'reqd': 0, + 'reqd': 1, 'search_index': 1, 'trigger': None, 'width': None @@ -216,13 +216,13 @@ 'docstatus': 0, 'doctype': 'DocField', 'fieldname': 'subject', - 'fieldtype': 'Text', + 'fieldtype': 'Small Text', 'hidden': None, 'icon': None, 'idx': 2, 'in_filter': 1, 'label': 'Subject', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04804', 'no_column': None, @@ -258,7 +258,7 @@ 'idx': 3, 'in_filter': 1, 'label': 'Raised By (Email)', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04805', 'no_column': None, @@ -294,7 +294,7 @@ 'idx': 4, 'in_filter': None, 'label': 'Description', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04806', 'no_column': None, @@ -330,7 +330,7 @@ 'idx': 5, 'in_filter': None, 'label': 'Problem Description', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL05248', 'no_column': None, @@ -353,7 +353,7 @@ { 'allow_on_submit': None, 'colour': None, - 'creation': '2011-06-24 11:54:03', + 'creation': '2011-06-29 17:28:05', 'default': None, 'depends_on': 'eval:!doc.__islocal', 'description': None, @@ -366,9 +366,9 @@ 'idx': 6, 'in_filter': None, 'label': 'Thread HTML', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', - 'name': 'FL05356', + 'name': 'FL05360', 'no_column': None, 'no_copy': None, 'oldfieldname': None, @@ -402,7 +402,7 @@ 'idx': 7, 'in_filter': None, 'label': 'New Response', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04808', 'no_column': None, @@ -438,7 +438,7 @@ 'idx': 8, 'in_filter': None, 'label': 'Send', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04809', 'no_column': None, @@ -461,7 +461,7 @@ { 'allow_on_submit': None, 'colour': 'White:FFF', - 'creation': '2011-06-24 11:54:03', + 'creation': '2011-06-29 17:28:05', 'default': None, 'depends_on': None, 'description': None, @@ -474,9 +474,9 @@ 'idx': 9, 'in_filter': None, 'label': 'Additional Info', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', - 'name': 'FL05357', + 'name': 'FL05361', 'no_column': None, 'no_copy': None, 'oldfieldname': None, @@ -497,7 +497,7 @@ { 'allow_on_submit': None, 'colour': None, - 'creation': '2011-06-24 11:54:03', + 'creation': '2011-06-29 17:28:05', 'default': None, 'depends_on': 'eval:!doc.__islocal', 'description': None, @@ -510,9 +510,9 @@ 'idx': 10, 'in_filter': None, 'label': None, - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', - 'name': 'FL05358', + 'name': 'FL05362', 'no_column': None, 'no_copy': None, 'oldfieldname': None, @@ -546,7 +546,7 @@ 'idx': 11, 'in_filter': 1, 'label': 'Customer', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04812', 'no_column': None, @@ -582,7 +582,7 @@ 'idx': 12, 'in_filter': 1, 'label': 'Customer Name', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04813', 'no_column': None, @@ -605,7 +605,7 @@ { 'allow_on_submit': None, 'colour': None, - 'creation': '2011-06-24 12:20:56', + 'creation': '2011-06-29 17:28:04', 'default': None, 'depends_on': None, 'description': None, @@ -618,9 +618,9 @@ 'idx': 13, 'in_filter': None, 'label': 'Address', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', - 'name': 'FL05399', + 'name': 'FL05355', 'no_column': None, 'no_copy': None, 'oldfieldname': None, @@ -641,7 +641,7 @@ { 'allow_on_submit': None, 'colour': None, - 'creation': '2011-06-24 12:20:56', + 'creation': '2011-06-29 17:28:04', 'default': None, 'depends_on': None, 'description': None, @@ -654,9 +654,9 @@ 'idx': 14, 'in_filter': None, 'label': 'Contact Name', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', - 'name': 'FL05401', + 'name': 'FL05356', 'no_column': None, 'no_copy': None, 'oldfieldname': None, @@ -677,7 +677,7 @@ { 'allow_on_submit': None, 'colour': None, - 'creation': '2011-06-24 12:20:56', + 'creation': '2011-06-29 17:28:05', 'default': None, 'depends_on': None, 'description': None, @@ -690,9 +690,9 @@ 'idx': 15, 'in_filter': None, 'label': 'Mobile No', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', - 'name': 'FL05400', + 'name': 'FL05357', 'no_column': None, 'no_copy': None, 'oldfieldname': None, @@ -713,7 +713,7 @@ { 'allow_on_submit': None, 'colour': None, - 'creation': '2011-05-23 10:18:58', + 'creation': '2011-06-29 17:28:05', 'default': None, 'depends_on': None, 'description': None, @@ -726,9 +726,9 @@ 'idx': 16, 'in_filter': None, 'label': 'Contact Email', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', - 'name': 'FL04814', + 'name': 'FL05358', 'no_column': None, 'no_copy': None, 'oldfieldname': 'contact_no', @@ -762,7 +762,7 @@ 'idx': 17, 'in_filter': None, 'label': 'Opening Date', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04815', 'no_column': None, @@ -798,7 +798,7 @@ 'idx': 18, 'in_filter': None, 'label': 'Opening Time', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04816', 'no_column': None, @@ -821,7 +821,7 @@ { 'allow_on_submit': None, 'colour': None, - 'creation': '2011-06-24 11:54:03', + 'creation': '2011-06-29 17:28:05', 'default': None, 'depends_on': 'eval:!doc.__islocal', 'description': None, @@ -834,9 +834,9 @@ 'idx': 19, 'in_filter': None, 'label': None, - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', - 'name': 'FL05359', + 'name': 'FL05363', 'no_column': None, 'no_copy': None, 'oldfieldname': None, @@ -856,7 +856,7 @@ }, { 'allow_on_submit': None, - 'colour': None, + 'colour': 'White:FFF', 'creation': '2011-05-23 10:18:58', 'default': None, 'depends_on': 'eval:!doc.__islocal', @@ -870,7 +870,7 @@ 'idx': 20, 'in_filter': 1, 'label': 'Allocated To', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04818', 'no_column': None, @@ -900,13 +900,13 @@ 'docstatus': 0, 'doctype': 'DocField', 'fieldname': 'resolution_details', - 'fieldtype': 'Text', + 'fieldtype': 'Small Text', 'hidden': None, 'icon': None, 'idx': 21, 'in_filter': None, 'label': 'Resolution Details', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04819', 'no_column': None, @@ -928,7 +928,7 @@ }, { 'allow_on_submit': None, - 'colour': None, + 'colour': 'White:FFF', 'creation': '2011-05-23 10:18:58', 'default': None, 'depends_on': 'eval:!doc.__islocal', @@ -942,7 +942,7 @@ 'idx': 22, 'in_filter': 0, 'label': 'Resolution Date', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04820', 'no_column': None, @@ -978,7 +978,7 @@ 'idx': 23, 'in_filter': None, 'label': 'Resolution Time', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL04821', 'no_column': None, @@ -1014,7 +1014,7 @@ 'idx': 24, 'in_filter': None, 'label': 'Content Type', - 'modified': '2011-06-27 11:30:33', + 'modified': '2011-07-04 15:13:48', 'modified_by': 'Administrator', 'name': 'FL05251', 'no_column': None, From e2ddb24cd19d489e1f00cba158259b5ef2b11287 Mon Sep 17 00:00:00 2001 From: Ravi Dey Date: Mon, 4 Jul 2011 16:47:24 +0530 Subject: [PATCH 02/10] support feed revert --- home/__init__.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/home/__init__.py b/home/__init__.py index 862d48601a9..111f6e618b5 100644 --- a/home/__init__.py +++ b/home/__init__.py @@ -78,16 +78,23 @@ def make_feed(doc, subject, color): f.color = color f.save(1) +#def update_feed(doc): +# "adds a new feed" +# prop_rec = webnotes.conn.sql("select value from `tabProperty Setter` where doc_type = %s and property = 'subject'", (doc.doctype)) +# if prop_rec: +# subject = prop_rec[0][0] +# else: +# rec = webnotes.conn.sql("select subject from tabDocType where name=%s", (doc.doctype)) +# subject = rec[0][0] +# +# subject, color = [subject, feed_dict_color.get(doc.doctype)] +# if subject: +# subject = subject % doc.fields +# make_feed(doc, subject, color) + def update_feed(doc): "adds a new feed" - prop_rec = webnotes.conn.sql("select value from `tabProperty Setter` where doc_type = %s and property = 'subject'", (doc.doctype)) - if prop_rec: - subject = prop_rec[0][0] - else: - rec = webnotes.conn.sql("select subject from tabDocType where name=%s", (doc.doctype)) - subject = rec[0][0] - - subject, color = [subject, feed_dict_color.get(doc.doctype)] + subject, color = feed_dict.get(doc.doctype, [None, None]) if subject: - subject = subject % doc.fields - make_feed(doc, subject, color) + subject = subject % doc.fields + make_feed(doc, subject, color) From 9514ee9eb87b0c64a535b70f5355ea8b34469bad Mon Sep 17 00:00:00 2001 From: Ravi Dey Date: Mon, 4 Jul 2011 16:49:25 +0530 Subject: [PATCH 03/10] support feed revert --- home/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/__init__.py b/home/__init__.py index 111f6e618b5..db8c5b6b65b 100644 --- a/home/__init__.py +++ b/home/__init__.py @@ -96,5 +96,5 @@ def update_feed(doc): "adds a new feed" subject, color = feed_dict.get(doc.doctype, [None, None]) if subject: - subject = subject % doc.fields - make_feed(doc, subject, color) + subject = subject % doc.fields + make_feed(doc, subject, color) From c1886b5b13ad6c1af33a1650e257c8c5d15db85e Mon Sep 17 00:00:00 2001 From: Ravi Dey Date: Mon, 4 Jul 2011 16:53:42 +0530 Subject: [PATCH 04/10] removed reqd from property setter doc field --- patches/patch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/patches/patch.py b/patches/patch.py index 7f82d56c418..a609738af62 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,6 +1,6 @@ # REMEMBER to update this # ======================== -last_patch = 307 +last_patch = 308 #------------------------------------------- @@ -1216,3 +1216,5 @@ def execute(patch_no): elif patch_no == 307: sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'Button'") reload_doc('setup', 'doctype', 'company') + elif patch_no == 308: + sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'") From 913d7b51aea962f474eda3026230fe94bfeee781 Mon Sep 17 00:00:00 2001 From: Ravi Dey Date: Mon, 4 Jul 2011 17:18:01 +0530 Subject: [PATCH 05/10] home feeds --- home/__init__.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/home/__init__.py b/home/__init__.py index db8c5b6b65b..bcfcbb70091 100644 --- a/home/__init__.py +++ b/home/__init__.py @@ -3,7 +3,7 @@ from webnotes import msgprint feed_dict = { # Project - 'Ticket': ['[%(status)s] %(subject)s', '#000080'], + 'Project': ['[%(status)s] %(subject)s', '#000080'], # Sales 'Lead': ['%(lead_name)s', '#000080'], @@ -30,8 +30,7 @@ feed_dict = { # Support 'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'], 'Maintenance Visit':['To %(customer_name)s', '#4169E1'], - #'Support Ticket': ['[%(status)s] %(subject)s', '#000080'] - 'Support Ticket': '#000080' + 'Support Ticket': ['[%(status)s] %(subject)s', '#000080'] } feed_dict_color = { @@ -77,20 +76,20 @@ def make_feed(doc, subject, color): f.subject = subject f.color = color f.save(1) + +def update_feed1(doc): + "adds a new feed" + prop_rec = webnotes.conn.sql("select value from `tabProperty Setter` where doc_type = %s and property = 'subject'", (doc.doctype)) + if prop_rec: + subject = prop_rec[0][0] + else: + rec = webnotes.conn.sql("select subject from tabDocType where name=%s", (doc.doctype)) + subject = rec[0][0] -#def update_feed(doc): -# "adds a new feed" -# prop_rec = webnotes.conn.sql("select value from `tabProperty Setter` where doc_type = %s and property = 'subject'", (doc.doctype)) -# if prop_rec: -# subject = prop_rec[0][0] -# else: -# rec = webnotes.conn.sql("select subject from tabDocType where name=%s", (doc.doctype)) -# subject = rec[0][0] -# -# subject, color = [subject, feed_dict_color.get(doc.doctype)] -# if subject: -# subject = subject % doc.fields -# make_feed(doc, subject, color) + subject, color = [subject, feed_dict_color.get(doc.doctype)] + if subject: + subject = subject % doc.fields + make_feed(doc, subject, color) def update_feed(doc): "adds a new feed" From d95826276180671a57454d09fb5610ea5ceaf384 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 5 Jul 2011 11:42:24 +0530 Subject: [PATCH 06/10] Added method is_setup_okay to confirm if a db is setup properly --- setup/doctype/setup_control/setup_control.py | 47 ++++++++++++++------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py index 284e2a8a360..7cbf4d32fbc 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -13,6 +13,8 @@ sql = webnotes.conn.sql get_value = webnotes.conn.get_value in_transaction = webnotes.conn.in_transaction convert_to_lists = webnotes.conn.convert_to_lists + +from server_tools.gateway_utils import update_client_control, get_total_users # ----------------------------------------------------------------------------------------- @@ -36,10 +38,10 @@ class DocType: #----------------------- def set_account_details(self, args): args = eval(args) - - self.set_cp_defaults(args['company_name'], args['industry'], args['time_zone'], args['country'], args['account_name']) + #webnotes.logger.error("args in set_account_details of setup_control: " + str(args)) + self.set_cp_defaults(args['company'], args['industry'], args['time_zone'], args['country'], args['account_name']) self.create_profile(args['user'], args['first_name'], args['last_name']) - self.update_client_control() + update_client_control(args['total_users']) # Account Setup @@ -163,19 +165,38 @@ class DocType: d = addchild(pr,'userroles', 'UserRole', 1) d.role = r d.save(1) - - # Update WN ERP Client Control - # ----------------------------- - def update_client_control(self): - cl = Document('WN ERP Client Control','WN ERP Client Control') - cl.account_start_date = nowdate() - cl.total_users = 1 - cl.is_trial_account = 1 - cl.save() + # Sync DB # ------- def sync_db(arg=''): import webnotes.model.db_schema sql("delete from `tabDocType Update Register`") - webnotes.model.db_schema.sync_all() \ No newline at end of file + webnotes.model.db_schema.sync_all() + + + def is_setup_okay(self, args): + """ + Validates if setup has been performed after database allocation + """ + + args = eval(args) + #webnotes.logger.error("args in set_account_details of setup_control: " + str(args)) + + cp_defaults = webnotes.conn.get_value('Control Panel', None, 'account_id') + + user_profile = webnotes.conn.get_value('Profile', args['user'], 'name') + + from webnotes.utils import cint + + total_users = get_total_users() + + #webnotes.logger.error("setup_control.is_setup_okay: " + cp_defaults + " " + user_profile + " " + str(total_users)) + + #webnotes.logger.error("setup_control.is_setup_okay: Passed Values:" + args['account_name'] + " " + args['user'] + " " + str(args['total_users'])) + + + if (cp_defaults==args['account_name']) and user_profile and \ + (total_users==cint(args['total_users'])): + return 'True' + \ No newline at end of file From 7f0befb94f26974cfb7bf5483b5e1c6623461895 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Tue, 5 Jul 2011 12:10:45 +0530 Subject: [PATCH 07/10] make ledger entry is qty and actual qty are both zero in stock reco --- .../doctype/stock_reconciliation/stock_reconciliation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/material_management/doctype/stock_reconciliation/stock_reconciliation.py b/material_management/doctype/stock_reconciliation/stock_reconciliation.py index 28410c80312..50da30b3ee6 100644 --- a/material_management/doctype/stock_reconciliation/stock_reconciliation.py +++ b/material_management/doctype/stock_reconciliation/stock_reconciliation.py @@ -127,10 +127,10 @@ class DocType: # update mar # ----------- def update_mar(self, d, qty_diff): - if not d[self.label['qty']] and not d[self.label['actual_qty']]: + if not flt(d[self.label['qty']]) and not flt(d[self.label['actual_qty']]): # seems like a special condition when there is no actual quanitity but there is a rate, may be only for setting a rate! self.make_sl_entry(1,d,1) - self.make_sl_entry(-1,d,1) + self.make_sl_entry(1,d,-1) else: self.update_item_valuation_pre_date(d) From 1b6d158f27a60aa5657494b02b0ea3108a7df386 Mon Sep 17 00:00:00 2001 From: Ravi Dey Date: Tue, 5 Jul 2011 12:11:40 +0530 Subject: [PATCH 08/10] sales person fix --- setup/doctype/sales_person/sales_person.py | 94 +++++++++++----------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/setup/doctype/sales_person/sales_person.py b/setup/doctype/sales_person/sales_person.py index 04a40bd6cd4..fbcb83e58c7 100644 --- a/setup/doctype/sales_person/sales_person.py +++ b/setup/doctype/sales_person/sales_person.py @@ -5,64 +5,60 @@ from webnotes.model.doc import Document from webnotes.model.doclist import getlist from webnotes.model.code import get_obj from webnotes import session, form, is_testing, msgprint, errprint - +from webnotes.utils import flt sql = webnotes.conn.sql convert_to_lists = webnotes.conn.convert_to_lists # ----------------------------------------------------------------------------------------- - class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.nsm_parent_field = 'parent_sales_person'; - - def check_state(self): - return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)]) + def __init__(self, doc, doclist=[]): + self.doc = doc + self.doclist = doclist + self.nsm_parent_field = 'parent_sales_person'; + + def check_state(self): + return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)]) - # update Node Set Model - def update_nsm_model(self): - import webnotes - import webnotes.utils.nestedset - webnotes.utils.nestedset.update_nsm(self) + # update Node Set Model + def update_nsm_model(self): + import webnotes + import webnotes.utils.nestedset + webnotes.utils.nestedset.update_nsm(self) - # ON UPDATE - #-------------------------------------- - def on_update(self): - # update nsm - self.update_nsm_model() + # ON UPDATE + #-------------------------------------- + def on_update(self): + # update nsm + self.update_nsm_model() - def validate(self): - from webnotes.utils import flt - for d in getlist(self.doclist, 'target_details'): - if not flt(d.target_qty) and not flt(d.target_amount): - msgprint("Either target qty or target amount is mandatory.") - raise Exception - - #self.sync_with_contact() - - def sync_with_contact(self): - cid = sql("select name from tabContact where sales_person_id = %s and is_sales_person=1", self.doc.name) - if cid: - d = Document('Contact', cid[0][0]) - else: - d = Document('Contact') - - name_split = self.doc.sales_person_name.split() - d.contact_name = self.doc.sales_person_name - d.first_name = name_split[0] - d.last_name = len(name_split) > 1 and name_split[1] or '' - d.email_id = self.doc.email_id - d.contact_no = d.mobile_no = self.doc.mobile_no - d.designation = self.doc.designation - d.department = self.doc.department - d.sales_person_id = self.doc.name - d.is_sales_person = 1 - - d.save(new = (not d.name)) - - + def validate(self): + for d in getlist(self.doclist, 'target_details'): + if not flt(d.target_qty) and not flt(d.target_amount): + msgprint("Either target qty or target amount is mandatory.") + raise Exception + + #self.sync_with_contact() + + def sync_with_contact(self): + cid = sql("select name from tabContact where sales_person_id = %s and is_sales_person=1", self.doc.name) + if cid: + d = Document('Contact', cid[0][0]) + else: + d = Document('Contact') + + name_split = self.doc.sales_person_name.split() + d.contact_name = self.doc.sales_person_name + d.first_name = name_split[0] + d.last_name = len(name_split) > 1 and name_split[1] or '' + d.email_id = self.doc.email_id + d.contact_no = d.mobile_no = self.doc.mobile_no + d.designation = self.doc.designation + d.department = self.doc.department + d.sales_person_id = self.doc.name + d.is_sales_person = 1 + + d.save(new = (not d.name)) From 66091b1eeb62e9fe94e8309a02812196eb6253ea Mon Sep 17 00:00:00 2001 From: nabinhait Date: Tue, 5 Jul 2011 12:38:48 +0530 Subject: [PATCH 09/10] make ledger entry is qty and actual qty are both zero in stock reco --- .../stock_reconciliation.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/material_management/doctype/stock_reconciliation/stock_reconciliation.py b/material_management/doctype/stock_reconciliation/stock_reconciliation.py index 50da30b3ee6..69710f0eaba 100644 --- a/material_management/doctype/stock_reconciliation/stock_reconciliation.py +++ b/material_management/doctype/stock_reconciliation/stock_reconciliation.py @@ -127,15 +127,18 @@ class DocType: # update mar # ----------- def update_mar(self, d, qty_diff): + """ + update item valuation in previous date and also on post date if no qty diff + """ + + self.update_item_valuation_pre_date(d) + if not flt(d[self.label['qty']]) and not flt(d[self.label['actual_qty']]): - # seems like a special condition when there is no actual quanitity but there is a rate, may be only for setting a rate! - self.make_sl_entry(1,d,1) - self.make_sl_entry(1,d,-1) - else: - self.update_item_valuation_pre_date(d) - - if not qty_diff: - self.update_item_valuation_post_date(d) + # seems like a special condition when there is no actual quanitity but there is a rate, may be only for setting a rate! + self.make_sl_entry(1,d,1) + self.make_sl_entry(1,d,-1) + elif not qty_diff: + self.update_item_valuation_post_date(d) # update valuation rate as csv file in all sle before reconciliation date # ------------------------------------------------------------------------ From 4b2f35ed7969eeaf2ab7235623d8c6c26e320ab2 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Tue, 5 Jul 2011 14:25:47 +0530 Subject: [PATCH 10/10] fixed issue in update_voucher_outstanding --- accounts/doctype/fiscal_year/fiscal_year.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/accounts/doctype/fiscal_year/fiscal_year.py b/accounts/doctype/fiscal_year/fiscal_year.py index 7db63b2754b..6dd4f2ca902 100644 --- a/accounts/doctype/fiscal_year/fiscal_year.py +++ b/accounts/doctype/fiscal_year/fiscal_year.py @@ -165,17 +165,15 @@ class DocType: def update_voucher_outstanding(self): # Clear outstanding self.clear_outstanding() - sql("LOCK TABLE `tabGL Entry` WRITE") - against_voucher = sql("select against_voucher, against_voucher_type from `tabGL Entry` where fiscal_year=%s and is_cancelled='No' and company=%s and ifnull(against_voucher, '') != '' and ifnull(against_voucher_type, '') != '' group by against_voucher, against_voucher_type", (self.doc.name, self.doc.company)) + against_voucher = sql("select against_voucher, against_voucher_type from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled, 'No')='No' and company=%s and ifnull(against_voucher, '') != '' and ifnull(against_voucher_type, '') != '' group by against_voucher, against_voucher_type", (self.doc.name, self.doc.company)) for d in against_voucher: # get voucher balance - bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s", (d[0], d[1])) + bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s and ifnull(is_cancelled, 'No') = 'No'", (d[0], d[1])) bal = bal and flt(bal[0][0]) or 0.0 if d[1] == 'Payable Voucher': bal = -bal # set voucher balance sql("update `tab%s` set outstanding_amount=%s where name='%s'"% (d[1], bal, d[0])) - sql("UNLOCK TABLES") # ==================================================================================== # Generate periods