Ejemplo n.º 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]
Ejemplo n.º 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]
Ejemplo n.º 3
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]
Ejemplo n.º 4
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