refactor: use DocType Fetch From instead of frm.add_fetch

This commit is contained in:
s-aga-r 2023-11-28 17:33:27 +05:30
parent 1763824e5f
commit 01044ca8e9
2 changed files with 16 additions and 14 deletions

View File

@ -8,17 +8,6 @@ frappe.ui.form.on("Warranty Claim", {
frm.set_query('contact_person', erpnext.queries.contact_query); frm.set_query('contact_person', erpnext.queries.contact_query);
frm.set_query('customer_address', erpnext.queries.address_query); frm.set_query('customer_address', erpnext.queries.address_query);
frm.set_query('customer', erpnext.queries.customer); frm.set_query('customer', erpnext.queries.customer);
frm.add_fetch('serial_no', 'item_code', 'item_code');
frm.add_fetch('serial_no', 'item_name', 'item_name');
frm.add_fetch('serial_no', 'description', 'description');
frm.add_fetch('serial_no', 'maintenance_status', 'warranty_amc_status');
frm.add_fetch('serial_no', 'warranty_expiry_date', 'warranty_expiry_date');
frm.add_fetch('serial_no', 'amc_expiry_date', 'amc_expiry_date');
frm.add_fetch('serial_no', 'customer', 'customer');
frm.add_fetch('serial_no', 'customer_name', 'customer_name');
frm.add_fetch('item_code', 'item_name', 'item_name');
frm.add_fetch('item_code', 'description', 'description');
}, },
onload: (frm) => { onload: (frm) => {

View File

@ -92,7 +92,8 @@
"fieldname": "serial_no", "fieldname": "serial_no",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Serial No", "label": "Serial No",
"options": "Serial No" "options": "Serial No",
"search_index": 1
}, },
{ {
"fieldname": "customer", "fieldname": "customer",
@ -128,6 +129,8 @@
"options": "fa fa-ticket" "options": "fa fa-ticket"
}, },
{ {
"fetch_from": "serial_no.item_code",
"fetch_if_empty": 1,
"fieldname": "item_code", "fieldname": "item_code",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1, "in_list_view": 1,
@ -140,6 +143,7 @@
}, },
{ {
"depends_on": "eval:doc.item_code", "depends_on": "eval:doc.item_code",
"fetch_from": "item_code.item_name",
"fieldname": "item_name", "fieldname": "item_name",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Item Name", "label": "Item Name",
@ -149,6 +153,7 @@
}, },
{ {
"depends_on": "eval:doc.item_code", "depends_on": "eval:doc.item_code",
"fetch_from": "item_code.description",
"fieldname": "description", "fieldname": "description",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"label": "Description", "label": "Description",
@ -164,17 +169,24 @@
"width": "50%" "width": "50%"
}, },
{ {
"fetch_from": "serial_no.maintenance_status",
"fetch_if_empty": 1,
"fieldname": "warranty_amc_status", "fieldname": "warranty_amc_status",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Warranty / AMC Status", "label": "Warranty / AMC Status",
"options": "\nUnder Warranty\nOut of Warranty\nUnder AMC\nOut of AMC" "options": "\nUnder Warranty\nOut of Warranty\nUnder AMC\nOut of AMC",
"search_index": 1
}, },
{ {
"fetch_from": "serial_no.warranty_expiry_date",
"fetch_if_empty": 1,
"fieldname": "warranty_expiry_date", "fieldname": "warranty_expiry_date",
"fieldtype": "Date", "fieldtype": "Date",
"label": "Warranty Expiry Date" "label": "Warranty Expiry Date"
}, },
{ {
"fetch_from": "serial_no.amc_expiry_date",
"fetch_if_empty": 1,
"fieldname": "amc_expiry_date", "fieldname": "amc_expiry_date",
"fieldtype": "Date", "fieldtype": "Date",
"label": "AMC Expiry Date" "label": "AMC Expiry Date"
@ -225,6 +237,7 @@
{ {
"bold": 1, "bold": 1,
"depends_on": "customer", "depends_on": "customer",
"fetch_from": "customer.customer_name",
"fieldname": "customer_name", "fieldname": "customer_name",
"fieldtype": "Data", "fieldtype": "Data",
"in_global_search": 1, "in_global_search": 1,
@ -366,7 +379,7 @@
"icon": "fa fa-bug", "icon": "fa fa-bug",
"idx": 1, "idx": 1,
"links": [], "links": [],
"modified": "2023-06-03 16:17:07.694449", "modified": "2023-11-28 17:30:35.676410",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Support", "module": "Support",
"name": "Warranty Claim", "name": "Warranty Claim",