Dear All,
We have new requirement to add in Total Purchase Order field respective to every Project.
May I know if anyone had done the custom script for Total Purchase order (via Purchase Order) field in Project Doctype.
Thank you
Regards
Charnack
- add the new field total_po_cost to project doctype via customize form
- add the following python script for both Submit and Cancel events of doctype Purchase Order.
projects = {po_item.project for po_item in doc.items}
for project in projects:
po_cost = frappe.get_list('Purchase Order',
fields = 'sum(grand_total)',
filters = {'project': project, 'docstatus': 1},
as_list = 1)[0][0]
frappe.db.set_value('Project',project, 'total_po_cost', po_cost or 0)
2 Likes
Thanks for your prompt reply. I will try it out.
Thankss.
Hi Szufisher,
I try to understand on this line.
projects = {po_item.project for po_item in doc.items}
Fieldname po_item is new added field to project doctype?
Sorry I couldnot find any of the po_item field in project by default.
Thank you
this line is python list comprehension which returns a set of unique project number.
Do I have to modified the code?
Question No 2:
2. add the following python script for both Submit and Cancel events of doctype Purchase Order
May I know how can I perform this step?
I had add in custom script as per yours, but the total PO does not show the total.
Thank you so much. its work.
@szufisher how can I use this script to show the count of purchase orders raised over a given period?