[Fix] Fetch Serial No by default for Delivery Note Item
This commit is contained in:
@@ -11,6 +11,7 @@ from frappe import throw, _
|
|||||||
from frappe.utils import flt, cint
|
from frappe.utils import flt, cint
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
class MultiplePricingRuleConflict(frappe.ValidationError): pass
|
class MultiplePricingRuleConflict(frappe.ValidationError): pass
|
||||||
|
|
||||||
class PricingRule(Document):
|
class PricingRule(Document):
|
||||||
@@ -113,9 +114,20 @@ def apply_pricing_rule(args):
|
|||||||
args_copy = copy.deepcopy(args)
|
args_copy = copy.deepcopy(args)
|
||||||
args_copy.update(item)
|
args_copy.update(item)
|
||||||
out.append(get_pricing_rule_for_item(args_copy))
|
out.append(get_pricing_rule_for_item(args_copy))
|
||||||
|
out.append(get_serial_no_for_item(args_copy))
|
||||||
return out
|
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):
|
def get_pricing_rule_for_item(args):
|
||||||
if args.get("parenttype") == "Material Request": return {}
|
if args.get("parenttype") == "Material Request": return {}
|
||||||
|
|
||||||
|
|||||||
@@ -736,7 +736,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
"qty": d.qty,
|
"qty": d.qty,
|
||||||
"parenttype": d.parenttype,
|
"parenttype": d.parenttype,
|
||||||
"parent": d.parent,
|
"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
|
// 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) {
|
if(item.item_code && item.warehouse) {
|
||||||
return this.frm.call({
|
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,
|
child: item,
|
||||||
args: {
|
args: {
|
||||||
item_code: item.item_code,
|
item_code: item.item_code,
|
||||||
warehouse: item.warehouse,
|
warehouse: item.warehouse,
|
||||||
|
qty: item.qty,
|
||||||
|
serial_no:item.serial_no
|
||||||
},
|
},
|
||||||
callback:function(r){
|
callback:function(r){
|
||||||
if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
|
if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
|
||||||
|
|||||||
@@ -502,7 +502,7 @@ frappe.ui.form.on('Stock Entry', {
|
|||||||
'qty' : d.qty
|
'qty' : d.qty
|
||||||
};
|
};
|
||||||
frappe.call({
|
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},
|
args: {"args": args},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if (!r.exe){
|
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 frappe.utils import cstr, cint, flt, comma_or, getdate, nowdate, formatdate, format_time
|
||||||
from erpnext.stock.utils import get_incoming_rate
|
from erpnext.stock.utils import get_incoming_rate
|
||||||
from erpnext.stock.stock_ledger import get_previous_sle, NegativeStockError
|
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
|
from erpnext.manufacturing.doctype.bom.bom import validate_bom_no
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@@ -868,16 +868,3 @@ def get_warehouse_details(args):
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
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
|
|
||||||
@@ -43,7 +43,7 @@ def get_item_details(args):
|
|||||||
get_party_item_code(args, item_doc, out)
|
get_party_item_code(args, item_doc, out)
|
||||||
|
|
||||||
if out.get("warehouse"):
|
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):
|
if frappe.db.exists("Product Bundle", args.item_code):
|
||||||
valuation_rate = 0.0
|
valuation_rate = 0.0
|
||||||
@@ -74,8 +74,7 @@ def get_item_details(args):
|
|||||||
out.update(get_pricing_rule_for_item(args))
|
out.update(get_pricing_rule_for_item(args))
|
||||||
|
|
||||||
if args.get("doctype") in ("Sales Invoice", "Delivery Note"):
|
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_no(out)
|
||||||
out.serial_no = get_serial_nos_by_fifo(args)
|
|
||||||
|
|
||||||
if args.transaction_date and item.lead_time_days:
|
if args.transaction_date and item.lead_time_days:
|
||||||
out.schedule_date = out.lead_time_date = add_days(args.transaction_date,
|
out.schedule_date = out.lead_time_date = add_days(args.transaction_date,
|
||||||
@@ -378,6 +377,19 @@ def get_bin_details(item_code, warehouse):
|
|||||||
["projected_qty", "actual_qty"], as_dict=True) \
|
["projected_qty", "actual_qty"], as_dict=True) \
|
||||||
or {"projected_qty": 0, "actual_qty": 0}
|
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()
|
@frappe.whitelist()
|
||||||
def get_batch_qty(batch_no,warehouse,item_code):
|
def get_batch_qty(batch_no,warehouse,item_code):
|
||||||
actual_batch_qty = get_actual_batch_qty(batch_no,warehouse,item_code)
|
actual_batch_qty = get_actual_batch_qty(batch_no,warehouse,item_code)
|
||||||
@@ -512,3 +524,17 @@ def get_gross_profit(out):
|
|||||||
|
|
||||||
return 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
|
||||||
|
|||||||
Reference in New Issue
Block a user