commit 894d6a86f7371fe608f717e3c9ae9aa053ccc1cd Author: LORENZO\pacio Date: Thu Oct 23 18:10:47 2025 +0200 . diff --git a/test.py b/test.py new file mode 100644 index 0000000..b5a4edb --- /dev/null +++ b/test.py @@ -0,0 +1,64 @@ +import xmlrpc.client, datetime + +url = "http://docker1.polo:8069/" +db = "PoloInformatico" +username = "busti@poloinformatico.it" +password = "p0l01nf." + +common = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/common") +uid = common.authenticate(db, username, password, {}) +models = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/object") + +# 1) Create a project +project_id = models.execute_kw(db, uid, password, 'project.project', 'create', [{ + 'name': 'test_api', +}]) + +# helper to ensure a stage exists and is linked to this project +def ensure_stage(name, seq, fold=False): + sid = models.execute_kw(db, uid, password, 'project.task.type', 'search', [[ + ('name', '=', name), + '|', ('project_ids', '=', False), ('project_ids', 'in', [project_id]), + ]], {'limit': 1}) + if sid: + models.execute_kw(db, uid, password, 'project.task.type', 'write', [sid, { + 'sequence': seq, 'fold': fold, 'project_ids': [(4, project_id)] + }]) + return sid[0] + return models.execute_kw(db, uid, password, 'project.task.type', 'create', [{ + 'name': name, 'sequence': seq, 'fold': fold, 'project_ids': [(4, project_id)] + }]) + +# 2) Create stages (columns) and order columns via their 'sequence' +todo_id = ensure_stage('DOCUMENTI', 10) +doing_id = ensure_stage('DA FARE', 20) +done_id = ensure_stage('COMPLETATO', 90) # folded column + +# 3) Create tasks and position them: choose stage via 'stage_id' and order via 'sequence' +task1 = models.execute_kw(db, uid, password, 'project.task', 'create', [{ + 'name': 'DOCUMENTI', + 'project_id': project_id, + 'stage_id': todo_id, + 'sequence': 1, # lower = higher in the column +}]) + +task2 = models.execute_kw(db, uid, password, 'project.task', 'create', [{ + 'name': 'COMPUTO METRICO', + 'project_id': project_id, + 'stage_id': todo_id, + 'sequence': 2, # lower = higher in the column +}]) + +task3 = models.execute_kw(db, uid, password, 'project.task', 'create', [{ + 'name': 'attività 1 da fare', + 'project_id': project_id, + 'stage_id': doing_id, + 'sequence': 20, +}]) + +# move task2 to "In Progress" and place it just below task1 +ref_seq = models.execute_kw(db, uid, password, 'project.task', 'read', [[task1], ['sequence']])[0]['sequence'] +models.execute_kw(db, uid, password, 'project.task', 'write', [[task2], { + 'stage_id': doing_id, + 'sequence': ref_seq + 1 +}])