I want to make a Stock Entry (type:Material Issue) to modify stock, but I do not want to make a General Ledger and Stock Ledger’s valuation equals 0. Since valuation of Stock Entry Detail was calculated automatically, so GL will be always made, and SL’s valuation is not 0.
Here’s my code
stock_entry = frappe.new_doc("Stock Entry")
stock_entry.purpose = 'Material Issue'
stock_entry.company = settings.business.COMPANY_NAME
stock_entry.purchase_order = doc.name
stock_entry.items = []
stock_entry.from_warehouse = settings.business.IN_STOCK_WAREHOUSE
stock_entry.difference_account = settings.business.DIFFERENCE_ACCOUNT
for item in doc.items:
if item.item_code in instock_items:
stock_entry_item = frappe.new_doc('Stock Entry Detail')
stock_entry_item.item_code = item.item_code
stock_entry_item.s_warehouse = settings.business.IN_STOCK_WAREHOUSE
stock_entry_item.qty = item.qty
stock_entry_item.expense_account = settings.business.DIFFERENCE_ACCOUNT
stock_entry_item.valuation_rate = 0
stock_entry_item.amount = 0
stock_entry_item.basic_amount = 0
stock_entry_item.basic_rate = 0
stock_entry_item.uom = item.uom
stock_entry_item.conversion_factor = 1
stock_entry_item.cost_center = settings.business.COST_CENTER
stock_entry.items.append(stock_entry_item)
doc_dict = frappe.get_doc(stock_entry.as_dict())
doc_dict.save() <--- after saving, valuation will be changed.
doc_dict.submit()