nabinhait | 601c196 | 2011-06-14 17:52:03 +0530 | [diff] [blame] | 1 | import webnotes |
Ravi Dey | 3333ca1 | 2011-07-04 16:23:19 +0530 | [diff] [blame] | 2 | from webnotes import msgprint |
nabinhait | 601c196 | 2011-06-14 17:52:03 +0530 | [diff] [blame] | 3 | |
| 4 | feed_dict = { |
| 5 | # Project |
Rushabh Mehta | 3a50b34 | 2011-07-06 14:50:30 +0530 | [diff] [blame] | 6 | 'Project': ['[%(status)s]', '#000080'], |
nabinhait | 601c196 | 2011-06-14 17:52:03 +0530 | [diff] [blame] | 7 | |
| 8 | # Sales |
| 9 | 'Lead': ['%(lead_name)s', '#000080'], |
| 10 | 'Quotation': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'], |
| 11 | 'Sales Order': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'], |
| 12 | |
| 13 | # Purchase |
| 14 | 'Supplier': ['%(supplier_name)s, %(supplier_type)s', '#6495ED'], |
| 15 | 'Purchase Order': ['[%(status)s] %(name)s To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'], |
| 16 | |
| 17 | # Stock |
| 18 | 'Delivery Note': ['[%(status)s] To %(customer_name)s', '#4169E1'], |
Anand Doshi | edb45c6 | 2012-01-19 17:12:17 +0530 | [diff] [blame] | 19 | 'Purchase Receipt': ['[%(status)s] From %(supplier)s', '#4169E1'], |
nabinhait | 601c196 | 2011-06-14 17:52:03 +0530 | [diff] [blame] | 20 | |
| 21 | # Accounts |
| 22 | 'Journal Voucher': ['[%(voucher_type)s] %(name)s', '#4169E1'], |
| 23 | 'Payable Voucher': ['To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'], |
| 24 | 'Receivable Voucher':['To %(customer_name)s for %(currency)s %(grand_total_export)s', '#4169E1'], |
| 25 | |
| 26 | # HR |
| 27 | 'Expense Voucher': ['[%(approval_status)s] %(name)s by %(employee_name)s', '#4169E1'], |
| 28 | 'Salary Slip': ['%(employee_name)s for %(month)s %(fiscal_year)s', '#4169E1'], |
| 29 | 'Leave Transaction':['%(leave_type)s for %(employee)s', '#4169E1'], |
| 30 | |
| 31 | # Support |
| 32 | 'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'], |
| 33 | 'Maintenance Visit':['To %(customer_name)s', '#4169E1'], |
Ravi Dey | 913d7b5 | 2011-07-04 17:18:01 +0530 | [diff] [blame] | 34 | 'Support Ticket': ['[%(status)s] %(subject)s', '#000080'] |
nabinhait | 601c196 | 2011-06-14 17:52:03 +0530 | [diff] [blame] | 35 | } |
| 36 | |
nabinhait | 601c196 | 2011-06-14 17:52:03 +0530 | [diff] [blame] | 37 | def make_feed(doc, subject, color): |
| 38 | "makes a new Feed record" |
Ravi Dey | 3333ca1 | 2011-07-04 16:23:19 +0530 | [diff] [blame] | 39 | #msgprint(subject) |
nabinhait | 601c196 | 2011-06-14 17:52:03 +0530 | [diff] [blame] | 40 | from webnotes.model.doc import Document |
| 41 | webnotes.conn.sql("delete from tabFeed where doc_type=%s and doc_name=%s", (doc.doctype, doc.name)) |
| 42 | f = Document('Feed') |
| 43 | f.doc_type = doc.doctype |
| 44 | f.doc_name = doc.name |
| 45 | f.subject = subject |
| 46 | f.color = color |
| 47 | f.save(1) |
Ravi Dey | 913d7b5 | 2011-07-04 17:18:01 +0530 | [diff] [blame] | 48 | |
Ravi Dey | ffecc71 | 2011-07-07 13:51:46 +0530 | [diff] [blame] | 49 | def update_feed(doc, method=None): |
nabinhait | 601c196 | 2011-06-14 17:52:03 +0530 | [diff] [blame] | 50 | "adds a new feed" |
Rushabh Mehta | 3a50b34 | 2011-07-06 14:50:30 +0530 | [diff] [blame] | 51 | if method=='validate': |
| 52 | return |
Ravi Dey | e2ddb24 | 2011-07-04 16:47:24 +0530 | [diff] [blame] | 53 | subject, color = feed_dict.get(doc.doctype, [None, None]) |
nabinhait | 601c196 | 2011-06-14 17:52:03 +0530 | [diff] [blame] | 54 | if subject: |
Ravi Dey | 9514ee9 | 2011-07-04 16:49:25 +0530 | [diff] [blame] | 55 | subject = subject % doc.fields |
| 56 | make_feed(doc, subject, color) |