How to set standard selling price to an item through python?

This is my code. But it is not setting standard selling price. I have given a default item group:

      def on_submit(doc, event):
    	for prem in range(len(doc.policy_premium)):
    		plans = [doc.policy_premium[prem].plan_1, doc.policy_premium[prem].plan_2, doc.policy_premium[prem].plan_3, doc.policy_premium[prem].plan_4]
    		for index in range(4):
    					INSERT INTO `tabItem` (name, item_name, item_code, standard_rate)
    						(%(name)s, %(item_name)s, %(item_code)s, %(standard_rate)s);
    					name = f"{} - {doc.policy_premium[prem].maximum_trip_duration} Days - Plan {index+1}",
    					item_name = f"{} - {doc.policy_premium[prem].maximum_trip_duration} Days - Plan {index+1}",
    					item_code = f"{} - {doc.policy_premium[prem].maximum_trip_duration} Days - Plan {index+1}",
    					standard_rate = plans[index]

I believe the standard_rate field for Item doctype is just used to added the standard price when the item is created through hooks. If you’re adding the item directly to the database this hook won’t get executed.

If you want to set the standard rate after the item is created you should set it in the Item Price doctype.

@dj12djdjs is correct. Selling prices are stored in the DocType named “Item Price”.

There is no “standard” Selling Price for an Item. Instead, you create 1 (or more) records in “Item Price”. When you create documents like Sales Order lines, ERPNext will choose the Selling Price based on values in “Item Price” such as Item Code, Price List, Unit of Measure, Customer, Date Range, etc.

Than how to access Item Price and Link that to Item through Python?

Go to Item Price doctype and the structure you will see is pretty simple.

Here’s a quick bit of Python to create a new 'Item Price' for these conditions:

  • Item’s name = ‘Foo’
  • Unit of Measure = ‘Each’
  • Selling price = 1.23
new_price = frappe.new_doc("Item Price")
new_price.item_code = 'Foo'
new_price.uom = 'Each'
new_price.selling = True
new_price.price_list = 'Standard Selling'
new_price.price_list_rate = 1.23

Thanks a lot…