Fix 'transporter info' section in Delivery Note (#15565)

- create is_transporter checkbox in supplier doctype
- new field transporter (supplier with is_transporter checked)
- created fields driver and driver_name
- removed GST India fields from core doctype
- removed readonly & allow_on_submit from fields (delivery trip applicable only for in-house delivery)
- read_only transporter_name field (kept for backwards compatibility)
- made necessary changes in delivery_trip implementation
- hidden section's fields from print (preserving v10 convention)
- added transporter field to 'Driver' doctype
- added queries for transporter and driver fields
- GST India fields in regional module
- Fix e-waybill report
This commit is contained in:
Sagar Vora 2018-10-10 14:51:26 +05:30 committed by Nabin Hait
parent dd87e0f1e2
commit d92f3ac480
10 changed files with 6225 additions and 6115 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,4 +2,13 @@
// For license information, please see license.txt
frappe.ui.form.on('Driver', {
setup: function(frm) {
frm.set_query('transporter', function(){
return {
filters: {
'is_transporter': 1
}
};
});
}
});

File diff suppressed because it is too large Load Diff

View File

@ -568,5 +568,6 @@ erpnext.patches.v11_0.remove_land_unit_icon
erpnext.patches.v11_0.add_default_dispatch_notification_template
erpnext.patches.v11_0.add_market_segments
erpnext.patches.v11_0.add_sales_stages
erpnext.patches.v11_0.ewaybill_fields_gst_india
erpnext.patches.v11_0.drop_column_max_days_allowed
erpnext.patches.v11_0.change_healthcare_desktop_icons

View File

@ -0,0 +1,9 @@
import frappe
from erpnext.regional.india.setup import make_custom_fields
def execute():
company = frappe.get_all('Company', filters = {'country': 'India'})
if not company:
return
make_custom_fields()

View File

@ -164,6 +164,43 @@ def make_custom_fields(update=True):
fieldtype='Check', insert_after='disabled', print_hide=1)
]
ewaybill_fields = [
{
'fieldname': 'distance',
'label': 'Distance (in km)',
'fieldtype': 'Float',
'insert_after': 'vehicle_no',
'print_hide': 1
},
{
'fieldname': 'gst_transporter_id',
'label': 'GST Transporter ID',
'fieldtype': 'Data',
'insert_after': 'transporter_name',
'fetch_from': 'transporter.gst_transporter_id',
'print_hide': 1
},
{
'fieldname': 'mode_of_transport',
'label': 'Mode of Transport',
'fieldtype': 'Select',
'options': '\nRoad\nAir\nRail\nShip',
'default': 'Road',
'insert_after': 'lr_date',
'print_hide': 1
},
{
'fieldname': 'gst_vehicle_type',
'label': 'GST Vehicle Type',
'fieldtype': 'Select',
'options': '\nRegular\nOver Dimensional Cargo (ODC)',
'default': 'Regular',
'depends_on': 'eval:(doc.mode_of_transport === "Road")',
'insert_after': 'mode_of_transport',
'print_hide': 1
}
]
custom_fields = {
'Address': [
dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data',
@ -175,7 +212,7 @@ def make_custom_fields(update=True):
],
'Purchase Invoice': invoice_gst_fields + purchase_invoice_gst_fields,
'Sales Invoice': invoice_gst_fields + sales_invoice_gst_fields,
'Delivery Note': sales_invoice_gst_fields,
'Delivery Note': sales_invoice_gst_fields + ewaybill_fields,
'Sales Taxes and Charges Template': inter_state_gst_field,
'Purchase Taxes and Charges Template': inter_state_gst_field,
'Item': [
@ -240,6 +277,15 @@ def make_custom_fields(update=True):
fieldtype='Currency', insert_after='monthly_house_rent', read_only=1),
dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption',
fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1)
],
'Supplier': [
{
'fieldname': 'gst_transporter_id',
'label': 'GST Transporter ID',
'fieldtype': 'Data',
'insert_after': 'supplier_type',
'depends_on': 'eval:doc.is_transporter'
}
]
}

