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