My goal is to fetch the data from a custom field in the item profile whenever that item is added to the quotation.
I created the custom fields in both doctypes. In the item doctype the field is a data type field. In the quotation item doctype it is a read only type field. Under options I wrote item.nombre_de_venta.
I’m having the same issue with the supplier product number. I’d like the supplier product number to appear in the purchase invoice. Do I pull it from item_code, item_supplier, supplier? None of these are working for me.
The format is not working for this particular situation.
I have tried
cur_frm.add_fetch(‘supplier’,‘supplier_part_no’,‘supplier_part_number’) , which generates an error message and
cur_frm.add_fetch(‘item_supplier’,‘supplier_part_no’,‘supplier_part_number’), but this also does not work.
Because the Item Supplier doctype allows for a list of suppliers and supplier part numbers, I think Next does not know which supplier part number to select. Somehow I need to tell Next that it needs to select the supplier part number that belongs to the supplier selected for the purchase.
I added another script line with add_fetch after the first one and a very similar operational error message
while testing the automatic filled on selection of Item_code
Traceback (innermost last):
File “/home/frappe/press/benches/1511060614/apps/frappe/frappe/app.py”, line 67, in application
response = frappe.handler.handle()
File “/home/frappe/press/benches/1511060614/apps/frappe/frappe/handler.py”, line 75, in handle
File “/home/frappe/press/benches/1511060614/apps/frappe/frappe/handler.py”, line 109, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/frappe/press/benches/1511060614/apps/frappe/frappe/init.py”, line 777, in call
return fn(*args, **newargs)
File “/home/frappe/press/benches/1511060614/apps/frappe/frappe/desk/form/utils.py”, line 56, in validate_link
% (fetch, options, ‘%s’), (value,))]
File “/home/frappe/press/benches/1511060614/apps/frappe/frappe/database.py”, line 135, in sql
File “/home/frappe/press/benches/1511060614/env/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/press/benches/1511060614/env/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue OperationalError: (1054, “Unknown column ‘supplier_name’ in ‘field list’”)
What did i do wrong ?
Here are my two lines :
cur_frm.add_fetch(“item_code”, “item_name”, “item_name”); // [this one works fine]
cur_frm.add_fetch(“item_code”, “supplier_name”, “supplier_name”); //[adding this one generate error]
@Manu, Unknown column means too that Column dont exists, when do you add_fetch in a link docfield, frappe will look for the the table linked in the field, in this case Item and except if you have added in the Item a field named supplier_name it dont exists by default!
Ok, so, if i understand properly, that means i can’t use the same “linked field” to retrieve other data (like supplier_name, item_description , etc…) for my child table using an add_fetch line?
If that’s the case, how can i have multiple fields automatically updated based only a selected “linked field” then ?
@Manu, I never say it! What I say is! You can use any number of add_fetch statement in your code, since the lookup field already exists in the linked doctype
When do you add a add_fetch in item_code, item_code makes a reference for a field in the Item (assuming that item_code is linked with Item DocType), your universe of possibilities for fields to fetch, is determined by the linked DocType, in this case the doctype Item, if you take a look into the Item DocType, you will see that:
In the Supplier Details section, the field that make a reference to the supplier is named default_supplier, and dont have another field explicitely named supplier_name