mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 17:04:47 +00:00
Delivery note update after submission
This commit is contained in:
@@ -68,13 +68,14 @@ class DeliveryNote(SellingController):
|
|||||||
self.validate_for_items()
|
self.validate_for_items()
|
||||||
self.validate_warehouse()
|
self.validate_warehouse()
|
||||||
self.validate_uom_is_integer("stock_uom", "qty")
|
self.validate_uom_is_integer("stock_uom", "qty")
|
||||||
self.update_current_stock()
|
|
||||||
self.validate_with_previous_doc()
|
self.validate_with_previous_doc()
|
||||||
|
|
||||||
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
|
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
|
||||||
make_packing_list(self, 'delivery_note_details')
|
make_packing_list(self, 'delivery_note_details')
|
||||||
|
|
||||||
self.status = 'Draft'
|
self.update_current_stock()
|
||||||
|
|
||||||
|
if not self.status: self.status = 'Draft'
|
||||||
if not self.installation_status: self.installation_status = 'Not Installed'
|
if not self.installation_status: self.installation_status = 'Not Installed'
|
||||||
|
|
||||||
def validate_with_previous_doc(self):
|
def validate_with_previous_doc(self):
|
||||||
@@ -133,14 +134,17 @@ class DeliveryNote(SellingController):
|
|||||||
|
|
||||||
|
|
||||||
def update_current_stock(self):
|
def update_current_stock(self):
|
||||||
for d in self.get('delivery_note_details'):
|
if self._action != "update_after_submit":
|
||||||
bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
for d in self.get('delivery_note_details'):
|
||||||
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
d.actual_qty = frappe.db.get_value("Bin", {"item_code": d.item_code,
|
||||||
|
"warehouse": d.warehouse}, "actual_qty")
|
||||||
|
|
||||||
for d in self.get('packing_details'):
|
for d in self.get('packing_details'):
|
||||||
bin = frappe.db.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
bin_qty = frappe.db.get_value("Bin", {"item_code": d.item_code,
|
||||||
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
"warehouse": d.warehouse}, ["actual_qty", "projected_qty"], as_dict=True)
|
||||||
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
|
if bin_qty:
|
||||||
|
d.actual_qty = flt(bin_qty.actual_qty)
|
||||||
|
d.projected_qty = flt(bin_qty.projected_qty)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.validate_packed_qty()
|
self.validate_packed_qty()
|
||||||
|
|||||||
Reference in New Issue
Block a user