Merge branch 'v4.x.x'

This commit is contained in:
Pratik Vyas 2015-03-20 17:32:07 +05:30
commit c7402e2989
9 changed files with 80 additions and 108 deletions

View File

@ -1,2 +1,2 @@
from __future__ import unicode_literals from __future__ import unicode_literals
__version__ = '4.24.1' __version__ = '4.24.2'

View File

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.widgets.reportview import get_match_cond from frappe.widgets.reportview import get_match_cond
from frappe.model.db_query import DatabaseQuery from frappe.model.db_query import DatabaseQuery
from frappe.utils import nowdate
def get_filters_cond(doctype, filters, conditions): def get_filters_cond(doctype, filters, conditions):
if filters: if filters:
@ -154,8 +155,6 @@ def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
return tax_accounts return tax_accounts
def item_query(doctype, txt, searchfield, start, page_len, filters): def item_query(doctype, txt, searchfield, start, page_len, filters):
from frappe.utils import nowdate
conditions = [] conditions = []
return frappe.db.sql("""select tabItem.name, return frappe.db.sql("""select tabItem.name,
@ -229,36 +228,48 @@ def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len,
}, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) }) }, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) })
def get_batch_no(doctype, txt, searchfield, start, page_len, filters): def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
from erpnext.controllers.queries import get_match_cond if not filters.get("posting_date"):
filters["posting_date"] = nowdate()
if filters.has_key('warehouse'): batch_nos = None
return frappe.db.sql("""select batch_no from `tabStock Ledger Entry` sle args = {
where item_code = '%(item_code)s' 'item_code': filters.get("item_code"),
and warehouse = '%(warehouse)s' 'warehouse': filters.get("warehouse"),
and batch_no like '%(txt)s' 'posting_date': filters.get('posting_date'),
and exists(select * from `tabBatch` 'txt': "%%%s%%" % txt,
where name = sle.batch_no 'mcond':get_match_cond(doctype),
and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s') "start": start,
and docstatus != 2) "page_len": page_len
%(mcond)s }
group by batch_no having sum(actual_qty) > 0
order by batch_no desc if args.get("warehouse"):
limit %(start)s, %(page_len)s """ % {'item_code': filters['item_code'], batch_nos = frappe.db.sql("""select sle.batch_no
'warehouse': filters['warehouse'], 'posting_date': filters['posting_date'], from `tabStock Ledger Entry` sle, `tabBatch`
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype), where sle.batch_no = `tabBatch`.name
'start': start, 'page_len': page_len}) and sle.item_code = '%(item_code)s'
and sle.warehouse = '%(warehouse)s'
and sle.batch_no like '%(txt)s'
and (ifnull(`tabBatch`.expiry_date, '2099-12-31') >= %(posting_date)s
or `tabBatch`.expiry_date = '')
and `tabBatch`.docstatus != 2
%(mcond)s
group by batch_no having sum(actual_qty) > 0
order by batch_no desc
limit %(start)s, %(page_len)s """
% args)
if batch_nos:
return batch_nos
else: else:
return frappe.db.sql("""select name from tabBatch return frappe.db.sql("""select name from `tabBatch`
where docstatus != 2 where item = '%(item_code)s'
and item = '%(item_code)s' and docstatus < 2
and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s') and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s
and name like '%(txt)s' or expiry_date = '' or expiry_date = "0000-00-00")
%(mcond)s %(mcond)s
order by name desc order by name desc
limit %(start)s, %(page_len)s""" % {'item_code': filters['item_code'], limit %(start)s, %(page_len)s
'posting_date': filters['posting_date'], 'txt': "%%%s%%" % txt, """ % args)
'mcond':get_match_cond(doctype),'start': start,
'page_len': page_len})
def get_account_list(doctype, txt, searchfield, start, page_len, filters): def get_account_list(doctype, txt, searchfield, start, page_len, filters):
filter_list = [] filter_list = []

View File

@ -5,7 +5,7 @@ app_publisher = "Web Notes Technologies Pvt. Ltd. and Contributors"
app_description = "Open Source Enterprise Resource Planning for Small and Midsized Organizations" app_description = "Open Source Enterprise Resource Planning for Small and Midsized Organizations"
app_icon = "icon-th" app_icon = "icon-th"
app_color = "#e74c3c" app_color = "#e74c3c"
app_version = "4.24.1" app_version = "4.24.2"
error_report_email = "support@erpnext.com" error_report_email = "support@erpnext.com"

View File

