This question has been flagged
2 Replies
3917 Views

Hi everyone,

I need some help as beginner,

I am trying to make an interface in PHP to make an invoice and when I try to make an invoice_line _ids, I get:

<p>Error: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/odoo/service/wsgi_server.py", line 56, in xmlrpc_return
    result = odoo.http.dispatch_rpc(service, method, params)
  File "/usr/lib/python2.7/site-packages/odoo/http.py", line 118, in dispatch_rpc
    result = dispatch(method, params)
  File "/usr/lib/python2.7/site-packages/odoo/service/model.py", line 38, in dispatch
    res = fn(db, uid, *params)
  File "/usr/lib/python2.7/site-packages/odoo/service/model.py", line 175, in execute_kw
    return execute(db, uid, obj, method, *args, **kw or {})
  File "/usr/lib/python2.7/site-packages/odoo/service/model.py", line 161, in wrapper
    raise ValidationError(msg)
ValidationError: ('The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set\n\n[object with reference: Account - account.account]', None)
</p>


This is the piece of the code:

$invoice_line_id = $models->execute_kw($db, $uid, $password,

'account.invoice.line',

'create',

array(

array(

'invoice_id'=>$invoice_id, // Reference to the invoice itself

'name'=>"Product description", // Invoice line description

'product_id'=>34, // Products can be found from product_product

'price_unit' => 5,

'account_id' => "700000",

'quantity'=> 2,

#'Account' => array("code"=>"0","company_id"=>$client[0]['id']),

)

)

);

Does anyone have an idea what I need to put?


Thanks in advance!


Ata

Avatar
Discard
Best Answer

It's look like issue with account_id.

You must pass internal id of account to create invoice line.

Ex:

$invoice_line_id = $models->execute_kw($db, $uid, $password,

'account.invoice.line',

'create',

array(

array(

'invoice_id'=>$invoice_id, // Reference to the invoice itself

'name'=>"Product description", // Invoice line description

'product_id'=>34, // Products can be found from product_product

'price_unit' => 5,

'account_id' => ODOO_ID,

'quantity'=> 2,

)

)

);


Avatar
Discard
Author Best Answer

Thanks a lot for your help,


If anyone needs more information about this ODOO_ID, it starts with 1  and this is used for each account code

Avatar
Discard