Try ERPNext Buy Support Partners Foundation

Custom Script - Purchase Order Did Not save

hello

I am adding row in child table through Custom Script Code it is working fine but after add it is not going to save…
i am getting this console error
amount: could not find docfield in method precision()
number_format.js:193:11
price_list_rate: could not find docfield in method precision()
number_format.js:193:11
base_price_list_rate: could not find docfield in method precision()
number_format.js:193:11
rate: could not find docfield in method precision()
number_format.js:193:11
base_rate: could not find docfield in method precision()
number_format.js:193:11
amount: could not find docfield in method precision()
number_format.js:193:11
base_amount: could not find docfield in method precision()
number_format.js:193:11
net_rate: could not find docfield in method precision()
number_format.js:193:11
base_net_rate: could not find docfield in method precision()
number_format.js:193:11
net_amount: could not find docfield in method precision()
number_format.js:193:11
base_net_amount: could not find docfield in method precision()
number_format.js:193:11
amount: could not find docfield in method precision()
number_format.js:193:11
price_list_rate: could not find docfield in method precision()
number_format.js:193:11
base_price_list_rate: could not find docfield in method precision()
number_format.js:193:11
rate: could not find docfield in method precision()
number_format.js:193:11
base_rate: could not find docfield in method precision()
number_format.js:193:11
amount: could not find docfield in method precision()
number_format.js:193:11
base_amount: could not find docfield in method precision()
number_format.js:193:11
net_rate: could not find docfield in method precision()
number_format.js:193:11
base_net_rate: could not find docfield in method precision()
number_format.js:193:11
net_amount: could not find docfield in method precision()
number_format.js:193:11
base_net_amount: could not find docfield in method precision()
number_format.js:193:11
amount: could not find docfield in method precision()
number_format.js:193:11
price_list_rate: could not find docfield in method precision()
number_format.js:193:11
base_price_list_rate: could not find docfield in method precision()
number_format.js:193:11
rate: could not find docfield in method precision()
number_format.js:193:11
base_rate: could not find docfield in method precision()
number_format.js:193:11
amount: could not find docfield in method precision()
number_format.js:193:11
base_amount: could not find docfield in method precision()
number_format.js:193:11
net_rate: could not find docfield in method precision()
number_format.js:193:11
base_net_rate: could not find docfield in method precision()
number_format.js:193:11
net_amount: could not find docfield in method precision()
number_format.js:193:11
base_net_amount: could not find docfield in method precision()
number_format.js:193:11
amount: could not find docfield in method precision()
number_format.js:193:11
price_list_rate: could not find docfield in method precision()
number_format.js:193:11
base_price_list_rate: could not find docfield in method precision()
number_format.js:193:11
rate: could not find docfield in method precision()
number_format.js:193:11
base_rate: could not find docfield in method precision()
number_format.js:193:11
amount: could not find docfield in method precision()
number_format.js:193:11
base_amount: could not find docfield in method precision()
number_format.js:193:11
net_rate: could not find docfield in method precision()
number_format.js:193:11
base_net_rate: could not find docfield in method precision()
number_format.js:193:11
net_amount: could not find docfield in method precision()
number_format.js:193:11
base_net_amount: could not find docfield in method precision()
number_format.js:193:11
amount: could not find docfield in method precision()
number_format.js:193:11
price_list_rate: could not find docfield in method precision()
number_format.js:193:11
base_price_list_rate: could not find docfield in method precision()
number_format.js:193:11
rate: could not find docfield in method precision()
number_format.js:193:11
base_rate: could not find docfield in method precision()
number_format.js:193:11
amount: could not find docfield in method precision()
number_format.js:193:11
base_amount: could not find docfield in method precision()
number_format.js:193:11
net_rate: could not find docfield in method precision()
number_format.js:193:11
base_net_rate: could not find docfield in method precision()
number_format.js:193:11
net_amount: could not find docfield in method precision()
number_format.js:193:11
base_net_amount: could not find docfield in method precision()

please suggest me what i have to do …

Could you share your custom script code?

