Merge branch 'website-wip'

This commit is contained in:
Anand Doshi
2013-09-19 12:27:11 +05:30
253 changed files with 1310 additions and 5414 deletions

View File

@@ -79,6 +79,10 @@ cur_frm.cscript.refresh = function(doc) {
}
}
cur_frm.cscript.company = function(doc, cdt, cdn) {
cur_frm.refresh_fields();
}
cur_frm.cscript.is_opening = function(doc, cdt, cdn) {
hide_field('aging_date');
if (doc.is_opening == 'Yes') unhide_field('aging_date');

View File

@@ -178,7 +178,7 @@ class DocType(AccountsController):
if account_type == 'Bank or Cash':
company_currency = get_company_currency(self.doc.company)
amt = flt(d.debit) and d.debit or d.credit
self.doc.total_amount = company_currency +' '+ cstr(amt)
self.doc.total_amount = company_currency + ' ' + cstr(amt)
from webnotes.utils import money_in_words
self.doc.total_amount_in_words = money_in_words(amt, company_currency)

View File

@@ -193,7 +193,7 @@ erpnext.POS = Class.extend({
</div>',
{
item_code: obj.name,
item_price: format_currency(obj.ref_rate, obj.ref_currency),
item_price: format_currency(obj.ref_rate, obj.currency),
item_name: obj.name===obj.item_name ? "" : obj.item_name,
item_image: image
})).appendTo($wrap);

View File

@@ -15,11 +15,14 @@ def get_items(price_list, item=None, item_group=None):
if item:
condition = "and i.name='%s'" % item
return webnotes.conn.sql("""select
i.name, i.item_name, i.image, ip.ref_rate, ip.ref_currency
from `tabItem` i LEFT JOIN `tabItem Price` ip
ON ip.parent=i.name
and ip.price_list=%s
return webnotes.conn.sql("""select i.name, i.item_name, i.image,
pl_items.ref_rate, pl_items.currency
from `tabItem` i LEFT JOIN
(select ip.item_code, ip.ref_rate, pl.currency from
`tabItem Price` ip, `tabPrice List` pl
where ip.parent=%s and ip.parent = pl.name) pl_items
ON
pl_items.item_code=i.name
where
i.is_sales_item='Yes'%s""" % ('%s', condition), (price_list), as_dict=1)

View File

@@ -73,45 +73,14 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
if(!from_delivery_note)
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
}
if(doc.outstanding_amount!=0)
cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
}
if (doc.docstatus===0) {
cur_frm.add_custom_button(wn._('From Sales Order'),
function() {
wn.model.map_current_doc({
method: "selling.doctype.sales_order.sales_order.make_sales_invoice",
source_doctype: "Sales Order",
get_query_filters: {
docstatus: 1,
status: ["!=", "Stopped"],
per_billed: ["<", 99.99],
customer: cur_frm.doc.customer || undefined,
company: cur_frm.doc.company
}
})
});
cur_frm.add_custom_button(wn._('From Delivery Note'),
function() {
wn.model.map_current_doc({
method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice",
source_doctype: "Delivery Note",
get_query: function() {
var filters = {
company: cur_frm.doc.company
};
if(cur_frm.doc.customer) filters["customer"] = cur_frm.doc.customer;
return {
query: "controllers.queries.get_delivery_notes_to_be_billed",
filters: filters
};
}
});
});
cur_frm.cscript.sales_order_btn();
cur_frm.cscript.delivery_note_btn();
}
// Show POS button only if it enabled from features setup
@@ -119,6 +88,43 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
cur_frm.cscript.pos_btn();
},
sales_order_btn: function() {
this.$sales_order_btn = cur_frm.add_custom_button(wn._('From Sales Order'),
function() {
wn.model.map_current_doc({
method: "selling.doctype.sales_order.sales_order.make_sales_invoice",
source_doctype: "Sales Order",
get_query_filters: {
docstatus: 1,
status: ["!=", "Stopped"],
per_billed: ["<", 99.99],
customer: cur_frm.doc.customer || undefined,
company: cur_frm.doc.company
}
})
});
},
delivery_note_btn: function() {
this.$delivery_note_btn = cur_frm.add_custom_button(wn._('From Delivery Note'),
function() {
wn.model.map_current_doc({
method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice",
source_doctype: "Delivery Note",
get_query: function() {
var filters = {
company: cur_frm.doc.company
};
if(cur_frm.doc.customer) filters["customer"] = cur_frm.doc.customer;
return {
query: "controllers.queries.get_delivery_notes_to_be_billed",
filters: filters
};
}
});
});
},
pos_btn: function() {
if(cur_frm.$pos_btn)
cur_frm.$pos_btn.remove();
@@ -126,9 +132,17 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
if(!cur_frm.pos_active) {
var btn_label = wn._("POS View"),
icon = "icon-desktop";
cur_frm.cscript.sales_order_btn();
cur_frm.cscript.delivery_note_btn();
} else {
var btn_label = wn._("Invoice View"),
icon = "icon-file-text";
if (cur_frm.doc.docstatus===0) {
this.$delivery_note_btn.remove();
this.$sales_order_btn.remove();
}
}
cur_frm.$pos_btn = cur_frm.add_custom_button(btn_label, function() {

View File

@@ -9,7 +9,7 @@ from webnotes.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdat
get_first_day, get_last_day
from webnotes.utils.email_lib import sendmail
from webnotes.utils import comma_and
from webnotes.utils import comma_and, get_url
from webnotes.model.doc import make_autoname
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
@@ -148,6 +148,9 @@ class DocType(SellingController):
self.validate_recurring_invoice()
self.convert_to_recurring()
def get_portal_page(self):
return "invoice" if self.doc.docstatus==1 else None
def set_missing_values(self, for_validate=False):
self.set_pos_fields(for_validate)
@@ -916,7 +919,7 @@ def notify_errors(inv, owner):
Regards,
Administrator
""" % (inv, website.get_site_address(), inv)
""" % (inv, get_url(), inv)
subj = "[Urgent] Error while creating recurring invoice from %s" % inv
from webnotes.profile import get_system_managers

View File

@@ -0,0 +1,5 @@
{% extends "app/portal/templates/sale.html" %}
{% block status -%}
{% if doc.status %}{{ doc.status }}{% endif %}
{%- endblock %}

View File

@@ -0,0 +1,30 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
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
def modify_status(doc):
doc.status = ""
if flt(doc.outstanding_amount):
doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
("label-warning", "icon-exclamation-sign",
_("To Pay") + " = " + fmt_money(doc.outstanding_amount, currency=doc.currency))
else:
doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
("label-success", "icon-ok", _("Paid"))

View File

@@ -0,0 +1 @@
{% extends "app/portal/templates/sales_transactions.html" %}

View File

@@ -0,0 +1,28 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
no_cache = True
def get_context():
from portal.utils import get_currency_context
context = get_currency_context()
context.update({
"title": "Invoices",
"method": "accounts.doctype.sales_invoice.templates.pages.invoices.get_invoices",
"icon": "icon-file-text",
"empty_list_message": "No Invoices Found",
"page": "invoice"
})
return context
@webnotes.whitelist()
def get_invoices(start=0):
from portal.utils import get_transaction_list
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