From ca944316b464e0ca02ce5f1391d6acb159a627ff Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 4 Nov 2020 18:50:15 +0530 Subject: [PATCH] fix: show/hide eway bill fields --- erpnext/patches.txt | 2 +- erpnext/patches/v12_0/setup_einvoice_fields.py | 10 +++++++++- erpnext/regional/india/setup.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 67dc8e38e95..d08a9283a08 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -678,4 +678,4 @@ erpnext.patches.v12_0.update_state_code_for_daman_and_diu erpnext.patches.v12_0.rename_lost_reason_detail erpnext.patches.v12_0.update_leave_application_status erpnext.patches.v12_0.update_payment_entry_status -erpnext.patches.v12_0.setup_einvoice_fields +erpnext.patches.v12_0.setup_einvoice_fields #2020-11-04 diff --git a/erpnext/patches/v12_0/setup_einvoice_fields.py b/erpnext/patches/v12_0/setup_einvoice_fields.py index fbb313a9fe1..9d7cfc52eb4 100644 --- a/erpnext/patches/v12_0/setup_einvoice_fields.py +++ b/erpnext/patches/v12_0/setup_einvoice_fields.py @@ -29,4 +29,12 @@ def execute(): } create_custom_fields(custom_fields, update=True) add_permissions() - add_print_formats() \ No newline at end of file + add_print_formats() + + frappe.db.set_value('Custom Field', { 'fieldname': 'mode_of_transport' }, 'default', '') + frappe.db.set_value('Custom Field', { 'fieldname': 'distance' }, 'mandatory_depends_on', 'transporter') + frappe.db.set_value('Custom Field', { 'fieldname': 'vehicle_no' }, 'mandatory_depends_on', 'eval:doc.mode_of_transport == "Road"') + frappe.db.set_value('Custom Field', { 'fieldname': 'vehicle_no' }, 'depends_on', 'depends_on': 'eval:doc.mode_of_transport == "Road"') + frappe.db.set_value('Custom Field', { 'fieldname': 'gst_vehicle_type' }, 'mandatory_depends_on', 'eval:doc.mode_of_transport == "Road"') + frappe.db.set_value('Custom Field', { 'fieldname': 'lr_date' }, 'mandatory_depends_on', 'eval:in_list(["Air", "Ship", "Rail"], doc.mode_of_transport)') + frappe.db.set_value('Custom Field', { 'fieldname': 'lr_no' }, 'mandatory_depends_on', 'eval:in_list(["Air", "Ship", "Rail"], doc.mode_of_transport)') \ No newline at end of file diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py index 4f1ca5012d1..bb0d2ff8013 100644 --- a/erpnext/regional/india/setup.py +++ b/erpnext/regional/india/setup.py @@ -303,6 +303,7 @@ def make_custom_fields(update=True): 'label': 'Vehicle No', 'fieldtype': 'Data', 'insert_after': 'lr_no', + 'depends_on': 'eval:(doc.mode_of_transport === "Road")', 'print_hide': 1, 'translatable': 0 }, @@ -333,7 +334,6 @@ def make_custom_fields(update=True): 'label': 'Mode of Transport', 'fieldtype': 'Select', 'options': '\nRoad\nAir\nRail\nShip', - 'default': 'Road', 'insert_after': 'transporter_name', 'print_hide': 1, 'translatable': 0