Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
1484 Представления

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 

Аватар
Отменить
Лучший ответ

It appears that the error is occurring when you are trying to attach a company record to the invoice. The error message suggests that the record with ID 9 in the "res.company" model does not exist or has been deleted. However, you have confirmed that the company record with ID 9 is present in the Odoo dashboard.

Here are a few things you can check to troubleshoot the issue:

  1. Verify that the "company_id" field is correctly defined as a many2one field in the "account.move" model and that it is correctly linked to the "res.company" model.

  2. Make sure that the user that you are using to create the invoice has the appropriate permissions to access and modify the "res.company" model and the specific record with ID 9.

  3. Confirm that the company record with ID 9 is in the correct state and has not been archived or deleted.

  4. Check that you're passing correct values to all the fields, especially the required fields.

  5. Check that you're passing the correct context.

  6. Make sure that the company_id is present in the create method of account.move

Аватар
Отменить
Автор

Thank you for answering, can you please check my question again since I update it according to your answer

Related Posts Ответы Просмотры Активность
2
сент. 22
3453
1
окт. 24
1097
1
апр. 24
1237
2
мар. 24
1748
2
мая 24
2149