Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import frappe |
| 6 | from frappe import _ |
Neil Trini Lasrado | d718c93 | 2014-10-22 15:56:38 +0530 | [diff] [blame] | 7 | from erpnext.templates.utils import get_transaction_context |
Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 8 | |
| 9 | no_cache = 1 |
| 10 | no_sitemap = 1 |
| 11 | |
| 12 | def get_context(context): |
| 13 | order_context = frappe._dict({ |
| 14 | "parent_link": "orders", |
| 15 | "parent_title": "My Orders" |
| 16 | }) |
| 17 | |
| 18 | order_context.update(get_transaction_context("Sales Order", frappe.form_dict.name)) |
| 19 | modify_status(order_context.doc) |
| 20 | return order_context |
| 21 | |
| 22 | def modify_status(doc): |
| 23 | doc.status = [] |
| 24 | if 0 < doc.per_billed < 100: |
| 25 | doc.status.append(("label-warning", "icon-ok", _("Partially Billed"))) |
| 26 | elif doc.per_billed == 100: |
| 27 | doc.status.append(("label-success", "icon-ok", _("Billed"))) |
| 28 | |
| 29 | if 0 < doc.per_delivered < 100: |
| 30 | doc.status.append(("label-warning", "icon-truck", _("Partially Delivered"))) |
| 31 | elif doc.per_delivered == 100: |
| 32 | doc.status.append(("label-success", "icon-truck", _("Delivered"))) |
| 33 | doc.status = " " + " ".join(('<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % s |
| 34 | for s in doc.status)) |