@ -500,20 +500,23 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
}) })
} }
}, },
batch_no: function(doc, cdt, cdn) { batch_no: function(doc, cdt, cdn) {
var me = this; var me = this;
var item = frappe.get_doc(cdt, cdn); var item = frappe.get_doc(cdt, cdn);
return this.frm.call({
method: "erpnext.stock.get_item_details.get_batch_qty", if(doc.warehouse && doc.item_code && doc.batch_no) {
child: item, return this.frm.call({
args: { method: "erpnext.stock.get_item_details.get_batch_qty",
"batch_no": item.batch_no, child: item,
"warehouse": item.warehouse, args: {
"item_code": item.item_code "batch_no": item.batch_no,
}, "warehouse": item.warehouse,
"fieldname": "actual_batch_qty" "item_code": item.item_code
}); },
"fieldname": "actual_batch_qty"
});
}
}, },
set_dynamic_labels: function() { set_dynamic_labels: function() {

View File

@ -185,6 +185,7 @@ def set_missing_values(source, target_doc):
def update_item(obj, target, source_parent): def update_item(obj, target, source_parent):
target.conversion_factor = 1 target.conversion_factor = 1
target.qty = flt(obj.qty) - flt(obj.ordered_qty) target.qty = flt(obj.qty) - flt(obj.ordered_qty)
target.stock_qty = target.qty
@frappe.whitelist() @frappe.whitelist()
def make_purchase_order(source_name, target_doc=None): def make_purchase_order(source_name, target_doc=None):

View File

@ -378,18 +378,20 @@ cur_frm.cscript.purpose = function(doc, cdt, cdn) {
// Overloaded query for link batch_no // Overloaded query for link batch_no
cur_frm.fields_dict['mtn_details'].grid.get_field('batch_no').get_query = function(doc, cdt, cdn) { cur_frm.fields_dict['mtn_details'].grid.get_field('batch_no').get_query = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var item = locals[cdt][cdn];
if(d.item_code) { if(!item.item_code) {
return{ frappe.throw(__("Please enter Item Code to get batch nos"));
query: "erpnext.stock.doctype.stock_entry.stock_entry.get_batch_no",
filters:{
'item_code': d.item_code,
's_warehouse': d.s_warehouse,
'posting_date': doc.posting_date
}
}
} else { } else {
msgprint(__("Please enter Item Code to get batch no")); filters = {
'item_code': item.item_code,
'posting_date': me.frm.doc.posting_date,
}
if(item.s_warehouse) filters["warehouse"] = item.s_warehouse
return {
query : "erpnext.controllers.queries.get_batch_no",
filters: filters
}
} }
} }

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
import frappe.defaults import frappe.defaults
from frappe.utils import cstr, cint, flt, comma_or, nowdate from frappe.utils import cstr, cint, flt, comma_or
from frappe import _ from frappe import _
from erpnext.stock.utils import get_incoming_rate from erpnext.stock.utils import get_incoming_rate
@ -680,51 +680,6 @@ def query_return_item(doctype, txt, searchfield, start, page_len, filters):
return result[start:start+page_len] return result[start:start+page_len]
def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
if not filters.get("posting_date"):
filters["posting_date"] = nowdate()
batch_nos = None
args = {
'item_code': filters.get("item_code"),
's_warehouse': filters.get('s_warehouse'),
'posting_date': filters.get('posting_date'),
'txt': "%%%s%%" % txt,
'mcond':get_match_cond(doctype),
"start": start,
"page_len": page_len
}
if filters.get("s_warehouse"):
batch_nos = frappe.db.sql("""select batch_no
from `tabStock Ledger Entry` sle
where item_code = '%(item_code)s'
and warehouse = '%(s_warehouse)s'
and batch_no like '%(txt)s'
and exists(select * from `tabBatch`
where name = sle.batch_no
and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s
or expiry_date = '')
and docstatus != 2)
%(mcond)s
group by batch_no having sum(actual_qty) > 0
order by batch_no desc
limit %(start)s, %(page_len)s """
% args)
if batch_nos:
return batch_nos
else:
return frappe.db.sql("""select name from `tabBatch`
where item = '%(item_code)s'
and docstatus < 2
and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s
or expiry_date = '' or expiry_date = "0000-00-00")
%(mcond)s
order by name desc
limit %(start)s, %(page_len)s
""" % args)
def get_stock_items_for_return(ref_doc, parentfields): def get_stock_items_for_return(ref_doc, parentfields):
"""return item codes filtered from doc, which are stock items""" """return item codes filtered from doc, which are stock items"""
if isinstance(parentfields, basestring): if isinstance(parentfields, basestring):

View File

@ -279,13 +279,13 @@ def get_serial_nos_by_fifo(args, item_doc):
})) }))
def get_actual_batch_qty(batch_no,warehouse,item_code): def get_actual_batch_qty(batch_no,warehouse,item_code):
actual_batch_qty = 0 actual_batch_qty = 0
if batch_no: if batch_no:
actual_batch_qty = flt(frappe.db.sql("""select sum(actual_qty) actual_batch_qty = flt(frappe.db.sql("""select sum(actual_qty)
from `tabStock Ledger Entry` from `tabStock Ledger Entry`
where warehouse=%s and item_code=%s and batch_no=%s""", where warehouse=%s and item_code=%s and batch_no=%s""",
(warehouse, item_code, batch_no))[0][0]) (warehouse, item_code, batch_no))[0][0])
return actual_batch_qty return actual_batch_qty
@frappe.whitelist() @frappe.whitelist()
def get_conversion_factor(item_code, uom): def get_conversion_factor(item_code, uom):

View File

@ -1,7 +1,7 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
import os import os
version = "4.24.1" version = "4.24.2"
with open("requirements.txt", "r") as f: with open("requirements.txt", "r") as f:
install_requires = f.readlines() install_requires = f.readlines()