I have an issue regarding consistency of data. The below have been created:
Reference doctype with multiple fields.
A child table and editable grid doctype has been created with a link field called Reference. I have also added the other fields from the reference doctype as data field, and has fetched the values from that doctype using fetch from.
In the supplier doctype, I have added a table field, and the child doctype has been set as options
When I add a row to the table, and click on new reference, the fields from the reference doctype appears and upon saving, the fields in the table are filled in automatically with the values (same fields are used in child and parent doctype).
However when I edit field from a row in the table directly, the value does not change when saved. And when I modify a field value from the reference screen, the value is saved correctly however in the table, it remains the same. I have to remove and add the reference again for the changes to appear.
Is there a way where I do not have to remove and readd the reference, and that the changes are reflected correctly in the table when modified from the reference screen and vice versa.
Hi @Ayesha , I have selected here Item Tax Template and fetching from a child table of Item Tax Template and it works fine. If this is not working i can suggest a another solution.
My Solution:
item_tax_template: function(frm, cdt, cdn) {
let row = locals[cdt][cdn]
frappe.db.get_doc("Item Tax Template", row.item_tax_template).then((doc) => {
doc.taxes.forEach((line) => {
frappe.model.set_value(cdt, cdn, "tax_rate", line.tax_rate);
frappe.model.set_value(cdt, cdn, "codice_iva", line.codice_iva);
});
frm.refresh_field("default_taxes");
});
}
# `default_taxes` is a child table field name.