def assign_task(): modelName = "stock.warehouse.logistic.task" if (request.data): data_list = json.loads(request.data) request_dict = data_list['params'] update_id = request_dict['to_update_id'] assign_uid = request_dict['uid'] api_class = Helpers(request_dict['url'], request_dict['db'], int(request_dict['uid']), request_dict['password']) check_access = api_class.check_access_rights(modelName) if (check_access): assigned_user = api_class.api_check_assigned_user( modelName, update_id) print assigned_user if assigned_user and assigned_user['assigned_id'] != False: response = { 'status': 'assigned', 'msg': 'already assigned task' } else: updated_id = api_class.assign_user(modelName, update_id, assign_uid) if updated_id: status_update = api_class.api_workflow_assign( modelName, update_id) print status_update response = { 'status': 'assigned', 'msg': 'you are assigned to this task' } return jsonify(response)
def update_task_flow(): response = {} modelName = "stock.warehouse.logistic.task" if (request.data): data_list = json.loads(request.data) request_dict = data_list['params'] update_id = request_dict['to_update_id'] state = request_dict['update_data'] print update_id api_class = Helpers(request_dict['url'], request_dict['db'], int(request_dict['uid']), request_dict['password']) check_access = api_class.check_access_rights(modelName) if (check_access): if (state == 'confirmed'): updated_id = api_class.api_workflow(modelName, update_id) print("updated id is %s" % updated_id) response = {'status': 'success', 'msg': 'updated Successfully'} if (state == 'assigned'): updated_id = api_class.api_workflow_assign( modelName, update_id) print("updated id is %s" % updated_id) response = {'status': 'success', 'msg': 'updated Successfully'} if (state == 'accepted'): updated_id = api_class.api_workflow_accept( modelName, update_id) print("updated id is %s" % updated_id) response = {'status': 'success', 'msg': 'updated Successfully'} if (state == 'done'): updated_id = api_class.api_workflow_done(modelName, update_id) print("updated id is %s" % updated_id) response = {'status': 'success', 'msg': 'updated Successfully'} if (state == 'cancel'): updated_id = api_class.api_workflow_cancel( modelName, update_id) print("updated id is %s" % updated_id) response = {'status': 'success', 'msg': 'updated Successfully'} if (state == 'rejected'): updated_id = api_class.api_workflow_reject( modelName, update_id) print("updated id is %s" % updated_id) response = {'status': 'success', 'msg': 'updated Successfully'} if (state == 'failed'): updated_id = api_class.api_workflow_fail(modelName, update_id) print("updated id is %s" % updated_id) response = {'status': 'success', 'msg': 'updated Successfully'} if (state == 'draft'): updated_id = api_class.api_workflow_draft(modelName, update_id) print("updated id is %s" % updated_id) response = {'status': 'success', 'msg': 'updated Successfully'} return jsonify(response)