I have added a new custom field called (Units of Measurement )in the Quality Inspection Parameter
then >
created the same field,( same name) in Quality Inspection Readings .
Then >
I went to Quality Inspection and created NEW and selected Quality Inspection Template . The custom field from the table does not populate.
Only the already existing fields such as Specification & Acceptance Criteria are being fetched.
I have read the instructions and it says keep the custom field as data which i did
Use in custom_script
add_fetch(link_fieldname, source_fieldname, target_fieldname)
Example:
cur_frm.add_fetch(âcustomerâ,âvat_idâ,âvat_idâ)
thanks for your reply!
can you give me a better example. If my created field name is âUnitâ inside "Quality Inspection Template Parameters and in the Doctype it is saying using Module âStockâ
Do i do it like this
cur_frm.add_fetch(âQuality Inspection Template Parametersâ,âUnitâ,âUnitâ) ?
Like this
Thank you for your help!
another thing, the Quality inspection template is Linked to âQuality Inspection Template parameters " this has the custom fields. then Quality Inspection is linked to Quality Inspection Template Readersâ Readers is linked to Quality Inspection Template.
So what do cur_frm.add_fetch(âcustomerâ,âvat_idâ,âvat_idâ)
Hello @sealcoatings
First of all, why you are saying template? You are confusing us. Template term is used for html and pages.
It is better to use doctype, child doctype, document and child document (the table inside the document). Doctype is the form it self, example: Sales Invoice and Child Doctype is a doctype that can be inserted in another Doctype, example of it is Sales Invoice Items.
Regarding to Document: from each doctype, we will create documents. Example: SINV0001 and SINV0002 and so on.
Coming to your requirement, I will explain it for you as following:
cur_frm.add_fetch(âfield_name_of_type_linkâ, âsource_field_nameâ, âdestination_field_nameâ);
Where:
source_field_name is the name of the field in the doctype that you need to bring from it the data.
destination_field_name is the name of the field in the doctype that you need to place (or set) the data in it.
Regards
Bilal
thanks for the update. Its my first time, its alittle confusing but nearly there.
The field in Doctype is Item Quality Inspection Parameter and the custom field is called Unit.
The Doctype is called Quality Inspection but inside it has a table called Quality Inspection Reading.
The Doctype Qualty Inspection Reading has the same field names Item Quality Inspection Parameter .
So when you goto Doctype Quaility inspection and select the template to populate the table .
So do i goto Custom Script , Select Quality Inspection Doctype
cur_frm.add_fetch(âItem Quality Inspection Parameterâ,âunitâ,âunitâ) ?
Please answer me on the following:
- What is the name of the source doctype and its child doctype that you need to fetch from it?
- What is the name of the destination doctype and its child doctype that u need to set the data in it?
- What custom fields u added and in which doctype?
Regards
Bilal
THe field is called âUnitâ inside "Item Quality Inspection Parameter " which is childdoc to âQuality Inspection Templateâ
THen in Quality Inspection , it has link to Doctype called âQuality Inspection Readingsâ which is table.
Inside Quality Inspection , you can select âQuality Inspection Templateâ to populate âQuality Inspection Readingsâ table.
You can see it in the default ERPNEXT 11
hope this makes sense
thank you so much for you help
THe field is called âUnitâ inside "Item Quality Inspection Parameter " which is childdoc to âQuality Inspection Templateâ
THen in Quality Inspection , it has link to Doctype called âQuality Inspection Readingsâ which is table.
Inside Quality Inspection , you can select âQuality Inspection Templateâ to populate âQuality Inspection Readingsâ table.
You can see it in the default ERPNEXT 11
hope this makes sense
thank you so much for you help
OK, it will not work using cur_frm.add_fetch, you need to use frappe.call and you need to call python method which will return the needed values based on the selected template.
Regards
Bilal
can you give me an example?
thank you!
Hello,
I came across same situation and found your query. I know it is old question, but may help someone. Below changes solved my problem.
Added âuomâ in fields of quality_inspection_template.py
def get_template_details(template):
if not template: return []
return frappe.get_all('Item Quality Inspection Parameter', fields=["specification", "value","uom"],
filters={'parenttype': 'Quality Inspection Template', 'parent': template}, order_by="idx")
Added child.uom = d.uom in quality_inspection.py
def get_item_specification_details(self):
if not self.quality_inspection_template:
self.quality_inspection_template = frappe.db.get_value(âItemâ,
self.item_code, âquality_inspection_templateâ)
if not self.quality_inspection_template: return
self.set('readings', [])
parameters = get_template_details(self.quality_inspection_template)
for d in parameters:
child = self.append('readings', {})
child.specification = d.specification
**child.uom = d.uom** //added this line
child.value = d.value
child.status = "Accepted"
Regards
Sakkeer