Hi,
I'am trying to read the products from a PHP page using search_read from the XML-RPC connection.
When I try it on the res.partner model with the following code :
$ids = $models->execute_kw(ODOO_DB, $uid, ODOO_SECRET,
'res.partner', 'search_read',
array(array(array('id', '>', 0))),
array('limit'=>10));
printDebug($ids, 'Liste des produits');
the answer is what's expected :
Array
(
[0] => Array
(
[signup_valid] =>
[subscription_count] => 0
[sale_order_count] => 2
[bank_account_count] => 0
[write_uid] => Array
(
[0] => 1
[1] => Olivier DUCROT
)
...
removed
...
[write_date] => 2017-04-06 11:59:57
[date] =>
[lang] => fr_FR
[sale_warn_msg] =>
[activity_summary] =>
[mobile] =>
[partner_share] => 1
[device_identity_ids] => Array
(
)
[category_id] => Array
(
)
)
)
When I try the same code with the product.product model using this code :
$ids = $models->execute_kw(ODOO_DB, $uid, ODOO_SECRET,
'product.product', 'search_read',
array(array(array('id', '>', 0))),
array('limit'=>10));
printDebug($ids, 'Liste des produits');
The answer is an error :
Array
(
[faultCode] => 1
[faultString] => Traceback (most recent call last):
File "/home/odoo/src/odoo/saas-14/odoo/service/wsgi_server.py", line 56, in xmlrpc_return
result = odoo.http.dispatch_rpc(service, method, params)
File "/home/odoo/src/odoo/saas-14/odoo/http.py", line 118, in dispatch_rpc
result = dispatch(method, params)
File "/home/odoo/src/odoo/saas-14/odoo/service/model.py", line 38, in dispatch
res = fn(db, uid, *params)
File "/home/odoo/src/odoo/saas-14/odoo/service/model.py", line 175, in execute_kw
return execute(db, uid, obj, method, *args, **kw or {})
File "/home/odoo/src/odoo/saas-14/odoo/service/model.py", line 119, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/src/odoo/saas-14/odoo/service/model.py", line 182, in execute
res = execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/odoo/src/odoo/saas-14/odoo/service/model.py", line 171, in execute_cr
return odoo.api.call_kw(recs, method, args, kw)
File "/home/odoo/src/odoo/saas-14/odoo/api.py", line 679, in call_kw
return call_kw_model(method, model, args, kwargs)
File "/home/odoo/src/odoo/saas-14/odoo/api.py", line 664, in call_kw_model
result = method(recs, *args, **kwargs)
File "/home/odoo/src/odoo/saas-14/odoo/models.py", line 4659, in search_read
result = records.read(fields)
File "/home/odoo/src/odoo/saas-14/odoo/models.py", line 3033, in read
values[name] = field.convert_to_read(record[name], record, use_name_get)
File "/home/odoo/src/odoo/saas-14/odoo/models.py", line 5174, in __getitem__
return self._fields[key].__get__(self, type(self))
File "/home/odoo/src/odoo/saas-14/odoo/fields.py", line 873, in __get__
self.determine_value(record)
File "/home/odoo/src/odoo/saas-14/odoo/fields.py", line 984, in determine_value
self.compute_value(recs)
File "/home/odoo/src/odoo/saas-14/odoo/fields.py", line 939, in compute_value
self._compute_value(records)
File "/home/odoo/src/odoo/saas-14/odoo/fields.py", line 930, in _compute_value
getattr(records, self.compute)()
File "/home/odoo/src/odoo/saas-14/addons/website_sale/models/product.py", line 193, in _website_price
pricelist = self.env['website'].get_current_website().get_current_pricelist()
File "/home/odoo/src/odoo/saas-14/addons/website/models/website.py", line 396, in get_current_website
domain_name = request.httprequest.environ.get('HTTP_HOST', '').split(':')[0]
File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 338, in __getattr__
return getattr(self._get_current_object(), name)
File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 297, in _get_current_object
return self.__local()
File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 132, in _lookup
raise RuntimeError('object unbound')
RuntimeError: object unbound
)