Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
5277 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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,

)

)

);


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 20
7217
4
thg 6 20
3818
1
thg 1 25
4263
1
thg 4 24
1454
0
thg 1 23
5705