Merge pull request #30579 from nextchamp-saqib/eway-bill-dialog-fix

fix: fetch from fields not working in eway bill dialog
This commit is contained in:
Saqib Ansari 2022-04-05 15:51:38 +05:30 committed by GitHub
commit 7757790572
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,6 +105,30 @@ erpnext.setup_einvoice_actions = (doctype) => {
},
primary_action_label: __('Submit')
});
d.fields_dict.transporter.df.onchange = function () {
const transporter = d.fields_dict.transporter.value;
if (transporter) {
frappe.db.get_value('Supplier', transporter, ['gst_transporter_id', 'supplier_name'])
.then(({ message }) => {
d.set_value('gst_transporter_id', message.gst_transporter_id);
d.set_value('transporter_name', message.supplier_name);
});
} else {
d.set_value('gst_transporter_id', '');
d.set_value('transporter_name', '');
}
};
d.fields_dict.driver.df.onchange = function () {
const driver = d.fields_dict.driver.value;
if (driver) {
frappe.db.get_value('Driver', driver, ['full_name'])
.then(({ message }) => {
d.set_value('driver_name', message.full_name);
});
} else {
d.set_value('driver_name', '');
}
};
d.show();
};
@ -153,7 +177,6 @@ const get_ewaybill_fields = (frm) => {
'fieldname': 'gst_transporter_id',
'label': 'GST Transporter ID',
'fieldtype': 'Data',
'fetch_from': 'transporter.gst_transporter_id',
'default': frm.doc.gst_transporter_id
},
{
@ -189,9 +212,9 @@ const get_ewaybill_fields = (frm) => {
'fieldname': 'transporter_name',
'label': 'Transporter Name',
'fieldtype': 'Data',
'fetch_from': 'transporter.name',
'read_only': 1,
'default': frm.doc.transporter_name
'default': frm.doc.transporter_name,
'depends_on': 'transporter'
},
{
'fieldname': 'mode_of_transport',
@ -206,7 +229,8 @@ const get_ewaybill_fields = (frm) => {
'fieldtype': 'Data',
'fetch_from': 'driver.full_name',
'read_only': 1,
'default': frm.doc.driver_name
'default': frm.doc.driver_name,
'depends_on': 'driver'
},
{
'fieldname': 'lr_date',