mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 03:09:09 +00:00
refactor: validate_dropship_item
This commit is contained in:
@@ -298,8 +298,9 @@ class SalesInvoice(SellingController):
|
|||||||
if cint(self.is_pos):
|
if cint(self.is_pos):
|
||||||
self.validate_pos()
|
self.validate_pos()
|
||||||
|
|
||||||
|
self.validate_dropship_item()
|
||||||
|
|
||||||
if cint(self.update_stock):
|
if cint(self.update_stock):
|
||||||
self.validate_dropship_item()
|
|
||||||
self.validate_warehouse()
|
self.validate_warehouse()
|
||||||
self.update_current_stock()
|
self.update_current_stock()
|
||||||
|
|
||||||
@@ -1026,10 +1027,16 @@ class SalesInvoice(SellingController):
|
|||||||
msgprint(_("Please enter Account for Change Amount"), raise_exception=1)
|
msgprint(_("Please enter Account for Change Amount"), raise_exception=1)
|
||||||
|
|
||||||
def validate_dropship_item(self):
|
def validate_dropship_item(self):
|
||||||
for item in self.items:
|
"""If items are drop shipped, stock cannot be updated."""
|
||||||
if item.sales_order:
|
if not cint(self.update_stock):
|
||||||
if frappe.db.get_value("Sales Order Item", item.so_detail, "delivered_by_supplier"):
|
return
|
||||||
frappe.throw(_("Could not update stock, invoice contains drop shipping item."))
|
|
||||||
|
if any(item.delivered_by_supplier for item in self.items):
|
||||||
|
frappe.throw(
|
||||||
|
_(
|
||||||
|
"Stock cannot be updated because the invoice contains a drop shipping item. Please disable 'Update Stock' or remove the drop shipping item."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
def update_current_stock(self):
|
def update_current_stock(self):
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
|
|||||||
Reference in New Issue
Block a user