I try to read data from the calendar but I don't know how to add a new event in odoo calendar. Here is my code of how to list event of odoo:
var inParams = []; inParams.push ([]); // where conditions inParams.push ([ 'name']); // fields inParams.push (0); //offset inParams.push (5); // limit var params = []; params.push (inParams); odoo.execute_kw ('calendar.event', 'search_read', params, function (err, value) { if (err) {return console.log (err); } console.log (value); odooResult + = JSON.stringify (value);
Do you know how to add a new event (Create: Meetings)?
I try like this, but is not working
function AddEventInOdoo (agent) { return new Promise ((resolve, reject) => { odoo4.connect ((err) => { if (err) return console.log ('AddEventInOdoo error' + err); console.log ('AddEventInOdoo connected'); var inParams = []; // inParams.push ([]); inParams.push ([{'id': 45, 'name': 'Easy', 'state': 'draft', 'display_start': '2019-12-19 07:30:00', 'start': ' 2019-12-19 07:30:00 ',' stop ':' 2019-12-18 08:30:00 ',' allday ':' false ',' start + date ':' 2019-12-19 07 : 30: 00 ',' start_datetime ':' 2019-12-19 07:30:00 ',' stop_datetime ':' 2019-12-19 08:30:00 ',' event_tz ':' Etc / GMT + 1 ',' duration ': 1.0,' privacy ':' public '}]); var params = []; params.push (inParams); odoo4.execute_kw ('calendar.event', 'create', params, function (err, value) { if (err) { return console.log (err) } if (value) { console.log ('Value is added'); return resolve (JSON.stringify (value)) } }); }); console.log ('AddEventInOdoo odoo connected'); }) .then ((value) => { var test = JSON.parse (value); var list = test.length; console.log ('test is' + test [0] .name + 'or is' + list); agent.add ('event added'); console.log ('odoo event added'); }). catch ((err) => { agent.add (`😔`); console.log ('Catch error' + err); }); }
I got this error: File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20191115-py3.7.egg/odoo/sql_db.py", line 240, in execute res = self._obj.execute ( query, params) psycopg2.extensions.TransactionRollbackError: could not serialize access due to concurrent update
and