How create `Purchase Invoice` Item from `Item`

Hello everyone!
I try to create Purchase Invoice from backend side. And I need to create Purchase Invoice Item. Maybe exists some function that can convert Item to Purchase Invoice Item?

You have to use the Append method to put/fill the item table from the backend…!

Eg.

doc = frappe.new_doc("Purchase Invoice Item")
doc.append('items', {
      'item_code': 'ABC',
      'item_name': 'XYZ',
      'qty': '10',
}
doc.save()
doc.submit()
frappe.db.commit()

thanks)

doc = frappe.new_doc('Purchase Invoice Item')
doc.append('items', {'item_code': '123', 'item_name': 'hello', 'qty': 3})
AttributeError: 'NoneType' object has no attribute 'options'

All is good. Necessary parameter is doctype:Item inside dict

you have to provide objects that will occupy the values that you’re storing.

like,
A = Samsung
B = Samsung Galaxy S9
C = 10

doc.append('items', {'item_code': A, 'item_name': B, 'qty': C})

and make sure you have to committed the DB using this command frappe.db.commit()