How to fill the detail into child table

@ruchin78 Python and JavaScript are case-sensitive languages, so Item is completely different of item

Hi @max_morais_dmm
I have corrected the item to Item in both places now I got this error.

Traceback (innermost last):
File “/home/sam/frappe-bench/apps/frappe/frappe/app.py”, line 57, in application
response = frappe.handler.handle()
File “/home/sam/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/sam/frappe-bench/apps/frappe/frappe/handler.py”, line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/sam/frappe-bench/apps/frappe/frappe/init.py”, line 805, in call
return fn(*args, **newargs)
File “/home/sam/frappe-bench/apps/library_management/library_management/folder_scriptss.py”, line 24, in get_bom_detail
pi = doc.append(‘parent_bom’, {})
File “/home/sam/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 132, in append
value = self._init_child(value, key)
File “/home/sam/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 156, in _init_child
value[“doctype”] = self.get_table_field_doctype(key)
File “/home/sam/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 260, in get_table_field_doctype
return self.meta.get_field(fieldname).options
AttributeError: ‘NoneType’ object has no attribute ‘options’

@ruchin78, question: What this line do? pi = doc.append('parent_bom', {})

@max_morais_dmm
I really don’t know about this. I am a layman in this case.
I appreciate if you can help me.

Edit: Actually the parent_bom is the name of child table.

Regards
Ruchin Sharma

@max_morais_dmm
I changed my code to

@frappe.whitelist()
def get_bom_detail(doc, Item):
    if isinstance(doc, basestring):
        doc = frappe.get_doc(json.loads(doc)) 
	for i in frappe.db.sql("""select parent,bom_no,parent as parent_bom from `tabBOM Item` where item_code=%s and parent is null""", Item, as_dict=1):
		doc.parent = i.parent
		doc.bom_no = i.bom_no
		doc.parent_bom = i.parent_bom

Now, no error is coming but nothing is happening.

Regards
Ruchin Sharma

@max_morais_dmm
My bad that, I really don’t know how to do this therefore I am just trying to do it by looking at some code and try to understand if it helps me.

I am a layman for this, therefore I appreciate if you can help me in the same context.

Regards
Ruchin Sharma

@max_morais_dmm
Thanks for your help. However I am still trying to resolve the problem.
Once I am done with that, I will definitely share my code here.

Regards
Ruchin Sharma

@ruchin78, ping me on gitter https://gitter.im/frappe/erpnext

1 Like

@max_morais_dmm
Thanks a lot for your help and support.
You are a genius and for me you are like a Godfather!
With the help you only, I could do this.
Again many many thanks to you dear.

Regards
Ruchin Sharma