fix: serial and batch bundle company mandatory error (#38994) (cherry picked from commit 10074e9980c8f2a1473827c61c888d970da4b73a) Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
parent
e0755f9a9a
commit
d2580be4fd
@ -1145,15 +1145,16 @@ def add_serial_batch_ledgers(entries, child_row, doc, warehouse) -> object:
|
|||||||
if isinstance(entries, str):
|
if isinstance(entries, str):
|
||||||
entries = parse_json(entries)
|
entries = parse_json(entries)
|
||||||
|
|
||||||
if doc and isinstance(doc, str):
|
parent_doc = doc
|
||||||
parent_doc = parse_json(doc)
|
if parent_doc and isinstance(parent_doc, str):
|
||||||
|
parent_doc = parse_json(parent_doc)
|
||||||
|
|
||||||
if frappe.db.exists("Serial and Batch Bundle", child_row.serial_and_batch_bundle):
|
if frappe.db.exists("Serial and Batch Bundle", child_row.serial_and_batch_bundle):
|
||||||
doc = update_serial_batch_no_ledgers(entries, child_row, parent_doc, warehouse)
|
sb_doc = update_serial_batch_no_ledgers(entries, child_row, parent_doc, warehouse)
|
||||||
else:
|
else:
|
||||||
doc = create_serial_batch_no_ledgers(entries, child_row, parent_doc, warehouse)
|
sb_doc = create_serial_batch_no_ledgers(entries, child_row, parent_doc, warehouse)
|
||||||
|
|
||||||
return doc
|
return sb_doc
|
||||||
|
|
||||||
|
|
||||||
def create_serial_batch_no_ledgers(entries, child_row, parent_doc, warehouse=None) -> object:
|
def create_serial_batch_no_ledgers(entries, child_row, parent_doc, warehouse=None) -> object:
|
||||||
@ -1177,6 +1178,7 @@ def create_serial_batch_no_ledgers(entries, child_row, parent_doc, warehouse=Non
|
|||||||
"type_of_transaction": type_of_transaction,
|
"type_of_transaction": type_of_transaction,
|
||||||
"posting_date": parent_doc.get("posting_date"),
|
"posting_date": parent_doc.get("posting_date"),
|
||||||
"posting_time": parent_doc.get("posting_time"),
|
"posting_time": parent_doc.get("posting_time"),
|
||||||
|
"company": parent_doc.get("company"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,9 @@ from frappe.tests.utils import FrappeTestCase
|
|||||||
from frappe.utils import add_days, add_to_date, flt, nowdate, nowtime, today
|
from frappe.utils import add_days, add_to_date, flt, nowdate, nowtime, today
|
||||||
|
|
||||||
from erpnext.stock.doctype.item.test_item import make_item
|
from erpnext.stock.doctype.item.test_item import make_item
|
||||||
|
from erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle import (
|
||||||
|
add_serial_batch_ledgers,
|
||||||
|
)
|
||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
|
|
||||||
|
|
||||||
@ -420,6 +423,43 @@ class TestSerialandBatchBundle(FrappeTestCase):
|
|||||||
ste.delete()
|
ste.delete()
|
||||||
self.assertFalse(frappe.db.exists("Serial and Batch Bundle", bundle_doc.name))
|
self.assertFalse(frappe.db.exists("Serial and Batch Bundle", bundle_doc.name))
|
||||||
|
|
||||||
|
def test_serial_and_batch_bundle_company(self):
|
||||||
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt
|
||||||
|
|
||||||
|
item = make_item(
|
||||||
|
properties={
|
||||||
|
"has_serial_no": 1,
|
||||||
|
"serial_no_series": "TT-SER-VAL-.#####",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
pr = make_purchase_receipt(
|
||||||
|
item_code=item,
|
||||||
|
warehouse="_Test Warehouse - _TC",
|
||||||
|
qty=3,
|
||||||
|
rate=500,
|
||||||
|
do_not_submit=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
entries = []
|
||||||
|
for serial_no in ["TT-SER-VAL-00001", "TT-SER-VAL-00002", "TT-SER-VAL-00003"]:
|
||||||
|
entries.append(frappe._dict({"serial_no": serial_no, "qty": 1}))
|
||||||
|
|
||||||
|
if not frappe.db.exists("Serial No", serial_no):
|
||||||
|
frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "Serial No",
|
||||||
|
"serial_no": serial_no,
|
||||||
|
"item_code": item,
|
||||||
|
}
|
||||||
|
).insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
item_row = pr.items[0]
|
||||||
|
item_row.type_of_transaction = "Inward"
|
||||||
|
item_row.is_rejected = 0
|
||||||
|
sn_doc = add_serial_batch_ledgers(entries, item_row, pr, "_Test Warehouse - _TC")
|
||||||
|
self.assertEqual(sn_doc.company, "_Test Company")
|
||||||
|
|
||||||
|
|
||||||
def get_batch_from_bundle(bundle):
|
def get_batch_from_bundle(bundle):
|
||||||
from erpnext.stock.serial_batch_bundle import get_batch_nos
|
from erpnext.stock.serial_batch_bundle import get_batch_nos
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user