I'm using Nodejs (odoo-xmlrpc lib)to integrate with Odoo.
the customer record has been created and attached correctly to the invoice but when trying to attach a company record as well it is returning an error as described below.
example of code.
const params = [];
params.push({
partner_id:1,
company_id:9,
ref:`order_${order.id}`,
payment_state:'paid',
invoice_line_ids: lineEntries,
move_type:'out_invoice'});
// Create the Invoice
const invoiceId = await this.run('account.move','create',params);
this code returns the following error:
faultString: 'Record does not exist or has been deleted.\n' +
'(Record: res.company(9,), User: 2)'
but when checking the Odoo dashboard I can see the company is created with ID 9 successfully.
Update: 24 Jan 2023
According to the answer by @S.M Firoz Ahmed
I changed the company creation model from (res.partner with option {is_company:true}) to (res.company). the company and assigned to a journal after creating it by the following code
params = { 'name': 'My Journal', 'code': 'MJ', 'company_id': 1 }
const journal_id = models.execute_kw('account.journal', 'create', [params])
and then assigned the company_id and journal_id to the invoice
const invoiceParams ={
partner_id:customer.id,
journal_id:2,company_id:1,
ref:`order_123`,
payment_state:'paid',
invoice_line_ids:lineEntries,
move_type:'out_invoice'
}
invoice_id = models.execute_kw('account.move', 'create', [params])
but nothing new, the same error returned