Пример #1
0
    def setcountry_id(self, value):
        # check to see if country value exists
        args = [("name", "=", value)]
        model = "res.country"
        call = Xmlcall(openerpconfig.rpcurl, openerpconfig.rpcuser, openerpconfig.rpcpwd, openerpconfig.rpcdb)
        ids = call.execute_action(model, "search", args)

        if len(ids) > 0:
            self.country_id = ids[0]
Пример #2
0
    def setUser(self, value):
        # chk if this stage already exists
        args = [("name", "=", value)]
        model = "res.users"
        call = Xmlcall(openerpconfig.rpcurl, openerpconfig.rpcuser, openerpconfig.rpcpwd, openerpconfig.rpcdb)
        ids = call.execute_action(model, "search", args)

        # do not try creating if not present, fallback to deafult
        if len(ids) > 0:
            self.user_id = ids[0]
Пример #3
0
    def setcountry_id(self, value):
        #check to see if country value exists
        args = [('name', '=', value)]
        model = 'res.country'
        call = Xmlcall(openerpconfig.rpcurl, openerpconfig.rpcuser,
                       openerpconfig.rpcpwd, openerpconfig.rpcdb)
        ids = call.execute_action(model, 'search', args)

        if len(ids) > 0:
            self.country_id = ids[0]
Пример #4
0
    def setUser(self, value):
        #chk if this stage already exists
        args = [('name', '=', value)]
        model = 'res.users'
        call = Xmlcall(openerpconfig.rpcurl, openerpconfig.rpcuser,
                       openerpconfig.rpcpwd, openerpconfig.rpcdb)
        ids = call.execute_action(model, 'search', args)

        #do not try creating if not present, fallback to deafult
        if len(ids) > 0:
            self.user_id = ids[0]
Пример #5
0
    def setStage(self, value):
        # chk if this stage already exists
        args = [("name", "=", value), ("type", "=", "lead")]
        model = "crm.case.stage"
        call = Xmlcall(openerpconfig.rpcurl, openerpconfig.rpcuser, openerpconfig.rpcpwd, openerpconfig.rpcdb)
        ids = call.execute_action(model, "search", args)

        # if not exist, try creating
        if len(ids) == 0:
            stage = {"name": value, "type": "lead"}
            ids = call.execute_action(model, "create", stage)
            self.stage_id = ids
        else:
            self.stage_id = ids[0]
Пример #6
0
    def setStage(self, value):
        #chk if this stage already exists
        args = [('name', '=', value), ('type', '=', 'lead')]
        model = 'crm.case.stage'
        call = Xmlcall(openerpconfig.rpcurl, openerpconfig.rpcuser,
                       openerpconfig.rpcpwd, openerpconfig.rpcdb)
        ids = call.execute_action(model, 'search', args)

        #if not exist, try creating
        if len(ids) == 0:
            stage = {'name': value, 'type': 'lead'}
            ids = call.execute_action(model, 'create', stage)
            self.stage_id = ids
        else:
            self.stage_id = ids[0]
Пример #7
0
mgbp = re.search(r"GBP.*?([\d]+\.[\d]+).*?([\d]+\.[\d]+)", resp.text, re.S)
rgbp = float(mgbp.group(2))

meur = re.search(r"EUR.*?([\d]+\.[\d]+).*?([\d]+\.[\d]+)", resp.text, re.S)
reur = float(meur.group(2))

# out rates into dict
ratemap = {}
ratemap["USD"] = 1 / rusd
ratemap["GBP"] = 1 / rgbp
ratemap["EUR"] = 1 / reur

today = datetime.date.today()

# now populate into openERP
for key, value in ratemap.items():
    cur = Currency()
    cur.setRate(value)
    cur.setID(key)
    cur.setName(str(today))

    # now make rpc call
    model = "res.currency.rate"
    call = Xmlcall(openerpconfig.rpcurl, openerpconfig.rpcuser, openerpconfig.rpcpwd, openerpconfig.rpcdb)
    cid = call.execute_action(model, "create", cur.__dict__)

    # print obj id and name
    print cid
    print key
Пример #8
0
            l.setReferred(row["Lead Source"])
            l.setFunction(row["Title"])
            l.setStreet(row["Street"])
            l.setStreet2(row["PO Box"])
            l.setCity(row["City"])
            l.setEmail(row["Other Email"])
            l.setPhone(row["Phone"])
            l.setFax(row["Fax"])
            l.setMobile(row["Mobile"])
            l.setIscustomeradd()
            l.setCompanyid(row["Company"])
            
            l.setcountry_id(row["Country"])
            
           
            #create objects via xml-rpc
            model = 'crm.lead'
            call = Xmlcall(openerpconfig.rpcurl, openerpconfig.rpcuser, openerpconfig.rpcpwd, openerpconfig.rpcdb)
            leadid = call.execute_action(model, 'create', l.__dict__)

            #print obj id and name
            print leadid
            print row["Name"]
            
            
except mdb.Error, e:
    print "Error %d: %s" % (e.args[0],e.args[1])
    sys.exit(1)    
finally:            
    if con:    
        con.close()            
Пример #9
0
mgbp = re.search(r'GBP.*?([\d]+\.[\d]+).*?([\d]+\.[\d]+)', resp.text, re.S)
rgbp = float(mgbp.group(2))

meur = re.search(r'EUR.*?([\d]+\.[\d]+).*?([\d]+\.[\d]+)', resp.text, re.S)
reur = float(meur.group(2))

#out rates into dict
ratemap = {}
ratemap['USD'] = 1 / rusd
ratemap['GBP'] = 1 / rgbp
ratemap['EUR'] = 1 / reur

today = datetime.date.today()

# now populate into openERP
for key, value in ratemap.items():
    cur = Currency()
    cur.setRate(value)
    cur.setID(key)
    cur.setName(str(today))

    #now make rpc call
    model = 'res.currency.rate'
    call = Xmlcall(openerpconfig.rpcurl, openerpconfig.rpcuser,
                   openerpconfig.rpcpwd, openerpconfig.rpcdb)
    cid = call.execute_action(model, 'create', cur.__dict__)

    #print obj id and name
    print cid
    print key