Merge branch 'master' into perpetual

This commit is contained in:
Nabin Hait 2013-08-02 11:53:00 +05:30
commit bbe1448fca
24 changed files with 149 additions and 55 deletions

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-24 12:15:51", "creation": "2013-05-24 12:15:51",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-26 11:16:53", "modified": "2013-08-01 16:50:05",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -81,7 +81,6 @@
"reqd": 1 "reqd": 1
}, },
{ {
"default": "1",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "conversion_rate", "fieldname": "conversion_rate",
"fieldtype": "Float", "fieldtype": "Float",

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-21 16:16:39", "creation": "2013-05-21 16:16:39",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-25 16:08:44", "modified": "2013-08-01 16:49:49",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -223,7 +223,6 @@
"read_only": 0 "read_only": 0
}, },
{ {
"default": "1",
"description": "The rate at which Bill Currency is converted into company's base currency", "description": "The rate at which Bill Currency is converted into company's base currency",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "conversion_rate", "fieldname": "conversion_rate",

View File

@ -93,12 +93,18 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
wn.model.map_current_doc({ wn.model.map_current_doc({
method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice", method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice",
source_doctype: "Delivery Note", source_doctype: "Delivery Note",
get_query_filters: { get_query: function() {
var filters = {
docstatus: 1, docstatus: 1,
customer: cur_frm.doc.customer || undefined,
company: cur_frm.doc.company 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.add_custom_button(wn._("POS View"), function() { // cur_frm.add_custom_button(wn._("POS View"), function() {

View File

@ -975,10 +975,12 @@ def make_delivery_note(source_name, target_doclist=None):
bean = webnotes.bean(target) bean = webnotes.bean(target)
bean.run_method("onload_post_render") bean.run_method("onload_post_render")
def update_item(obj, target, source_parent): def update_item(source_doc, target_doc, source_parent):
target.amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate) target_doc.amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \
target.export_amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate) flt(source_doc.basic_rate)
target.qty = flt(obj.qty) - flt(obj.delivered_qty) target_doc.export_amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \
flt(source_doc.export_rate)
target_doc.qty = flt(source_doc.qty) - flt(source_doc.delivered_qty)
doclist = get_mapped_doclist("Sales Invoice", source_name, { doclist = get_mapped_doclist("Sales Invoice", source_name, {
"Sales Invoice": { "Sales Invoice": {

View File

@ -33,7 +33,7 @@ wn.pages['voucher-import-tool'].onload = function(wrapper) {
callback: function(fid, filename, r) { callback: function(fid, filename, r) {
wrapper.waiting.toggle(false); wrapper.waiting.toggle(false);
$(wrapper).find(".messages").toggle(true).html( $(wrapper).find(".messages").toggle(true).html(
r.join("<div style='margin:4px; border-top:1px solid #aaa;'></div>")) r.message.join("<div style='margin:4px; border-top:1px solid #aaa;'></div>"))
} }
}); });

View File

@ -43,7 +43,7 @@ def execute(filters=None):
purchase_receipt = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", []))) purchase_receipt = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", [])))
project_name = list(set(invoice_po_pr_map.get(inv.name, {}).get("project_name", []))) project_name = list(set(invoice_po_pr_map.get(inv.name, {}).get("project_name", [])))
row = [inv.name, inv.posting_date, inv.supplier_name, inv.credit_to, row = [inv.name, inv.posting_date, inv.supplier, inv.supplier_name, inv.credit_to,
account_map.get(inv.credit_to), ", ".join(project_name), inv.bill_no, inv.bill_date, account_map.get(inv.credit_to), ", ".join(project_name), inv.bill_no, inv.bill_date,
inv.remarks, ", ".join(purchase_order), ", ".join(purchase_receipt)] inv.remarks, ", ".join(purchase_order), ", ".join(purchase_receipt)]
@ -76,9 +76,10 @@ def execute(filters=None):
def get_columns(invoice_list): def get_columns(invoice_list):
"""return columns based on filters""" """return columns based on filters"""
columns = [ columns = [
"Invoice:Link/Purchase Invoice:120", "Posting Date:Date:80", "Supplier::120", "Invoice:Link/Purchase Invoice:120", "Posting Date:Date:80", "Supplier Id::120",
"Supplier Account:Link/Account:120", "Account Group:LInk/Account:120", "Supplier Name::120", "Supplier Account:Link/Account:120",
"Project:Link/Project:80", "Bill No::120", "Bill Date:Date:80", "Remarks::150", "Account Group:LInk/Account:120", "Project:Link/Project:80", "Bill No::120",
"Bill Date:Date:80", "Remarks::150",
"Purchase Order:Link/Purchase Order:100", "Purchase Receipt:Link/Purchase Receipt:100" "Purchase Order:Link/Purchase Order:100", "Purchase Receipt:Link/Purchase Receipt:100"
] ]
expense_accounts = tax_accounts = expense_columns = tax_columns = [] expense_accounts = tax_accounts = expense_columns = tax_columns = []

View File

@ -43,7 +43,7 @@ def execute(filters=None):
sales_order = list(set(invoice_so_dn_map.get(inv.name, {}).get("sales_order", []))) sales_order = list(set(invoice_so_dn_map.get(inv.name, {}).get("sales_order", [])))
delivery_note = list(set(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", []))) delivery_note = list(set(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", [])))
row = [inv.name, inv.posting_date, inv.customer_name, inv.debit_to, row = [inv.name, inv.posting_date, inv.customer, inv.customer_name, inv.debit_to,
account_map.get(inv.debit_to), customer_map.get(inv.customer), inv.project_name, account_map.get(inv.debit_to), customer_map.get(inv.customer), inv.project_name,
inv.remarks, ", ".join(sales_order), ", ".join(delivery_note)] inv.remarks, ", ".join(sales_order), ", ".join(delivery_note)]
@ -76,10 +76,10 @@ def execute(filters=None):
def get_columns(invoice_list): def get_columns(invoice_list):
"""return columns based on filters""" """return columns based on filters"""
columns = [ columns = [
"Invoice:Link/Sales Invoice:120", "Posting Date:Date:80", "Customer::120", "Invoice:Link/Sales Invoice:120", "Posting Date:Date:80", "Customer Id::120",
"Customer Account:Link/Account:120", "Account Group:LInk/Account:120", "Customer Name::120", "Customer Account:Link/Account:120", "Account Group:LInk/Account:120",
"Territory:Link/Territory:80", "Project:Link/Project:80", "Territory:Link/Territory:80", "Project:Link/Project:80", "Remarks::150",
"Remarks::150", "Sales Order:Link/Sales Order:100", "Delivery Note:Link/Delivery Note:100" "Sales Order:Link/Sales Order:100", "Delivery Note:Link/Delivery Note:100"
] ]
income_accounts = tax_accounts = income_columns = tax_columns = [] income_accounts = tax_accounts = income_columns = tax_columns = []

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-21 16:16:39", "creation": "2013-05-21 16:16:39",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-23 15:26:28", "modified": "2013-08-01 16:49:16",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -191,7 +191,6 @@
"reqd": 1 "reqd": 1
}, },
{ {
"default": "1",
"description": "Rate at which supplier's currency is converted to company's base currency", "description": "Rate at which supplier's currency is converted to company's base currency",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "conversion_rate", "fieldname": "conversion_rate",
@ -313,7 +312,7 @@
"fieldname": "purchase_other_charges", "fieldname": "purchase_other_charges",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Purchase Taxes and Charges", "label": "Purchase Taxes and Charges",
"no_copy": 1, "no_copy": 0,
"oldfieldname": "purchase_other_charges", "oldfieldname": "purchase_other_charges",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Purchase Taxes and Charges Master", "options": "Purchase Taxes and Charges Master",

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-21 16:16:45", "creation": "2013-05-21 16:16:45",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-23 15:27:23", "modified": "2013-08-01 16:49:33",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -186,7 +186,6 @@
"reqd": 1 "reqd": 1
}, },
{ {
"default": "1",
"description": "Rate at which supplier's currency is converted to company's base currency", "description": "Rate at which supplier's currency is converted to company's base currency",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "conversion_rate", "fieldname": "conversion_rate",

View File

@ -67,6 +67,7 @@ class AccountsController(TransactionBase):
self.doc.doctype + _(" can not be made."), raise_exception=1) self.doc.doctype + _(" can not be made."), raise_exception=1)
def set_price_list_currency(self, buying_or_selling): def set_price_list_currency(self, buying_or_selling):
company_currency = get_company_currency(self.doc.company)
# TODO - change this, since price list now has only one currency allowed # TODO - change this, since price list now has only one currency allowed
if self.meta.get_field("price_list_name") and self.doc.price_list_name and \ if self.meta.get_field("price_list_name") and self.doc.price_list_name and \
not self.doc.price_list_currency: not self.doc.price_list_currency:
@ -74,7 +75,6 @@ class AccountsController(TransactionBase):
if self.doc.price_list_currency: if self.doc.price_list_currency:
if not self.doc.plc_conversion_rate: if not self.doc.plc_conversion_rate:
company_currency = get_company_currency(self.doc.company)
if self.doc.price_list_currency == company_currency: if self.doc.price_list_currency == company_currency:
self.doc.plc_conversion_rate = 1.0 self.doc.plc_conversion_rate = 1.0
else: else:
@ -86,6 +86,12 @@ class AccountsController(TransactionBase):
self.doc.currency = self.doc.price_list_currency self.doc.currency = self.doc.price_list_currency
self.doc.conversion_rate = self.doc.plc_conversion_rate self.doc.conversion_rate = self.doc.plc_conversion_rate
if self.meta.get_field("currency") and self.doc.currency != company_currency and \
not self.doc.conversion_rate:
exchange = self.doc.currency + "-" + company_currency
self.doc.conversion_rate = flt(webnotes.conn.get_value("Currency Exchange",
exchange, "exchange_rate"))
def set_missing_item_details(self, get_item_details): def set_missing_item_details(self, get_item_details):
"""set missing item values""" """set missing item values"""
for item in self.doclist.get({"parentfield": self.fname}): for item in self.doclist.get({"parentfield": self.fname}):

View File

@ -23,7 +23,7 @@ def get_filters_cond(doctype, filters, conditions):
filters = filters.items() filters = filters.items()
flt = [] flt = []
for f in filters: for f in filters:
if f[1][0] == '!': if isinstance(f[1], basestring) and f[1][0] == '!':
flt.append([doctype, f[0], '!=', f[1][1:]]) flt.append([doctype, f[0], '!=', f[1][1:]])
else: else:
flt.append([doctype, f[0], '=', f[1]]) flt.append([doctype, f[0], '=', f[1]])
@ -205,3 +205,19 @@ def get_price_list_currency(doctype, txt, searchfield, start, page_len, filters)
("%s", "%s", searchfield, "%s", "%s", "%s"), ("%s", "%s", searchfield, "%s", "%s", "%s"),
(filters["price_list_name"], filters['buying_or_selling'], "%%%s%%" % txt, (filters["price_list_name"], filters['buying_or_selling'], "%%%s%%" % txt,
start, page_len)) start, page_len))
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.sql("""select `tabDelivery Note`.name, `tabDelivery Note`.customer_name
from `tabDelivery Note`
where `tabDelivery Note`.`%(key)s` like %(txt)s %(fcond)s and
(ifnull((select sum(qty) from `tabDelivery Note Item` where
`tabDelivery Note Item`.parent=`tabDelivery Note`.name), 0) >
ifnull((select sum(qty) from `tabSales Invoice Item` where
`tabSales Invoice Item`.delivery_note=`tabDelivery Note`.name), 0))
%(mcond)s order by `tabDelivery Note`.`%(key)s` asc
limit %(start)s, %(page_len)s""" % {
"key": searchfield,
"fcond": get_filters_cond(doctype, filters, []),
"mcond": get_match_cond(doctype),
"start": "%(start)s", "page_len": "%(page_len)s", "txt": "%(txt)s"
}, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) }, debug=True)

View File

@ -127,12 +127,12 @@ pscript.feature_dict = {
'Sales Order': {'sales_order_details':['page_break']} 'Sales Order': {'sales_order_details':['page_break']}
}, },
'fs_exports': { 'fs_exports': {
'Delivery Note': {'fields':['conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'delivery_note_details':['base_ref_rate','amount','basic_rate']}, 'Delivery Note': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'delivery_note_details':['base_ref_rate','amount','basic_rate']},
'POS Setting': {'fields':['conversion_rate','currency']}, 'POS Setting': {'fields':['conversion_rate','currency']},
'Quotation': {'fields':['conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'quotation_details':['base_ref_rate','amount','basic_rate']}, 'Quotation': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'quotation_details':['base_ref_rate','amount','basic_rate']},
'Sales Invoice': {'fields':['conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'entries':['base_ref_rate','amount','basic_rate']}, 'Sales Invoice': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'entries':['base_ref_rate','amount','basic_rate']},
'Sales BOM': {'fields':['currency']}, 'Sales BOM': {'fields':['currency']},
'Sales Order': {'fields':['conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'sales_order_details':['base_ref_rate','amount','basic_rate']} 'Sales Order': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'sales_order_details':['base_ref_rate','amount','basic_rate']}
}, },
'fs_imports': { 'fs_imports': {

View File

@ -20,8 +20,8 @@ span, div, td, input, textarea, button, select {
} }
.expiry-info { .expiry-info {
margin-top: 40px; margin-top: -20px;
margin-bottom: -40px; margin-bottom: 20px;
text-align: center; text-align: center;
background-color: rgb(255, 255, 204); background-color: rgb(255, 255, 204);
padding: 7px; padding: 7px;

View File

@ -24,11 +24,14 @@ erpnext.toolbar.setup = function() {
+wn._("My Settings")+'...</a></li>'); +wn._("My Settings")+'...</a></li>');
$user.append('<li class="divider"></li>'); $user.append('<li class="divider"></li>');
$user.append('<li><a href="https://erpnext.com/manual" target="_blank">\ $user.append('<li><a href="https://erpnext.com/manual" target="_blank">\
<i class="icon-fixed-width icon-file"></i> '+wn._('Documentation')+'</a></li>') <i class="icon-fixed-width icon-file"></i> '+wn._('Documentation')+'</a></li>');
$user.append('<li><a href="http://groups.google.com/group/erpnext-user-forum" target="_blank">\ $user.append('<li><a href="http://groups.google.com/group/erpnext-user-forum" target="_blank">\
<i class="icon-fixed-width icon-quote-left"></i> '+wn._('Forum')+'</a></li>') <i class="icon-fixed-width icon-quote-left"></i> '+wn._('Forum')+'</a></li>');
if(wn.boot.expires_on) {
$user.append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\ $user.append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\
<i class="icon-fixed-width icon-comments"></i> '+wn._('Live Chat')+'</a></li>') <i class="icon-fixed-width icon-comments"></i> '+wn._('Live Chat')+'</a></li>');
}
erpnext.toolbar.set_new_comments(); erpnext.toolbar.set_new_comments();

View File

@ -75,8 +75,10 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
company: function() { company: function() {
if(this.frm.doc.company && this.frm.fields_dict.currency) { if(this.frm.doc.company && this.frm.fields_dict.currency) {
var company_currency = this.get_company_currency(); if(!this.frm.doc.currency) {
this.frm.set_value("currency", company_currency); this.frm.set_value("currency", this.get_company_currency());
}
this.frm.script_manager.trigger("currency"); this.frm.script_manager.trigger("currency");
} }
}, },

View File

@ -121,10 +121,14 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
} }
}, },
refresh: function(doc) { refresh: function() {
this._super();
this.frm.toggle_display("customer_name", this.frm.toggle_display("customer_name",
(this.customer_name && this.frm.doc.customer_name!==this.frm.doc.customer)); (this.customer_name && this.frm.doc.customer_name!==this.frm.doc.customer));
this._super(); if(this.frm.fields_dict.packing_details) {
var packing_list_exists = this.frm.get_doclist({parentfield: "packing_details"}).length;
this.frm.toggle_display("packing_list", packing_list_exists ? true : false);
}
}, },
customer: function() { customer: function() {

View File

@ -153,7 +153,7 @@ def _get_price_list_rate(args, item_bean, meta):
from utilities.transaction_base import validate_currency from utilities.transaction_base import validate_currency
validate_currency(args, item_bean.doc, meta) validate_currency(args, item_bean.doc, meta)
return {"ref_rate": flt(base_ref_rate[0].ref_rate * args.plc_conversion_rate / args.conversion_rate)} return {"ref_rate": flt(base_ref_rate[0].ref_rate) * flt(args.plc_conversion_rate) / flt(args.conversion_rate)}
def _get_item_discount(item_group, customer): def _get_item_discount(item_group, customer):
parent_item_groups = [x[0] for x in webnotes.conn.sql("""SELECT parent.name parent_item_groups = [x[0] for x in webnotes.conn.sql("""SELECT parent.name

View File

@ -17,6 +17,10 @@
cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.abbr && !doc.__islocal) if(doc.abbr && !doc.__islocal)
cur_frm.set_df_property("abbr", "read_only", 1) cur_frm.set_df_property("abbr", "read_only", 1)
if(!doc.__islocal) {
cur_frm.toggle_enable("default_currency", !cur_frm.doc.__transactions_exist);
}
} }
cur_frm.cscript.has_special_chars = function(t) { cur_frm.cscript.has_special_chars = function(t) {

View File

@ -29,11 +29,31 @@ class DocType:
def __init__(self,d,dl): def __init__(self,d,dl):
self.doc, self.doclist = d,dl self.doc, self.doclist = d,dl
def onload(self):
self.doc.fields["__transactions_exist"] = self.check_if_transactions_exist()
def check_if_transactions_exist(self):
exists = False
for doctype in ["Sales Invoice", "Delivery Note", "Sales Order", "Quotation",
"Purchase Invoice", "Purchase Receipt", "Purchase Order", "Supplier Quotation"]:
if webnotes.conn.sql("""select name from `tab%s` where company=%s and docstatus=1
limit 1""" % (doctype, "%s"), self.doc.name):
exists = True
break
return exists
def validate(self): def validate(self):
if self.doc.fields.get('__islocal') and len(self.doc.abbr) > 5: if self.doc.fields.get('__islocal') and len(self.doc.abbr) > 5:
webnotes.msgprint("Abbreviation cannot have more than 5 characters", webnotes.msgprint("Abbreviation cannot have more than 5 characters",
raise_exception=1) raise_exception=1)
self.previous_default_currency = webnotes.conn.get_value("Company", self.doc.name, "default_currency")
if self.doc.default_currency and self.previous_default_currency and \
self.doc.default_currency != self.previous_default_currency and \
self.check_if_transactions_exist():
msgprint(_("Sorry! You cannot change company's default currency, because there are existing transactions against it. You will need to cancel those transactions if you want to change the default currency."), raise_exception=True)
def on_update(self): def on_update(self):
if not webnotes.conn.sql("""select name from tabAccount if not webnotes.conn.sql("""select name from tabAccount
where company=%s and docstatus<2 limit 1""", self.doc.name): where company=%s and docstatus<2 limit 1""", self.doc.name):

View File

@ -19,6 +19,7 @@ import webnotes
from webnotes import msgprint, _ from webnotes import msgprint, _
from webnotes.utils import comma_or, cint from webnotes.utils import comma_or, cint
from webnotes.model.controller import DocListController from webnotes.model.controller import DocListController
import webnotes.defaults
class DocType(DocListController): class DocType(DocListController):
def onload(self): def onload(self):
@ -30,6 +31,15 @@ class DocType(DocListController):
msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " + msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " +
comma_or(["Buying", "Selling"]), raise_exception=True) comma_or(["Buying", "Selling"]), raise_exception=True)
if not self.doclist.get({"parentfield": "valid_for_territories"}):
# if no territory, set default territory
if webnotes.defaults.get_user_default("territory"):
self.doclist.append({
"doctype": "For Territory",
"parentfield": "valid_for_territories",
"territory": webnotes.defaults.get_user_default("territory")
})
else:
# at least one territory # at least one territory
self.validate_table_has_rows("valid_for_territories") self.validate_table_has_rows("valid_for_territories")

View File

@ -344,12 +344,38 @@ class DocType(SellingController):
from accounts.general_ledger import make_gl_entries from accounts.general_ledger import make_gl_entries
make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2)) make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2))
def get_invoiced_qty_map(delivery_note):
"""returns a map: {dn_detail: invoiced_qty}"""
invoiced_qty_map = {}
for dn_detail, qty in webnotes.conn.sql("""select dn_detail, qty from `tabSales Invoice Item`
where delivery_note=%s and docstatus=1""", delivery_note):
if not invoiced_qty_map.get(dn_detail):
invoiced_qty_map[dn_detail] = 0
invoiced_qty_map[dn_detail] += qty
return invoiced_qty_map
@webnotes.whitelist() @webnotes.whitelist()
def make_sales_invoice(source_name, target_doclist=None): def make_sales_invoice(source_name, target_doclist=None):
invoiced_qty_map = get_invoiced_qty_map(source_name)
def update_accounts(source, target): def update_accounts(source, target):
si = webnotes.bean(target) si = webnotes.bean(target)
si.run_method("onload_post_render") si.run_method("onload_post_render")
si.set_doclist(si.doclist.get({"parentfield": ["!=", "entries"]}) +
si.doclist.get({"parentfield": "entries", "qty": [">", 0]}))
if len(si.doclist.get({"parentfield": "entries"})) == 0:
webnotes.msgprint(_("Hey! All these items have already been invoiced."),
raise_exception=True)
return si.doclist
def update_item(source_doc, target_doc, source_parent):
target_doc.qty = source_doc.qty - invoiced_qty_map.get(source_doc.name, 0)
doclist = get_mapped_doclist("Delivery Note", source_name, { doclist = get_mapped_doclist("Delivery Note", source_name, {
"Delivery Note": { "Delivery Note": {
"doctype": "Sales Invoice", "doctype": "Sales Invoice",
@ -366,6 +392,7 @@ def make_sales_invoice(source_name, target_doclist=None):
"prevdoc_docname": "sales_order", "prevdoc_docname": "sales_order",
"serial_no": "serial_no" "serial_no": "serial_no"
}, },
"postprocess": update_item
}, },
"Sales Taxes and Charges": { "Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges", "doctype": "Sales Taxes and Charges",

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-02 16:29:48", "creation": "2013-05-02 16:29:48",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-10 14:54:09", "modified": "2013-07-31 17:30:34",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -49,7 +49,7 @@
"oldfieldname": "ref_rate", "oldfieldname": "ref_rate",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "ref_currency", "options": "ref_currency",
"reqd": 0, "reqd": 1,
"search_index": 0 "search_index": 0
}, },
{ {

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-02-22 01:28:02", "creation": "2013-02-22 01:28:02",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-10 14:54:10", "modified": "2013-08-01 12:23:40",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -47,7 +47,7 @@
"fieldtype": "Date", "fieldtype": "Date",
"in_list_view": 1, "in_list_view": 1,
"label": "Required Date", "label": "Required Date",
"no_copy": 1, "no_copy": 0,
"oldfieldname": "schedule_date", "oldfieldname": "schedule_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 0, "print_hide": 0,

View File

@ -39,9 +39,6 @@ $.extend(cur_frm.cscript, {
cur_frm.footer.help_area.innerHTML = '<p><a href="#Form/Email Settings/Email Settings">Email Settings</a><br>\ cur_frm.footer.help_area.innerHTML = '<p><a href="#Form/Email Settings/Email Settings">Email Settings</a><br>\
<span class="help">Integrate incoming support emails to Support Ticket</span></p>'; <span class="help">Integrate incoming support emails to Support Ticket</span></p>';
} }
if(doc.description)
doc.description = wn.utils.escape_script_and_style(doc.description);
}, },
refresh: function(doc) { refresh: function(doc) {