Update the doctype value by creating the object

I want to do something like this…

si = frappe.get_doc(“Sales Invoice”,sale_invoice.name)
si.update({“update_stock”:1 })
if si.sales_account == ‘’:
cmp_abbr_by_name = frappe.db.sql(“”“SELECT abbr FROM tabCompany WHERE name = %s”“”,si.company, as_dict = 1)
abbr = cmp_abbr_by_name[0].abbr
for item in si.items:
item.update({“warehouse”:"Finished Goods - " + abbr})

Can you please give some more details of the purpose of the code and what is the problem you are facing?

You can directly set the docfields as si.update_stock = 1

yes… but it’s not working…