Hi,
We’re trying to make a new module of a “Stock Request” for we needed it for our system. We tried to copy the “Material Request” Doctype and “Material Request Item” and made the doctypes “Stock Request” and “Stock Request Item”. But we’re encountering some problems like, when the Item Code was searched on the “Stock Request” module, the “Item Name” wont automatically appear and the “Description” too. Hope you get us. Hope you can help us with this problem. Thank you!
Please see attached files for more info:
@kelscey90 add this in onload method of you Stock Request.js
frm.add_fetch("item_code", "description", "description");
frm.add_fetch("item_code", "item_name", "item_name");
Hi,
Sorry for the stupid question for I don’t know much about technologies. Is there anyway you can show me how to go to this so called “Onload Method” I can’t seem to find it.
@kelscey90, it can be a Custom Script
if are you not following the app development, or in the your_app/your_module/doctype/stock_request/stock_request.js
if are you following the app development.
to add a onload method in a Custom Script
use
frappe.ui.form.on("DocType", "onload", function(frm, cdt, cdn){
})
@kelscey90, just a tip: Material Request
cover Stock Request
1 Like
@max_morais_dmm, I followed you steps but still Item name and description wont appear?
Please see attached files:
@kelscey90 DocType
is a keyword, related to your doctype
you need replace it by you doctype name!
Ohhh. I didn’t see that. Lol. Thank you so much!!! Very informative and helps us a lot!
Btw. We tried to save it and won’t let us save because of Stock UOM is needed to be indicated. We tried putting “frm.add_fetch(“item_code”, “item_name”, “item_name”);” on the onload method but it gave us a error message.
@kelscey90 share the error message!
Another detail, do you need add one add_fetch
for each field that do you need load from Item
Yes, I am aware of adding “add_fetch” for each field. Sorry for I’ve sended the wrong script. Here’s the script I encoded for the uom problem (“item_code”, “uom”, “uom”)
Please see attached files:
@kelscey90, nothing about “Ctrl+C” + “Ctrl+V” in the error description? cause a image that cut most important part of the error, means nothing!
Sorry here’s the error message:
Traceback (innermost last):
File “/home/frappe/press/benches/1604201352/apps/frappe/frappe/app.py”, line 57, in application
response = frappe.handler.handle()
File “/home/frappe/press/benches/1604201352/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/frappe/press/benches/1604201352/apps/frappe/frappe/handler.py”, line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/frappe/press/benches/1604201352/apps/frappe/frappe/init.py”, line 806, in call
return fn(*args, **newargs)
File “/home/frappe/press/benches/1604201352/apps/frappe/frappe/desk/form/utils.py”, line 44, in validate_link
% (fetch, frappe.db.escape(options), ‘%s’), (value,))[0]]
File “/home/frappe/press/benches/1604201352/apps/frappe/frappe/database.py”, line 136, in sql
self._cursor.execute(query, values)
File “/home/frappe/press/benches/1604201352/env/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/press/benches/1604201352/env/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1054, “Unknown column ‘uom’ in ‘field list’”)
In Item
dont exists a field named uom
, check the doctype fields, to ensure the right name!
Here’s the field Stock Uom for our Stock Request module. I wrote the correct name but it can’t detect it.