From 1be5bb7e6a3bc7ad282c23186037953ac190a586 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 12 Sep 2013 15:25:38 +0530 Subject: [PATCH] [portal] [minor] show status for order and invoice --- .../templates/pages/invoice.html | 6 +++++- .../sales_invoice/templates/pages/invoice.py | 16 ++++++++++++++- .../sales_invoice/templates/pages/invoices.py | 8 ++++++-- portal/templates/sale.html | 2 +- portal/templates/sales_transactions.html | 6 ++++-- portal/utils.py | 20 +++++++++++++------ .../sales_order/templates/pages/order.html | 6 +++++- .../sales_order/templates/pages/order.py | 18 ++++++++++++++++- .../sales_order/templates/pages/orders.py | 9 +++++++-- 9 files changed, 74 insertions(+), 17 deletions(-) diff --git a/accounts/doctype/sales_invoice/templates/pages/invoice.html b/accounts/doctype/sales_invoice/templates/pages/invoice.html index 376e5df7c2..db6e009f89 100644 --- a/accounts/doctype/sales_invoice/templates/pages/invoice.html +++ b/accounts/doctype/sales_invoice/templates/pages/invoice.html @@ -1 +1,5 @@ -{% extends "app/portal/templates/sale.html" %} \ No newline at end of file +{% extends "app/portal/templates/sale.html" %} + +{% block status -%} + {% if doc.status %}{{ doc.status }}{% endif %} +{%- endblock %} \ No newline at end of file diff --git a/accounts/doctype/sales_invoice/templates/pages/invoice.py b/accounts/doctype/sales_invoice/templates/pages/invoice.py index 200727c44e..8fc89135c9 100644 --- a/accounts/doctype/sales_invoice/templates/pages/invoice.py +++ b/accounts/doctype/sales_invoice/templates/pages/invoice.py @@ -3,14 +3,28 @@ from __future__ import unicode_literals import webnotes +from webnotes import _ +from webnotes.utils import flt, fmt_money no_cache = True def get_context(): from portal.utils import get_transaction_context context = get_transaction_context("Sales Invoice", webnotes.form_dict.name) + modify_status(context.get("doc")) context.update({ "parent_link": "invoices", "parent_title": "Invoices" }) - return context \ No newline at end of file + return context + +def modify_status(doc): + doc.status = "" + if flt(doc.outstanding_amount): + doc.status = ' %s' % \ + ("label-warning", "icon-exclamation-sign", + _("To Pay") + " = " + fmt_money(doc.outstanding_amount, currency=doc.currency)) + else: + doc.status = ' %s' % \ + ("label-success", "icon-ok", _("Paid")) + \ No newline at end of file diff --git a/accounts/doctype/sales_invoice/templates/pages/invoices.py b/accounts/doctype/sales_invoice/templates/pages/invoices.py index ec957f3a78..59e53a05c0 100644 --- a/accounts/doctype/sales_invoice/templates/pages/invoices.py +++ b/accounts/doctype/sales_invoice/templates/pages/invoices.py @@ -11,7 +11,7 @@ def get_context(): context = get_currency_context() context.update({ "title": "Invoices", - "method": "portal.templates.pages.invoices.get_invoices", + "method": "accounts.doctype.sales_invoice.templates.pages.invoices.get_invoices", "icon": "icon-file-text", "empty_list_message": "No Invoices Found", "page": "invoice" @@ -21,4 +21,8 @@ def get_context(): @webnotes.whitelist() def get_invoices(start=0): from portal.utils import get_transaction_list - return get_transaction_list("Sales Invoice", start) \ No newline at end of file + from accounts.doctype.sales_invoice.templates.pages.invoice import modify_status + invoices = get_transaction_list("Sales Invoice", start, ["outstanding_amount"]) + for d in invoices: + modify_status(d) + return invoices \ No newline at end of file diff --git a/portal/templates/sale.html b/portal/templates/sale.html index 41ba297d3a..2a7c6038da 100644 --- a/portal/templates/sale.html +++ b/portal/templates/sale.html @@ -17,7 +17,7 @@
- {% if doc.status -%}
{{ doc.status }}
{%- endif %} + {% block status -%}{%- endblock %}
{{ utils.formatdate(doc.posting_date or doc.transaction_date) }} diff --git a/portal/templates/sales_transactions.html b/portal/templates/sales_transactions.html index 10139c398b..5f337976ca 100644 --- a/portal/templates/sales_transactions.html +++ b/portal/templates/sales_transactions.html @@ -12,12 +12,14 @@