So I’m building a simpler form for making stock issues and stock transfers
My stock item balance before transacting
Heres the error
- You can see I have enough stock in my warehouse but the Stock Entry error says I have 0
- This only happens when I try to submit from the code
- It works just fine when I draft from code and submit manually
Heres my code
def make_stock_entry_transfer(self):
#convert stock_in items to stock_entry items
items = []
for item in self.items:
if item.price == 0:
frappe.throw("{0} unit value can not be 0".format(item.item))
items.append({
"item_code": item.item,
"item_name": item.item_name,
"qty": item.qty,
"transfer_qty": item.qty,
#"actual_qty": item.warehouse_balance,
"conversion_factor": item.conversion_factor,
"s_warehouse": self.transacting_warehouse,
"t_warehouse": self.receiving_wh,
"uom": item.unit,
"stock_uom": item.stock_uom,
"basic_rate": item.price,
#"valuation_rate": item.price,
"basic_amount": item.line_value,
"expense_account": "5119 - Stock Adjustment - EF" #get
})
se = frappe.get_doc({
"company": "Example Firm", #doc.company,
"doctype": "Stock Entry",
"stock_entry_type": "Material Transfer",
"items": items,
"naming_series": "MAT-STE-.YYYY.-",
"set_posting_time": 1,
"posting_date": self.t_date,
"posting_time": self.t_date,
"from_warehouse": self.transacting_warehouse,
"to_warehouse": self.receiving_wh,
"remarks": self.remarks,
"docstatus": 1
})
inserted = se.insert()
#inserted.submit()
self.db_set("stock_entry_reference", inserted.name)
self.notify_update()
Any ideas?