Document creation for an Item on Item creation

Hello,

I have created Lastest Purchase Price doctype there i have kept field like Item Name, Item Code, Updated Date, Rate. My requirement is when I will create new item then there also new Latest Purchase Price document will have to generate with that same Item having Rate. How can i do this ?

Hi @pm23,

Please check the post.

syntax like (Server Script)

def on_update(doc, event):
        # Create a new Latest Purchase Price document
        lpp_doc = frappe.new_doc("Latest Purchase Price")
        lpp_doc.item_name = doc.item_name
        lpp_doc.item_code = doc.item_code
        lpp_doc.updated_date = frappe.utils.now_datetime()
        lpp_doc.rate = doc.rate
        lpp_doc.insert(ignore_permissions=True)

When you save the Item and Latest Purchase Price will be created. So have to add logic as per your scenario and also update the field name and doctype.

Thank You!

Hello @NCP ,

Done.
Thanks