Merge branch 'master' into staging

This commit is contained in:
Nabin Hait 2017-09-25 16:03:32 +05:30
commit 39c2f75e6d
5 changed files with 29 additions and 12 deletions

View File

@ -4,7 +4,7 @@ import inspect
import frappe
from erpnext.hooks import regional_overrides
__version__ = '8.11.4'
__version__ = '8.11.5'
def get_default_company(user=None):
'''Get default company for user'''

View File

@ -346,6 +346,7 @@ erpnext.production_order = {
var max = flt(frm.doc.qty) - flt(frm.doc.produced_qty);
}
max = flt(max, precision("qty"));
frappe.prompt({fieldtype:"Float", label: __("Qty for {0}", [purpose]), fieldname:"qty",
description: __("Max: {0}", [max]), 'default': max },
function(data) {

View File

@ -288,12 +288,14 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
},
set_cumulative_total: function(row_idx, tax) {
var tax_amount = (in_list(["Valuation and Total", "Total"], tax.category) ?
tax.tax_amount_after_discount_amount : 0);
if (tax.add_deduct_tax == "Deduct") { tax_amount = -1*tax_amount; }
if(row_idx==0) {
tax.total = flt(this.frm.doc.net_total + tax.tax_amount_after_discount_amount,
precision("total", tax));
tax.total = flt(this.frm.doc.net_total + tax_amount, precision("total", tax));
} else {
tax.total = flt(this.frm.doc["taxes"][row_idx-1].total + tax.tax_amount_after_discount_amount,
precision("total", tax));
tax.total = flt(this.frm.doc["taxes"][row_idx-1].total + tax_amount, precision("total", tax));
}
},

View File

@ -121,8 +121,9 @@ cur_frm.cscript.change_abbr = function() {
dialog.fields_dict.update.$input.click(function() {
var args = dialog.get_values();
if(!args) return;
frappe.show_alert(__("Update in progress. It might take a while."));
return frappe.call({
method: "erpnext.setup.doctype.company.company.replace_abbr",
method: "erpnext.setup.doctype.company.company.enqueue_replace_abbr",
args: {
"company": cur_frm.doc.name,
"old": cur_frm.doc.abbr,

View File

@ -281,6 +281,13 @@ class Company(Document):
# delete mode of payment account
frappe.db.sql("delete from `tabMode of Payment Account` where company=%s", self.name)
@frappe.whitelist()
def enqueue_replace_abbr(company, old, new):
kwargs = dict(company=company, old=old, new=new)
frappe.enqueue('erpnext.setup.doctype.company.company.replace_abbr', **kwargs)
@frappe.whitelist()
def replace_abbr(company, old, new):
new = new.strip()
@ -291,16 +298,22 @@ def replace_abbr(company, old, new):
frappe.db.set_value("Company", company, "abbr", new)
def _rename_record(dt):
for d in frappe.db.sql("select name from `tab%s` where company=%s" % (dt, '%s'), company):
parts = d[0].rsplit(" - ", 1)
def _rename_record(doc):
parts = doc[0].rsplit(" - ", 1)
if len(parts) == 1 or parts[1].lower() == old.lower():
frappe.rename_doc(dt, d[0], parts[0] + " - " + new)
frappe.rename_doc(dt, doc[0], parts[0] + " - " + new)
def _rename_records(dt):
# rename is expensive so let's be economical with memory usage
doc = (d for d in frappe.db.sql("select name from `tab%s` where company=%s" % (dt, '%s'), company))
for d in doc:
_rename_record(d)
for dt in ["Warehouse", "Account", "Cost Center"]:
_rename_record(dt)
_rename_records(dt)
frappe.db.commit()
def get_name_with_abbr(name, company):
company_abbr = frappe.db.get_value("Company", company, "abbr")
parts = name.split(" - ")