mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 06:59:20 +00:00
Add rejected serial nos in Purchase Receipt if auto-created based on series
This commit is contained in:
@@ -426,6 +426,7 @@
|
|||||||
"fieldname": "rejected_serial_no",
|
"fieldname": "rejected_serial_no",
|
||||||
"fieldtype": "Text",
|
"fieldtype": "Text",
|
||||||
"label": "Rejected Serial No",
|
"label": "Rejected Serial No",
|
||||||
|
"no_copy": 1,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 0
|
"read_only": 0
|
||||||
@@ -508,6 +509,7 @@
|
|||||||
"label": "Landed Cost Voucher Amount",
|
"label": "Landed Cost Voucher Amount",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -555,7 +557,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2014-08-08 13:15:06.362562",
|
"modified": "2014-08-11 12:48:13.509109",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Purchase Receipt Item",
|
"name": "Purchase Receipt Item",
|
||||||
|
|||||||
@@ -295,19 +295,30 @@ def make_serial_no(serial_no, sle):
|
|||||||
return sr.name
|
return sr.name
|
||||||
|
|
||||||
def update_serial_nos_after_submit(controller, parentfield):
|
def update_serial_nos_after_submit(controller, parentfield):
|
||||||
stock_ledger_entries = frappe.db.sql("""select voucher_detail_no, serial_no
|
stock_ledger_entries = frappe.db.sql("""select voucher_detail_no, serial_no, actual_qty, warehouse
|
||||||
from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""",
|
from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""",
|
||||||
(controller.doctype, controller.name), as_dict=True)
|
(controller.doctype, controller.name), as_dict=True)
|
||||||
|
|
||||||
if not stock_ledger_entries: return
|
if not stock_ledger_entries: return
|
||||||
|
|
||||||
for d in controller.get(parentfield):
|
for d in controller.get(parentfield):
|
||||||
serial_no = None
|
update_rejected_serial_nos = True if (controller.doctype=="Purchase Receipt" and d.rejected_qty) else False
|
||||||
|
accepted_serial_nos_updated = False
|
||||||
|
warehouse = d.t_warehouse if controller.doctype == "Stock Entry" else d.warehouse
|
||||||
|
|
||||||
for sle in stock_ledger_entries:
|
for sle in stock_ledger_entries:
|
||||||
if sle.voucher_detail_no==d.name:
|
if sle.voucher_detail_no==d.name:
|
||||||
serial_no = sle.serial_no
|
if not accepted_serial_nos_updated and d.qty and abs(sle.actual_qty)==d.qty \
|
||||||
break
|
and sle.warehouse == warehouse and sle.serial_no != d.serial_no:
|
||||||
|
d.serial_no = sle.serial_no
|
||||||
if d.serial_no != serial_no:
|
frappe.db.set_value(d.doctype, d.name, "serial_no", sle.serial_no)
|
||||||
d.serial_no = serial_no
|
accepted_serial_nos_updated = True
|
||||||
frappe.db.set_value(d.doctype, d.name, "serial_no", serial_no)
|
if not update_rejected_serial_nos:
|
||||||
|
break
|
||||||
|
elif update_rejected_serial_nos and abs(sle.actual_qty)==d.rejected_qty \
|
||||||
|
and sle.warehouse == d.rejected_warehouse and sle.serial_no != d.rejected_serial_no:
|
||||||
|
d.rejected_serial_no = sle.serial_no
|
||||||
|
frappe.db.set_value(d.doctype, d.name, "rejected_serial_no", sle.serial_no)
|
||||||
|
update_rejected_serial_nos = False
|
||||||
|
if accepted_serial_nos_updated:
|
||||||
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user