[minor] [selling] [fix] fetch available qty for given warehouse
This commit is contained in:
parent
648a5c7e33
commit
1dc95ed865
@ -189,6 +189,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
barcode: item.barcode,
|
barcode: item.barcode,
|
||||||
warehouse: item.warehouse,
|
warehouse: item.warehouse,
|
||||||
doctype: me.frm.doc.doctype,
|
doctype: me.frm.doc.doctype,
|
||||||
|
parentfield: item.parentfield,
|
||||||
customer: me.frm.doc.customer,
|
customer: me.frm.doc.customer,
|
||||||
currency: me.frm.doc.currency,
|
currency: me.frm.doc.currency,
|
||||||
conversion_rate: me.frm.doc.conversion_rate,
|
conversion_rate: me.frm.doc.conversion_rate,
|
||||||
@ -287,13 +288,13 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
|
|
||||||
warehouse: function(doc, cdt, cdn) {
|
warehouse: function(doc, cdt, cdn) {
|
||||||
var item = wn.model.get_doc(cdt, cdn);
|
var item = wn.model.get_doc(cdt, cdn);
|
||||||
if(item.item_code && (item.warehouse || item.reserved_warehouse)) {
|
if(item.item_code && item.warehouse) {
|
||||||
this.frm.call({
|
this.frm.call({
|
||||||
method: "selling.utils.get_available_qty",
|
method: "selling.utils.get_available_qty",
|
||||||
child: item,
|
child: item,
|
||||||
args: {
|
args: {
|
||||||
item_code: item.item_code,
|
item_code: item.item_code,
|
||||||
warehouse: item.warehouse || item.reserved_warehouse,
|
warehouse: item.warehouse,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -97,11 +97,21 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
|||||||
tc_name: function() {
|
tc_name: function() {
|
||||||
this.get_terms();
|
this.get_terms();
|
||||||
},
|
},
|
||||||
|
|
||||||
reserved_warehouse: function(doc, cdt, cdn) {
|
|
||||||
this.warehouse(doc, cdt, cdn);
|
|
||||||
},
|
|
||||||
|
|
||||||
|
reserved_warehouse: function(doc, cdt, cdn) {
|
||||||
|
var item = wn.model.get_doc(cdt, cdn);
|
||||||
|
if(item.item_code && item.reserved_warehouse) {
|
||||||
|
this.frm.call({
|
||||||
|
method: "selling.utils.get_available_qty",
|
||||||
|
child: item,
|
||||||
|
args: {
|
||||||
|
item_code: item.item_code,
|
||||||
|
warehouse: item.reserved_warehouse,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
make_material_request: function() {
|
make_material_request: function() {
|
||||||
wn.model.open_mapped_doc({
|
wn.model.open_mapped_doc({
|
||||||
method: "selling.doctype.sales_order.sales_order.make_material_request",
|
method: "selling.doctype.sales_order.sales_order.make_material_request",
|
||||||
|
@ -58,9 +58,15 @@ def get_item_details(args):
|
|||||||
|
|
||||||
_validate_item_details(args, item_bean.doc)
|
_validate_item_details(args, item_bean.doc)
|
||||||
|
|
||||||
out = _get_basic_details(args, item_bean)
|
|
||||||
|
|
||||||
meta = webnotes.get_doctype(args.doctype)
|
meta = webnotes.get_doctype(args.doctype)
|
||||||
|
|
||||||
|
# hack! for Sales Order Item
|
||||||
|
warehouse_fieldname = "warehouse"
|
||||||
|
if meta.get_field("reserved_warehouse", parentfield=args.parentfield):
|
||||||
|
warehouse_fieldname = "reserved_warehouse"
|
||||||
|
|
||||||
|
out = _get_basic_details(args, item_bean, warehouse_fieldname)
|
||||||
|
|
||||||
if meta.get_field("currency"):
|
if meta.get_field("currency"):
|
||||||
out.base_ref_rate = out.basic_rate = out.ref_rate = out.export_rate = 0.0
|
out.base_ref_rate = out.basic_rate = out.ref_rate = out.export_rate = 0.0
|
||||||
|
|
||||||
@ -69,8 +75,8 @@ def get_item_details(args):
|
|||||||
|
|
||||||
out.update(_get_item_discount(out.item_group, args.customer))
|
out.update(_get_item_discount(out.item_group, args.customer))
|
||||||
|
|
||||||
if out.warehouse or out.reserved_warehouse:
|
if out.get(warehouse_fieldname):
|
||||||
out.update(get_available_qty(args.item_code, out.warehouse or out.reserved_warehouse))
|
out.update(get_available_qty(args.item_code, out.get(warehouse_fieldname)))
|
||||||
|
|
||||||
out.customer_item_code = _get_customer_item_code(args, item_bean)
|
out.customer_item_code = _get_customer_item_code(args, item_bean)
|
||||||
|
|
||||||
@ -108,13 +114,13 @@ def _validate_item_details(args, item):
|
|||||||
msgprint(_("Item") + (" %s: " % item.name) + _("not a sales item"),
|
msgprint(_("Item") + (" %s: " % item.name) + _("not a sales item"),
|
||||||
raise_exception=True)
|
raise_exception=True)
|
||||||
|
|
||||||
def _get_basic_details(args, item_bean):
|
def _get_basic_details(args, item_bean, warehouse_fieldname):
|
||||||
item = item_bean.doc
|
item = item_bean.doc
|
||||||
|
|
||||||
out = webnotes._dict({
|
out = webnotes._dict({
|
||||||
"item_code": item.name,
|
"item_code": item.name,
|
||||||
"description": item.description_html or item.description,
|
"description": item.description_html or item.description,
|
||||||
"reserved_warehouse": item.default_warehouse or args.warehouse or args.reserved_warehouse,
|
warehouse_fieldname: item.default_warehouse or args.get(warehouse_fieldname),
|
||||||
"warehouse": item.default_warehouse or args.warehouse,
|
|
||||||
"income_account": item.default_income_account or args.income_account \
|
"income_account": item.default_income_account or args.income_account \
|
||||||
or webnotes.conn.get_value("Company", args.company, "default_income_account"),
|
or webnotes.conn.get_value("Company", args.company, "default_income_account"),
|
||||||
"expense_account": item.purchase_account or args.expense_account \
|
"expense_account": item.purchase_account or args.expense_account \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user