mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 15:09:20 +00:00
refactor: validate SO and SI references
(cherry picked from commit 4d090bd3b8)
# Conflicts:
# erpnext/stock/doctype/delivery_note/delivery_note.py
This commit is contained in:
@@ -130,6 +130,7 @@ class DeliveryNote(SellingController):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_posting_time()
|
self.validate_posting_time()
|
||||||
super(DeliveryNote, self).validate()
|
super(DeliveryNote, self).validate()
|
||||||
|
self.validate_references()
|
||||||
self.set_status()
|
self.set_status()
|
||||||
self.so_required()
|
self.so_required()
|
||||||
self.validate_proj_cust()
|
self.validate_proj_cust()
|
||||||
@@ -195,6 +196,91 @@ class DeliveryNote(SellingController):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
def set_serial_and_batch_bundle_from_pick_list(self):
|
||||||
|
from erpnext.stock.serial_batch_bundle import SerialBatchCreation
|
||||||
|
|
||||||
|
if not self.pick_list:
|
||||||
|
return
|
||||||
|
|
||||||
|
for item in self.items:
|
||||||
|
if item.pick_list_item and not item.serial_and_batch_bundle:
|
||||||
|
filters = {
|
||||||
|
"item_code": item.item_code,
|
||||||
|
"voucher_type": "Pick List",
|
||||||
|
"voucher_no": self.pick_list,
|
||||||
|
"voucher_detail_no": item.pick_list_item,
|
||||||
|
}
|
||||||
|
|
||||||
|
bundle_id = frappe.db.get_value("Serial and Batch Bundle", filters, "name")
|
||||||
|
|
||||||
|
if bundle_id:
|
||||||
|
cls_obj = SerialBatchCreation(
|
||||||
|
{
|
||||||
|
"type_of_transaction": "Outward",
|
||||||
|
"serial_and_batch_bundle": bundle_id,
|
||||||
|
"item_code": item.get("item_code"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
cls_obj.duplicate_package()
|
||||||
|
|
||||||
|
item.serial_and_batch_bundle = cls_obj.serial_and_batch_bundle
|
||||||
|
|
||||||
|
def validate_references(self):
|
||||||
|
self.validate_sales_order_references()
|
||||||
|
self.validate_sales_invoice_references()
|
||||||
|
|
||||||
|
def validate_sales_order_references(self):
|
||||||
|
err_msg = ""
|
||||||
|
for item in self.items:
|
||||||
|
if (item.against_sales_order and not item.so_detail) or (
|
||||||
|
not item.against_sales_order and item.so_detail
|
||||||
|
):
|
||||||
|
if not item.against_sales_order:
|
||||||
|
err_msg += (
|
||||||
|
_("'Sales Order' reference ({1}) is missing in row {0}").format(
|
||||||
|
frappe.bold(item.idx), frappe.bold("against_sales_order")
|
||||||
|
)
|
||||||
|
+ "<br>"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
err_msg += (
|
||||||
|
_("'Sales Order Item' reference ({1}) is missing in row {0}").format(
|
||||||
|
frappe.bold(item.idx), frappe.bold("so_detail")
|
||||||
|
)
|
||||||
|
+ "<br>"
|
||||||
|
)
|
||||||
|
|
||||||
|
if err_msg:
|
||||||
|
frappe.throw(err_msg, title=_("References to Sales Orders are Incomplete"))
|
||||||
|
|
||||||
|
def validate_sales_invoice_references(self):
|
||||||
|
err_msg = ""
|
||||||
|
for item in self.items:
|
||||||
|
if (item.against_sales_invoice and not item.si_detail) or (
|
||||||
|
not item.against_sales_invoice and item.si_detail
|
||||||
|
):
|
||||||
|
if not item.against_sales_invoice:
|
||||||
|
err_msg += (
|
||||||
|
_("'Sales Invoice' reference ({1}) is missing in row {0}").format(
|
||||||
|
frappe.bold(item.idx), frappe.bold("against_sales_invoice")
|
||||||
|
)
|
||||||
|
+ "<br>"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
err_msg += (
|
||||||
|
_("'Sales Invoice Item' reference ({1}) is missing in row {0}").format(
|
||||||
|
frappe.bold(item.idx), frappe.bold("si_detail")
|
||||||
|
)
|
||||||
|
+ "<br>"
|
||||||
|
)
|
||||||
|
|
||||||
|
if err_msg:
|
||||||
|
frappe.throw(err_msg, title=_("References to Sales Invoices are Incomplete"))
|
||||||
|
|
||||||
|
>>>>>>> 4d090bd3b8 (refactor: validate SO and SI references)
|
||||||
def validate_proj_cust(self):
|
def validate_proj_cust(self):
|
||||||
"""check for does customer belong to same project as entered.."""
|
"""check for does customer belong to same project as entered.."""
|
||||||
if self.project and self.customer:
|
if self.project and self.customer:
|
||||||
|
|||||||
Reference in New Issue
Block a user