Skip to Content
Menu
This question has been flagged
1 Reply
1687 Views

Hello all, 

I am creating vendor bill but i got an error that "Record does not exist or has been deleted."
Here is my code:

@api.multi
def action_confirm(self):
account = self.env['account.account'].search([('name', 'ilike', 'Final Settlement')])[0].id
supplier_line = {
'product_id': self.product_id.id,
'name': self.product_id.name,
'quantity': 1,
'account_id': account,
'price_unit': self.total_amount,
}
record_line = {
'partner_id': self.employee_id.id,
'invoice_line_ids': [(0, 0, supplier_line)],
}
record = self.env['account.invoice'].create(record_line)
self.env['account.invoice'].action_invoice_open()
return record
Avatar
Discard
Best Answer

Hello Muhammad,

'partner_id': self.employee_id.id

So partner_id in account.invoice is related to res.partner and you are passing wrong id.

If you have a related user in employee  then you can use self.employee_id.user_id.partner_id.id.

Thanks,

Avatar
Discard
Author

bro first i created partner for that employee:

vals = {

'name': self.employee_id.id,

'email': self.employee_id.work_email,

'street': self.employee_id.address_id.street,

'street2': self.employee_id.address_id.street2,

'city': self.employee_id.address_id.city,

'zip': self.employee_id.address_id.zip,

'country_id': self.employee_id.address_id.country_id.id,

'phone': self.employee_id.work_phone,

'mobile': self.employee_id.mobile_phone,

}

v_partner = self.env['res.partner'].create(vals)

Ok so in partner_id you have to pass v_partner.id