Need Py equivalent script for this js

Hi ,

Could anyone tell me the py equivalent for this js script ?

cur_frm.add_fetch('production_order','production_item','item_code');

Thanks

check the frappe.db.get_value() method

1 Like

Hi @makarand_b. Many thanks for reply . Tried but not working .Please could you guide me

Thanks

can you share your code ?

Many thanks for the reply @makarand_b

frappe.db.get_value("Production order", self.production_order, "qty")

using frappe.db.get_value you will get the qty, then you can assign this qty to any other document.

qty = frappe.db.get_value("Production order", self.production_order, "qty")

e.g doc.qty = qty

1 Like

Many thanks for swift response @makarand_b .

This code gives me this error . Please help

Traceback (most recent call last):
  File "/home/ommi/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
    response = frappe.handler.handle()
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 36, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/__init__.py", line 876, in call
    return fn(*args, **newargs)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/client.py", line 36, in get_value
    filters = json.loads(filters)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer

Thanks