Merge branch 'hotfix'

This commit is contained in:
Sahil Khan
2019-07-11 15:15:56 +05:30
7 changed files with 56 additions and 36 deletions

View File

@@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
__version__ = '11.1.45'
__version__ = '11.1.46'
def get_default_company(user=None):
'''Get default company for user'''

View File

@@ -21,9 +21,29 @@ frappe.ui.form.on('Exchange Rate Revaluation', {
refresh: function(frm) {
if(frm.doc.docstatus==1) {
frm.add_custom_button(__('Make Journal Entry'), function() {
return frm.events.make_jv(frm);
});
frappe.db.get_value("Journal Entry Account", {
'reference_type': 'Exchange Rate Revaluation',
'reference_name': frm.doc.name,
'docstatus': 1
}, "sum(debit) as sum", (r) =>{
let total_amt = 0;
frm.doc.accounts.forEach(d=> {
total_amt = total_amt + d['new_balance_in_base_currency'];
});
if(total_amt === r.sum) {
frm.add_custom_button(__("Journal Entry"), function(){
frappe.route_options = {
'reference_type': 'Exchange Rate Revaluation',
'reference_name': frm.doc.name
};
frappe.set_route("List", "Journal Entry");
}, __("View"));
} else {
frm.add_custom_button(__('Create Journal Entry'), function() {
return frm.events.make_jv(frm);
});
}
}, 'Journal Entry');
}
},

View File

@@ -174,9 +174,13 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
method: "erpnext.selling.doctype.quotation.quotation.make_sales_invoice",
source_doctype: "Quotation",
target: me.frm,
setters: {
customer: me.frm.doc.customer || undefined,
},
setters: [{
fieldtype: 'Link',
label: __('Customer'),
options: 'Customer',
fieldname: 'party_name',
default: me.frm.doc.customer,
}],
get_query_filters: {
docstatus: 1,
status: ["!=", "Lost"],

View File

@@ -93,4 +93,6 @@ def get_chart_data(filters, columns, income, expense, net_profit_loss):
else:
chart["type"] = "line"
chart["fieldtype"] = "Currency"
return chart

View File

@@ -587,7 +587,6 @@ erpnext.utils.map_current_doc = function(opts) {
if(!r.exc) {
var doc = frappe.model.sync(r.message);
cur_frm.dirty();
erpnext.utils.clear_duplicates();
cur_frm.refresh();
}
}
@@ -618,28 +617,6 @@ erpnext.utils.map_current_doc = function(opts) {
}
}
erpnext.utils.clear_duplicates = function() {
if(!cur_frm.doc.items) return;
const unique_items = new Map();
/*
Create a Map of items with
item_code => [qty, warehouse, batch_no]
*/
let items = [];
for (let item of cur_frm.doc.items) {
if (!(unique_items.has(item.item_code) && unique_items.get(item.item_code)[0] === item.qty &&
unique_items.get(item.item_code)[1] === item.warehouse && unique_items.get(item.item_code)[2] === item.batch_no &&
unique_items.get(item.item_code)[3] === item.delivery_date && unique_items.get(item.item_code)[4] === item.required_date &&
unique_items.get(item.item_code)[5] === item.rate)) {
unique_items.set(item.item_code, [item.qty, item.warehouse, item.batch_no, item.delivery_date, item.required_date, item.rate]);
items.push(item);
}
}
cur_frm.doc.items = items;
}
frappe.form.link_formatters['Item'] = function(value, doc) {
if(doc && doc.item_name && doc.item_name !== value) {
return value? value + ': ' + doc.item_name: doc.item_name;

View File

@@ -486,13 +486,27 @@ def close_or_unclose_sales_orders(names, status):
frappe.local.message_log = []
def get_requested_item_qty(sales_order):
return frappe._dict(frappe.db.sql("""
select sales_order_item, sum(stock_qty)
from `tabMaterial Request Item`
where docstatus = 1
and sales_order = %s
group by sales_order_item
""", sales_order))
@frappe.whitelist()
def make_material_request(source_name, target_doc=None):
requested_item_qty = get_requested_item_qty(source_name)
def postprocess(source, doc):
doc.material_request_type = "Purchase"
def update_item(source, target, source_parent):
target.project = source_parent.project
target.qty = source.stock_qty - requested_item_qty.get(source.name, 0)
target.conversion_factor = 1
target.stock_qty = source.stock_qty - requested_item_qty.get(source.name, 0)
doc = get_mapped_doc("Sales Order", source_name, {
"Sales Order": {
@@ -517,7 +531,7 @@ def make_material_request(source_name, target_doc=None):
"stock_uom": "uom",
"stock_qty": "qty"
},
"condition": lambda doc: not frappe.db.exists('Product Bundle', doc.item_code),
"condition": lambda doc: not frappe.db.exists('Product Bundle', doc.item_code) and doc.stock_qty > requested_item_qty.get(doc.name, 0),
"postprocess": update_item
}
}, target_doc, postprocess)

View File

@@ -31,13 +31,16 @@ class ItemPrice(Document):
frappe.throw(_("Valid From Date must be lesser than Valid Upto Date."))
def update_price_list_details(self):
self.buying, self.selling, self.currency = \
frappe.db.get_value("Price List",
{"name": self.price_list, "enabled": 1},
["buying", "selling", "currency"])
if self.price_list:
self.buying, self.selling, self.currency = \
frappe.db.get_value("Price List",
{"name": self.price_list, "enabled": 1},
["buying", "selling", "currency"])
def update_item_details(self):
self.item_name, self.item_description = frappe.db.get_value("Item",self.item_code,["item_name", "description"])
if self.item_code:
self.item_name, self.item_description = frappe.db.get_value("Item",
self.item_code,["item_name", "description"])
def check_duplicates(self):
conditions = "where item_code=%(item_code)s and price_list=%(price_list)s and name != %(name)s"