mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
* fix: serial and batch bundle for POS Invoice (#41491)
(cherry picked from commit e5dfc5e545)
# Conflicts:
# erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.json
* chore: fix conflicts
---------
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -935,6 +935,9 @@ class SerialandBatchBundle(Document):
|
||||
self.validate_voucher_no_docstatus()
|
||||
|
||||
def validate_voucher_no_docstatus(self):
|
||||
if self.voucher_type == "POS Invoice":
|
||||
return
|
||||
|
||||
if frappe.db.get_value(self.voucher_type, self.voucher_no, "docstatus") == 1:
|
||||
msg = f"""The {self.voucher_type} {bold(self.voucher_no)}
|
||||
is in submitted state, please cancel it first"""
|
||||
@@ -1722,6 +1725,7 @@ def get_reserved_batches_for_pos(kwargs) -> dict:
|
||||
"`tabPOS Invoice Item`.warehouse",
|
||||
"`tabPOS Invoice Item`.name as child_docname",
|
||||
"`tabPOS Invoice`.name as parent_docname",
|
||||
"`tabPOS Invoice Item`.use_serial_batch_fields",
|
||||
"`tabPOS Invoice Item`.serial_and_batch_bundle",
|
||||
],
|
||||
filters=[
|
||||
@@ -1735,7 +1739,7 @@ def get_reserved_batches_for_pos(kwargs) -> dict:
|
||||
ids = [
|
||||
pos_invoice.serial_and_batch_bundle
|
||||
for pos_invoice in pos_invoices
|
||||
if pos_invoice.serial_and_batch_bundle
|
||||
if pos_invoice.serial_and_batch_bundle and not pos_invoice.use_serial_batch_fields
|
||||
]
|
||||
|
||||
if ids:
|
||||
|
||||
@@ -246,6 +246,9 @@ class SerialBatchBundle:
|
||||
frappe.throw(_(msg))
|
||||
|
||||
def delink_serial_and_batch_bundle(self):
|
||||
if self.is_pos_transaction():
|
||||
return
|
||||
|
||||
update_values = {
|
||||
"serial_and_batch_bundle": "",
|
||||
}
|
||||
@@ -295,8 +298,22 @@ class SerialBatchBundle:
|
||||
self.cancel_serial_and_batch_bundle()
|
||||
|
||||
def cancel_serial_and_batch_bundle(self):
|
||||
if self.is_pos_transaction():
|
||||
return
|
||||
|
||||
frappe.get_cached_doc("Serial and Batch Bundle", self.sle.serial_and_batch_bundle).cancel()
|
||||
|
||||
def is_pos_transaction(self):
|
||||
if (
|
||||
self.sle.voucher_type == "Sales Invoice"
|
||||
and self.sle.serial_and_batch_bundle
|
||||
and frappe.get_cached_value(
|
||||
"Serial and Batch Bundle", self.sle.serial_and_batch_bundle, "voucher_type"
|
||||
)
|
||||
== "POS Invoice"
|
||||
):
|
||||
return True
|
||||
|
||||
def submit_serial_and_batch_bundle(self):
|
||||
doc = frappe.get_doc("Serial and Batch Bundle", self.sle.serial_and_batch_bundle)
|
||||
self.validate_actual_qty(doc)
|
||||
|
||||
Reference in New Issue
Block a user