View File

@ -21,7 +21,7 @@ def get_data(filters):
data = frappe.db.sql("""
SELECT
dn.name as dn_id, dn.posting_date, dn.company, dn.company_gstin, dn.customer, dn.customer_gstin, dni.item_code, dni.item_name, dni.description, dni.gst_hsn_code, dni.uom, dni.qty, dni.amount, dn.transport_mode, dn.distance, dn.transporter_name, dn.transporter, dn.lr_no, dn.lr_date, dn.vehicle_no, dn.vehicle_type, dn.company_address, dn.shipping_address_name
dn.name as dn_id, dn.posting_date, dn.company, dn.company_gstin, dn.customer, dn.customer_gstin, dni.item_code, dni.item_name, dni.description, dni.gst_hsn_code, dni.uom, dni.qty, dni.amount, dn.mode_of_transport, dn.distance, dn.transporter_name, dn.gst_transporter_id, dn.lr_no, dn.lr_date, dn.vehicle_no, dn.gst_vehicle_type, dn.company_address, dn.shipping_address_name
FROM
`tabDelivery Note` AS dn join `tabDelivery Note Item` AS dni on (dni.parent = dn.name)
WHERE
@ -52,6 +52,9 @@ def get_data(filters):
row.posting_date = '/'.join(str(row.posting_date).replace("-", "/").split('/')[::-1])
row.lr_date = '/'.join(str(row.lr_date).replace("-", "/").split('/')[::-1])
if row.gst_vehicle_type == 'Over Dimensional Cargo (ODC)':
row.gst_vehicle_type = 'ODC'
row.item_name = re.sub(special_characters, " ", row.item_name)
row.description = row.item_name
@ -333,8 +336,8 @@ def get_columns():
"width": 100
},
{
"fieldname": "transport_mode",
"label": _("Transport Mode"),
"fieldname": "mode_of_transport",
"label": _("Mode of Transport"),
"fieldtype": "Data",
"width": 100
},
@ -351,20 +354,20 @@ def get_columns():
"width": 120
},
{
"fieldname": "transporter_id",
"fieldname": "gst_transporter_id",
"label": _("Transporter ID"),
"fieldtype": "Data",
"width": 100
},
{
"fieldname": "lr_no",
"label": _("Transporter Doc No"),
"label": _("Transport Receipt No"),
"fieldtype": "Data",
"width": 120
},
{
"fieldname": "lr_date",
"label": _("Transporter Date"),
"label": _("Transport Receipt Date"),
"fieldtype": "Data",
"width": 120
},
@ -375,7 +378,7 @@ def get_columns():
"width": 100
},
{
"fieldname": "vehicle_type",
"fieldname": "gst_vehicle_type",
"label": _("Vehicle Type"),
"fieldtype": "Data",
"width": 100

View File

@ -32,9 +32,19 @@ frappe.ui.form.on("Delivery Note", {
}
})
frm.set_query('transporter_name', function(doc) {
frm.set_query('transporter', function() {
return {
filters: { 'supplier_group': "transporter" }
filters: {
'is_transporter': 1
}
}
});
frm.set_query('driver', function(doc) {
return {
filters: {
'transporter': doc.transporter
}
}
});

File diff suppressed because it is too large Load Diff

View File

@ -24,11 +24,9 @@ class DeliveryTrip(Document):
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",
"driver": self.driver,
"driver_name": self.driver_name,
"vehicle_no": self.vehicle,
"vehicle_type": "Regular",
"lr_no": self.name,
"lr_date": self.date
}
@ -40,6 +38,7 @@ class DeliveryTrip(Document):
value = None if delete else value
setattr(note_doc, field, value)
note_doc.flags.ignore_validate_update_after_submit = True
note_doc.save()
delivery_notes = [get_link_to_form("Delivery Note", note) for note in delivery_notes]