Map details from Delivery Trip back to Delivery Note (#15261)
* Map details from Delivery Trip back to Delivery Note * Add pop-up to indicate changed Delivery Notes
This commit is contained in:
parent
f2fe0b2194
commit
4b290e5561
@ -2790,12 +2790,12 @@
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"allow_on_submit": 1,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "transporter",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@ -2806,11 +2806,12 @@
|
||||
"label": "Transporter ID",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Driver",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -2822,7 +2823,7 @@
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"allow_on_submit": 1,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
@ -2844,7 +2845,7 @@
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"print_width": "150px",
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -2857,7 +2858,7 @@
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"allow_on_submit": 1,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
@ -2878,7 +2879,7 @@
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -2890,7 +2891,7 @@
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"allow_on_submit": 1,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
@ -2910,7 +2911,7 @@
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -2954,12 +2955,12 @@
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"allow_on_submit": 1,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "vehicle_no",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@ -2970,11 +2971,12 @@
|
||||
"label": "Vehicle No",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Vehicle",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -2986,7 +2988,7 @@
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"allow_on_submit": 1,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
@ -3007,7 +3009,7 @@
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -3019,13 +3021,13 @@
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"allow_on_submit": 1,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "",
|
||||
"fieldname": "lr_no",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@ -3038,11 +3040,12 @@
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "lr_no",
|
||||
"oldfieldtype": "Data",
|
||||
"options": "Delivery Trip",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"print_width": "100px",
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -3055,7 +3058,7 @@
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"allow_on_submit": 1,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
@ -3079,7 +3082,7 @@
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"print_width": "100px",
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -4165,7 +4168,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2018-08-21 14:44:46.764951",
|
||||
"modified": "2018-08-29 04:03:32.749794",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Delivery Note",
|
||||
|
@ -428,7 +428,7 @@
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
@ -608,7 +608,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-08-29 14:44:36.993178",
|
||||
"modified": "2018-08-30 02:31:49.400138",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Delivery Trip",
|
||||
@ -661,6 +661,5 @@
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 0,
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
"track_seen": 0
|
||||
}
|
@ -3,16 +3,49 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils.user import get_user_fullname
|
||||
from frappe.utils import getdate, cstr, get_datetime
|
||||
from frappe.contacts.doctype.address.address import get_address_display
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import cstr, get_datetime, getdate, get_link_to_form
|
||||
from frappe.utils.user import get_user_fullname
|
||||
|
||||
|
||||
class DeliveryTrip(Document):
|
||||
pass
|
||||
def on_submit(self):
|
||||
self.update_delivery_notes()
|
||||
|
||||
def on_cancel(self):
|
||||
self.update_delivery_notes(delete=True)
|
||||
|
||||
def update_delivery_notes(self, delete=False):
|
||||
delivery_notes = list(set([stop.delivery_note for stop in self.delivery_stops if stop.delivery_note]))
|
||||
|
||||
update_fields = {
|
||||
"transporter": self.driver,
|
||||
"transporter_name": self.driver_name,
|
||||
"transport_mode": "Road",
|
||||
"vehicle_no": self.vehicle,
|
||||
"vehicle_type": "Regular",
|
||||
"lr_no": self.name,
|
||||
"lr_date": self.date
|
||||
}
|
||||
|
||||
for delivery_note in delivery_notes:
|
||||
note_doc = frappe.get_doc("Delivery Note", delivery_note)
|
||||
|
||||
for field, value in update_fields.items():
|
||||
value = None if delete else value
|
||||
setattr(note_doc, field, value)
|
||||
|
||||
note_doc.save()
|
||||
|
||||
delivery_notes = [get_link_to_form("Delivery Note", note) for note in delivery_notes]
|
||||
frappe.msgprint(_("Delivery Notes {0} updated".format(", ".join(delivery_notes))))
|
||||
|
||||
|
||||
|
||||
def get_default_contact(out, name):
|
||||
@ -191,4 +224,4 @@ def round_timedelta(td, period):
|
||||
def format_address(address):
|
||||
"""Customer Address format """
|
||||
address = frappe.get_doc('Address', address)
|
||||
return '{}, {}, {}, {}'.format(address.address_line1, address.city, address.pincode, address.country)
|
||||
return '{}, {}, {}, {}'.format(address.address_line1, address.city, address.pincode, address.country)
|
||||
|
Loading…
Reference in New Issue
Block a user