Exemplo n.º 1
0
def get_tasks():

    #api_defaults
    modelName = "stock.warehouse.logistic.task"
    fields = ['name',
              'purchase_id',
              'partner_id',
              'type',
              'date_planned',
              'create_uid',
              'state',
              'line_ids']


    if(request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        api_class = Helpers(request_dict['url'],request_dict['db'],int(request_dict['uid']),request_dict['password'])
        check_access = api_class.check_access_rights(modelName)
        checksum = []
        if(check_access):
            get_all_tasks = api_class.api_search_read(modelName,checksum,fields)
            if(get_all_tasks):
                response = get_all_tasks
            else:
                response = {'status': 'error', 'msg': 'No Tasks Found'}
    return jsonify(response)
Exemplo n.º 2
0
def partner_det():
    print "Entered into partner Details"
    modelName1 = "res.partner"
    fields_toget = ['street','street2', 'city', 'state_id', 'country_id', 'name','zip']
    if (request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        user_id = request_dict['uid']
        checksum = [['customer','=',True]]
        # partner_id = request_dict['partner_id']
        api_class = Helpers(request_dict['url'], request_dict['db'], int(request_dict['uid']),
                            request_dict['password'])
        check_access = api_class.check_access_rights(modelName1)
        if (check_access):
            assigned_user = api_class.api_search_read(modelName1,checksum,fields_toget)
            print assigned_user
            if assigned_user:
                for loc_det in assigned_user:

                    string_data = ''
                    # string_data=assigned_user['city']+','+assigned_user['state_id'][1]+','+assigned_user['country_id'][1]
                    if loc_det['street'] != False:
                        string_data = loc_det['street'] + ','
                    if loc_det['street2'] != False:
                        string_data = string_data + loc_det['street2'] + ','
                    if loc_det['city'] != False:
                        string_data = string_data + loc_det['city'] + ','
                    if loc_det['state_id'] != False:
                        string_data = string_data + loc_det['state_id'][1] + ','
                    if loc_det['country_id'] != False:
                        string_data = string_data + loc_det['country_id'][1]
                    print (string_data)
                    partner_location = geocoder.google(string_data)
                    print partner_location.latlng
                    partner_loc = partner_location.latlng
                    if partner_loc:
                        loc_det['latitude'] = partner_loc[0]
                        loc_det['longitude'] = partner_loc[1]
                    else:
                        loc_det['latitude'] = False
                        loc_det['longitude'] = False
                response = assigned_user
            else:
                response = {'status': 'error', 'msg': 'No Customers Found'}

    return jsonify(response)
Exemplo n.º 3
0
def get_project():
    print "entered into project listing"
    modelName= "project.project"
    fields =['name']
    if request.data:
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        api_class = Helpers(request_dict['url'], request_dict['db'], int(request_dict['uid']), request_dict['password'])
        check_access = api_class.check_access_rights(modelName)

        checksum = [['user_id', '=', int(request_dict['uid'])]]
        if (check_access):
            get_all_tasks = api_class.api_search_read(modelName,checksum, fields)
            if (get_all_tasks):
                response = get_all_tasks
            else:
                response = {'status': 'error', 'msg': 'No Tasks Found'}
    return jsonify(response)
Exemplo n.º 4
0
def get_tasks_det():
    #api defaults
    modelName = "project.materials"
    fields_toget = ['product_id','to_use','used']

    if(request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        print "data is %s"%request_dict
        checksum = [['task_id', '=', int(request_dict['task_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):
            get_task_lines = api_class.api_search_read(modelName,checksum,fields_toget)
            if(get_task_lines):
                response = get_task_lines
            else:
                response = {'status': 'error', 'msg': 'No Materials Found'}


        return jsonify(response)
Exemplo n.º 5
0
def get_project_task():
    print "entered into project listing"
    modelName= "project.task"
    fields =['name','project_id','user_id','planned_hours','material_ids','description','stage_id']
    if request.data:
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        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 'project_id' in request_dict:
            checksum = [['project_id', '=', int(request_dict['project_id'])]]
        else:
            checksum = []
        if (check_access):
            get_all_tasks = api_class.api_search_read(modelName,checksum, fields)
            if (get_all_tasks):
                for all in get_all_tasks:
                    test=all['description']
                    plain_text= re.sub(r'<.*?>', '', test)
                    all['description'] = plain_text
                response = get_all_tasks
            else:
                response = {'status': 'error', 'msg': 'No Tasks Found'}
    return jsonify(response)