[Fix] Fetch Serial No by default for Delivery Note Item
This commit is contained in:
parent
2ada1600ed
commit
af0d6378f1
@ -11,6 +11,7 @@ from frappe import throw, _
|
||||
from frappe.utils import flt, cint
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class MultiplePricingRuleConflict(frappe.ValidationError): pass
|
||||
|
||||
class PricingRule(Document):
|
||||
@ -113,8 +114,19 @@ def apply_pricing_rule(args):
|
||||
args_copy = copy.deepcopy(args)
|
||||
args_copy.update(item)
|
||||
out.append(get_pricing_rule_for_item(args_copy))
|
||||
|
||||
out.append(get_serial_no_for_item(args_copy))
|
||||
return out
|
||||
|
||||
def get_serial_no_for_item(args):
|
||||
from erpnext.stock.get_item_details import get_serial_no
|
||||
item_details = frappe._dict({
|
||||
"doctype": args.doctype,
|
||||
"name": args.name,
|
||||
"serial_no": args.serial_no
|
||||
})
|
||||
if args.get("parenttype") in ("Sales Invoice", "Delivery Note"):
|
||||
item_details.serial_no = get_serial_no(args)
|
||||
return item_details
|
||||
|
||||
def get_pricing_rule_for_item(args):
|
||||
if args.get("parenttype") == "Material Request": return {}
|
||||
@ -311,4 +323,4 @@ def set_transaction_type(args):
|
||||
elif args.customer:
|
||||
args.transaction_type = "selling"
|
||||
else:
|
||||
args.transaction_type = "buying"
|
||||
args.transaction_type = "buying"
|
@ -736,7 +736,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
"qty": d.qty,
|
||||
"parenttype": d.parenttype,
|
||||
"parent": d.parent,
|
||||
"pricing_rule": d.pricing_rule
|
||||
"pricing_rule": d.pricing_rule,
|
||||
"warehouse": d.warehouse,
|
||||
"serial_no": d.serial_no
|
||||
});
|
||||
|
||||
// if doctype is Quotation Item / Sales Order Iten then add Margin Type and rate in item_list
|
||||
|
@ -206,11 +206,13 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
|
||||
if(item.item_code && item.warehouse) {
|
||||
return this.frm.call({
|
||||
method: "erpnext.stock.get_item_details.get_bin_details",
|
||||
method: "erpnext.stock.get_item_details.get_bin_details_and_serial_nos",
|
||||
child: item,
|
||||
args: {
|
||||
item_code: item.item_code,
|
||||
warehouse: item.warehouse,
|
||||
qty: item.qty,
|
||||
serial_no:item.serial_no
|
||||
},
|
||||
callback:function(r){
|
||||
if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
|
||||
@ -375,4 +377,4 @@ frappe.ui.form.on(cur_frm.doctype,"project", function(frm) {
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
@ -502,7 +502,7 @@ frappe.ui.form.on('Stock Entry', {
|
||||
'qty' : d.qty
|
||||
};
|
||||
frappe.call({
|
||||
method: "erpnext.stock.doctype.stock_entry.stock_entry.get_serial_no",
|
||||
method: "erpnext.stock.get_item_details.get_serial_no",
|
||||
args: {"args": args},
|
||||
callback: function(r) {
|
||||
if (!r.exe){
|
||||
|
@ -8,7 +8,7 @@ from frappe import _
|
||||
from frappe.utils import cstr, cint, flt, comma_or, getdate, nowdate, formatdate, format_time
|
||||
from erpnext.stock.utils import get_incoming_rate
|
||||
from erpnext.stock.stock_ledger import get_previous_sle, NegativeStockError
|
||||
from erpnext.stock.get_item_details import get_bin_details, get_default_cost_center, get_conversion_factor, process_args, get_serial_nos_by_fifo
|
||||
from erpnext.stock.get_item_details import get_bin_details, get_default_cost_center, get_conversion_factor
|
||||
from erpnext.manufacturing.doctype.bom.bom import validate_bom_no
|
||||
import json
|
||||
|
||||
@ -867,17 +867,4 @@ def get_warehouse_details(args):
|
||||
"basic_rate" : get_incoming_rate(args)
|
||||
}
|
||||
|
||||
return ret
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_serial_no(args):
|
||||
if isinstance(args, basestring):
|
||||
args = json.loads(args)
|
||||
args = frappe._dict(args)
|
||||
|
||||
if args.get('warehouse'):
|
||||
if frappe.get_value('Item', {'item_code': args.item_code}, "has_serial_no") == 1:
|
||||
args = json.dumps({"item_code": args.get('item_code'),"warehouse": args.get('warehouse'),"qty": args.get('qty')})
|
||||
args = process_args(args)
|
||||
serial_no = get_serial_nos_by_fifo(args)
|
||||
return serial_no
|
||||
return ret
|
@ -43,7 +43,7 @@ def get_item_details(args):
|
||||
get_party_item_code(args, item_doc, out)
|
||||
|
||||
if out.get("warehouse"):
|
||||
out.update(get_bin_details(args.item_code, out.warehouse))
|
||||
out.update(get_bin_details_and_serial_nos(args.item_code, out.warehouse, args.qty, args.serial_no))
|
||||
|
||||
if frappe.db.exists("Product Bundle", args.item_code):
|
||||
valuation_rate = 0.0
|
||||
@ -74,8 +74,7 @@ def get_item_details(args):
|
||||
out.update(get_pricing_rule_for_item(args))
|
||||
|
||||
if args.get("doctype") in ("Sales Invoice", "Delivery Note"):
|
||||
if item_doc.has_serial_no == 1 and not args.serial_no:
|
||||
out.serial_no = get_serial_nos_by_fifo(args)
|
||||
out.serial_no = get_serial_no(out)
|
||||
|
||||
if args.transaction_date and item.lead_time_days:
|
||||
out.schedule_date = out.lead_time_date = add_days(args.transaction_date,
|
||||
@ -375,8 +374,21 @@ def get_projected_qty(item_code, warehouse):
|
||||
@frappe.whitelist()
|
||||
def get_bin_details(item_code, warehouse):
|
||||
return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
|
||||
["projected_qty", "actual_qty"], as_dict=True) \
|
||||
or {"projected_qty": 0, "actual_qty": 0}
|
||||
["projected_qty", "actual_qty"], as_dict=True) \
|
||||
or {"projected_qty": 0, "actual_qty": 0}
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_serial_no_details(item_code, warehouse, qty, serial_no):
|
||||
args = frappe._dict({"item_code":item_code, "warehouse":warehouse, "qty":qty, "serial_no":serial_no})
|
||||
serial_no = get_serial_no(args)
|
||||
return {'serial_no': serial_no}
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_bin_details_and_serial_nos(item_code, warehouse, qty, serial_no):
|
||||
bin_details_and_serial_nos = {}
|
||||
bin_details_and_serial_nos.update(get_bin_details(item_code, warehouse))
|
||||
bin_details_and_serial_nos.update(get_serial_no_details(item_code, warehouse, qty, serial_no))
|
||||
return bin_details_and_serial_nos
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_batch_qty(batch_no,warehouse,item_code):
|
||||
@ -512,3 +524,17 @@ def get_gross_profit(out):
|
||||
|
||||
return out
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_serial_no(args):
|
||||
if isinstance(args, basestring):
|
||||
args = json.loads(args)
|
||||
args = frappe._dict(args)
|
||||
|
||||
if args.get('warehouse') and args.get('qty') and args.get('item_code'):
|
||||
|
||||
if frappe.get_value('Item', {'item_code': args.item_code}, "has_serial_no") == 1:
|
||||
print "I am in too"
|
||||
args = json.dumps({"item_code": args.get('item_code'),"warehouse": args.get('warehouse'),"qty": args.get('qty')})
|
||||
args = process_args(args)
|
||||
serial_no = get_serial_nos_by_fifo(args)
|
||||
return serial_no
|
||||
|
Loading…
x
Reference in New Issue
Block a user