fix(delivery): update package total on validate (#16131)
This commit is contained in:
parent
5472fff027
commit
f43433b43d
@ -579,3 +579,4 @@ erpnext.patches.v10_0.update_user_image_in_employee
|
|||||||
erpnext.patches.v11_0.update_delivery_trip_status
|
erpnext.patches.v11_0.update_delivery_trip_status
|
||||||
erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items
|
erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items
|
||||||
erpnext.patches.v11_0.set_missing_gst_hsn_code
|
erpnext.patches.v11_0.set_missing_gst_hsn_code
|
||||||
|
erpnext.patches.v11_0.update_package_total_in_delivery_trips
|
7
erpnext/patches/v11_0/update_package_total_in_delivery_trips.py
Executable file
7
erpnext/patches/v11_0/update_package_total_in_delivery_trips.py
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
for trip in frappe.get_all("Delivery Trip", {"docstatus" : 1}):
|
||||||
|
trip_doc = frappe.get_doc("Delivery Trip", trip.name)
|
||||||
|
total = sum([stop.grand_total for stop in trip_doc.delivery_stops if stop.grand_total])
|
||||||
|
frappe.db.set_value("Delivery Trip", trip.name, "package_total", total, update_modified=False)
|
@ -25,6 +25,8 @@ class DeliveryTrip(Document):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_stop_addresses()
|
self.validate_stop_addresses()
|
||||||
|
self.update_status()
|
||||||
|
self.update_package_total()
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.update_status()
|
self.update_status()
|
||||||
@ -37,11 +39,6 @@ class DeliveryTrip(Document):
|
|||||||
self.update_status()
|
self.update_status()
|
||||||
self.update_delivery_notes(delete=True)
|
self.update_delivery_notes(delete=True)
|
||||||
|
|
||||||
def validate_stop_addresses(self):
|
|
||||||
for stop in self.delivery_stops:
|
|
||||||
if not stop.customer_address:
|
|
||||||
stop.customer_address = get_address_display(frappe.get_doc("Address", stop.address).as_dict())
|
|
||||||
|
|
||||||
def update_status(self):
|
def update_status(self):
|
||||||
status = {
|
status = {
|
||||||
0: "Draft",
|
0: "Draft",
|
||||||
@ -58,6 +55,14 @@ class DeliveryTrip(Document):
|
|||||||
|
|
||||||
self.db_set("status", status)
|
self.db_set("status", status)
|
||||||
|
|
||||||
|
def update_package_total(self):
|
||||||
|
self.package_total = sum([stop.grand_total for stop in self.delivery_stops if stop.grand_total])
|
||||||
|
|
||||||
|
def validate_stop_addresses(self):
|
||||||
|
for stop in self.delivery_stops:
|
||||||
|
if not stop.customer_address:
|
||||||
|
stop.customer_address = get_address_display(frappe.get_doc("Address", stop.address).as_dict())
|
||||||
|
|
||||||
def update_delivery_notes(self, delete=False):
|
def update_delivery_notes(self, delete=False):
|
||||||
"""
|
"""
|
||||||
Update all connected Delivery Notes with Delivery Trip details
|
Update all connected Delivery Notes with Delivery Trip details
|
||||||
|
Loading…
x
Reference in New Issue
Block a user