Skip to Content
Menu
This question has been flagged
1696 Views

Hi, 

I am trying to send a request from PHP to API (Odoo 12) to create a reservation in the reservation module, but it sends me a sql error, although I not sure if the request I am sending is correct, here I leave the php request sample


$idBooking = $obj->execute_kw($db, $uid, $password, 
'hotel.reservation', 'create',
array(
    'partner_id' => 35
    'partner_invoice_id' => 35
    'partner_order_id' => 35
    'partner_shipping_id' => 35
    'checkin' => 10/02/2020 12:00:00
    'checkout' => 28/02/2020 12:00:00
    'warehouse_id' => 1
    'pricelist_id' => 2
    'adults' => 1
    'children' => 0
    'reservation_line' => array( 
                                                array( 
                                                        6,0,array( 
                                                                    'reserve'=>array(6,0,array($infoRoom['id'])), 
                                                                    'name'=>array($infoRoom['name']) 
                                                                    ) 
                                                          ) 
                                                  ) 
);


And this is the error

[faultCode] => 1
[faultString] => Traceback (most recent call last):
File "/odoo/odoo-server/odoo/addons/base/controllers/rpc.py", line 63, in xmlrpc_2
response = self._xmlrpc(service)
File "/odoo/odoo-server/odoo/addons/base/controllers/rpc.py", line 43, in _xmlrpc
result = dispatch_rpc(service, method, params)
File "/odoo/odoo-server/odoo/http.py", line 120, in dispatch_rpc
result = dispatch(method, params)
File "/odoo/odoo-server/odoo/service/model.py", line 39, in dispatch
res = fn(db, uid, *params)
File "/odoo/odoo-server/odoo/service/model.py", line 171, in execute_kw
return execute(db, uid, obj, method, *args, **kw or {})
File "/odoo/odoo-server/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/odoo/odoo-server/odoo/service/model.py", line 178, in execute
res = execute_cr(cr, uid, obj, method, *args, **kw)
File "/odoo/odoo-server/odoo/service/model.py", line 167, in execute_cr
return odoo.api.call_kw(recs, method, args, kw)
File "/odoo/odoo-server/odoo/api.py", line 747, in call_kw
return _call_kw_model_create(method, model, args, kwargs)
File "/odoo/odoo-server/odoo/api.py", line 727, in _call_kw_model_create
result = method(recs, *args, **kwargs)
File "<decorator-gen-331>", line 2, in create
File "/odoo/odoo-server/odoo/api.py", line 430, in _model_create_single
return create(self, arg)
File "/odoo/odoo-server/addons/hotel_reservation/models/hotel_reservation.py", line 308, in create
return super(HotelReservation, self).create(vals)
File "<decorator-gen-118>", line 2, in create
File "/odoo/odoo-server/odoo/api.py", line 451, in _model_create_multi
return create(self, [arg])
File "/odoo/odoo-server/addons/mail/models/mail_thread.py", line 273, in create
threads = super(MailThread, self).create(vals_list)
File "<decorator-gen-3>", line 2, in create
File "/odoo/odoo-server/odoo/api.py", line 452, in _model_create_multi
return create(self, arg)
File "/odoo/odoo-server/odoo/models.py", line 3560, in create
records = self._create(data_list)
File "/odoo/odoo-server/odoo/models.py", line 3684, in _create
for other, data in pycompat.izip(others, data_list)
File "/odoo/odoo-server/odoo/fields.py", line 2476, in create
comodel.browse(act[2]).write({inverse: record.id})
File "/odoo/odoo-server/odoo/models.py", line 3321, in write
self._write(store_vals)
File "/odoo/odoo-server/odoo/models.py", line 3414, in _write
cr.execute(query, params + [sub_ids])
File "/odoo/odoo-server/odoo/sql_db.py", line 148, in wrapper
return f(self, *args, **kwargs)
File "/odoo/odoo-server/odoo/sql_db.py", line 225, in execute
res = self._obj.execute(query, params)
psycopg2.DataError: invalid input syntax for integer: "name"
LINE 1: ...ite_date"=(now() at time zone 'UTC') WHERE id IN ('name', 'r...

Apparently the error come from the node of reservation_line.

I hope someone can help me.

Thanks.

Avatar
Discard