OCA / odoorpc

Python module to pilot your Odoo servers through JSON-RPC.
http://pythonhosted.org/OdooRPC/
GNU Lesser General Public License v3.0
231 stars 123 forks source link

Expected singleton error on create(vals) where vals is list of dicts fails #56

Open mohamedhagag opened 4 years ago

mohamedhagag commented 4 years ago

create accepts list of dicts and should create multiple records.

when trying so in odoorpc I get this error:

odoorpc/odoo.py in json(self, url, params)
    281         data = self._connector.proxy_json(url, params)
    282         if data.get('error'):
--> 283             raise error.RPCError(
    284                 data['error']['data']['message'],
    285                 data['error'])

RPCError: Error while validating constraint

**Expected singleton**: res.partner(2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, 2826, 2827, 2828, 2829, 2830, 2831, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857, 2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2874, 2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2885, 2886, 2887, 2888, 2889, 2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2898, 2899, 2900, 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912)
None

Code is:

import odoorpc
odoo = odoorpc.ODOO('localhost', port=8012)
odoo.login('test', 'admin', 'admin')
vals = []
for i in range(200100,200199): 
    vals.append({ 
    'name': f'partner {i}', 
    'phone': f'+12345000{i}', 
    }) 

p = odoo.env['res.partner']
p.create(vals)
mohamedhagag commented 4 years ago

This happens with odoo v12 but v13 working as expected !!

sebalix commented 4 years ago

It needs to be fixed yes, this syntax is not yet supported. Thanks for the report!