var d = frappe.model.add_child(cur_frm.doc, “Purchase Order”, “items”);
frappe.model.set_value( d.last_purchase_rate =0);
frappe.model.set_value( d.base_price_list_rate =0);
frappe.model.set_value( d.qty =qty);
frappe.model.set_value( d.rate =rate);
frappe.model.set_value( d.total_weight =0);
frappe.model.set_value( d.received_qty =0);
frappe.model.set_value( d.received_qty =0);
frappe.model.set_value( d.stock_uom =uom);
frappe.model.set_value( d.base_net_rate =uom);
frappe.model.set_value( d.base_net_rate =uom);
frappe.model.set_value( d.conversion_factor =1);
frappe.model.set_value( d.stock_qty =qty1);
frappe.model.set_value( d.warehouse =warehouse);
frappe.model.set_value( d.billed_amt =0);
frappe.model.set_value( d.uom =uom);
frappe.model.set_value( d.description =item_code);
frappe.model.set_value( d.returned_qty =0);
frappe.model.set_value( d.base_rate =rate);
frappe.model.set_value( d.item_code =item_code);
frappe.model.set_value( d.billed_amt =0);
frappe.model.set_value( d.base_amount =0);
frappe.model.set_value( d.item_name =item);
frappe.model.set_value( d.docname =“Purchase Order”);
var amount=qty
rate;

		frappe.model.set_value( d.amount =amount);
		frappe.model.set_value( d.price_list_rate =0);
		frappe.model.set_value( d.base_price_list_rate =0);
                    refresh_field("items");

first i was adding only item_code and qty then i was getting error so i tried to add all field

Can you try this:

var child = frappe.model.add_child(“items”); // add new row to child table "items"
frappe.model.set_value(child.doctype, child.name, 'last_purchase_rate', 0);  // set field "purchase_rate" of child to value 0
frappe.model.set_value(child.doctype, child.name, 'item_code', item_code);

Maybe try setting the item code first, there might be some integrated fetch functions that trigger which can conflict with setting other fields.

Hope this helps.

Thank You so much Sir This Code is Working Fine …

var child = cur_frm.add_child(“items”);
frappe.model.set_value(child.doctype, child.name, “item_code”, item_code)
frappe.model.set_value(child.doctype, child.name, “qty”, qty)
cur_frm.refresh_field(“items”)

Thanks

You are welcome :wink:

1 Like

hi @lasalesi i have tried your code values are also set in the child table but i could not save the record…it throws mandatory fields required but i have filled the required mandatory fields and in my console shows following error

amount: could not find docfield in method precision()
price_list_rate: could not find docfield in method precision()
base_price_list_rate: could not find docfield in method precision()
could not find docfield in method precision()
base_rate: could not find docfield in method precision()
amount: could not find docfield in method precision()
base_amount: could not find docfield in method precision()
net_rate: could not find docfield in method precision()
base_net_rate: could not find docfield in method precision()
net_amount: could not find docfield in method precision()
base_net_amount: could not find docfield in method precision()
amount: could not find docfield in method precision()
price_list_rate: could not find docfield in method precision()
base_price_list_rate: could not find docfield in method precision()
could not find docfield in method precision()
base_rate: could not find docfield in method precision()
amount: could not find docfield in method precision()
base_amount: could not find docfield in method precision()
net_rate: could not find docfield in method precision()
base_net_rate: could not find docfield in method precision()
net_amount: could not find docfield in method precision()
base_net_amount: could not find docfield in method precision()
amount: could not find docfield in method precision()
price_list_rate: could not find docfield in method precision()
base_price_list_rate: could not find docfield in method precision()
rate: could not find docfield in method precision()
base_rate: could not find docfield in method precision()
amount: could not find docfield in method precision()
base_amount: could not find docfield in method precision()
net_rate: could not find docfield in method precision()
base_net_rate: could not find docfield in method precision()
net_amount: could not find docfield in method precision()
base_net_amount: could not find docfield in method precision()
amount: could not find docfield in method precision()
price_list_rate: could not find docfield in method precision()
base_price_list_rate: could not find docfield in method precision()
rate: could not find docfield in method precision()
base_rate: could not find docfield in method precision()
amount: could not find docfield in method precision()
base_amount: could not find docfield in method precision()
net_rate: could not find docfield in method precision()
base_net_rate: could not find docfield in method precision()
net_amount: could not find docfield in method precision()
base_net_amount: could not find docfield in method precision()

can you share your code.

Hi @nikhil1, Thanks for your response. I didn’t add refresh field after adding cur_frm.refresh_field(“items”); working fine now :+1:

1 Like