mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 23:49:19 +00:00
fix: reload global defaults (#19517)
This commit is contained in:
@@ -1,27 +1,28 @@
|
|||||||
# Copyright (c) 2017, Frappe and Contributors
|
# Copyright (c) 2017, Frappe and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.reload_doc('stock', 'doctype', 'delivery_trip')
|
frappe.reload_doc('setup', 'doctype', 'global_defaults', force=True)
|
||||||
frappe.reload_doc('stock', 'doctype', 'delivery_stop', force=True)
|
frappe.reload_doc('stock', 'doctype', 'delivery_trip')
|
||||||
|
frappe.reload_doc('stock', 'doctype', 'delivery_stop', force=True)
|
||||||
for trip in frappe.get_all("Delivery Trip"):
|
|
||||||
trip_doc = frappe.get_doc("Delivery Trip", trip.name)
|
for trip in frappe.get_all("Delivery Trip"):
|
||||||
|
trip_doc = frappe.get_doc("Delivery Trip", trip.name)
|
||||||
status = {
|
|
||||||
0: "Draft",
|
status = {
|
||||||
1: "Scheduled",
|
0: "Draft",
|
||||||
2: "Cancelled"
|
1: "Scheduled",
|
||||||
}[trip_doc.docstatus]
|
2: "Cancelled"
|
||||||
|
}[trip_doc.docstatus]
|
||||||
if trip_doc.docstatus == 1:
|
|
||||||
visited_stops = [stop.visited for stop in trip_doc.delivery_stops]
|
if trip_doc.docstatus == 1:
|
||||||
if all(visited_stops):
|
visited_stops = [stop.visited for stop in trip_doc.delivery_stops]
|
||||||
status = "Completed"
|
if all(visited_stops):
|
||||||
elif any(visited_stops):
|
status = "Completed"
|
||||||
status = "In Transit"
|
elif any(visited_stops):
|
||||||
|
status = "In Transit"
|
||||||
frappe.db.set_value("Delivery Trip", trip.name, "status", status, update_modified=False)
|
|
||||||
|
frappe.db.set_value("Delivery Trip", trip.name, "status", status, update_modified=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user