this is my code but when I executed the function it doesn't work
the below code that I executed but doesn't work with me I want some one to help me I'm using odoo16
def button_landed_cost(self):
# Assuming you have the necessary data (purchase name, vendor, etc.)
purchase_name = self.name
vendor_id = self.partner_id.id
# Create an entry in the account.move model
account_move = self.env['account.move'].create({
'partner_id': vendor_id,
'ref': purchase_name,
# Add other relevant fields...
})
if account_move:
print(f"Account move created successfully with ID: {account_move.id}")
else:
print("Failed to create account move")
return True
It should create an accounting move which you can see under accounting entries if you remove filters.
To create a bill, you need to set the move type to Vendor Bill
Example:
account_move = self.env['account.move'].create({
'partner_id': vendor_id,
'ref': purchase_name,
'move_type': 'in_invoice',
# Add other relevant fields...
})