跳至內容
選單
此問題已被標幟
1 回覆
3402 瀏覽次數

Hi,

I'm trying to implement a feature in my custom module that auto fills a selection field with data (gathers from GET requests to alfresco API to list site's directory)


I've tried the following but did not work :

......
my_site = fields.Char("Site")
my_selection = fields.Selection(selection="_get_selection",string="Directory")
def _get_selection(self) : 
    if self.site_is_reachable() :
        link = "https://alfresco.com/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/sites/"+
                self.my_site+
                "/documentLibrary" # self.my_site si not accessible here
         passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
         passman.add_password(None, link,user, pwd)
         authhandler = urllib2.HTTPBasicAuthHandler(passman)
         opener = urllib2.build_opener(authhandler)
         urllib2.install_opener(opener)
         pagehandle = urllib2.urlopen(link)
         return self.handle_response(pagehandle.read()) # handle the response, extract the names and return a list of tuples
.......

               

The issue in the code is that the called function in "Selection" :_get_selection, does not have the current record, i can't figure out how to passe it as argument or through context.

Any idea to make it work ?

Thank you :)

頭像
捨棄
最佳答案

UP +1

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
9月 23
13176
1
5月 16
17430
2
9月 23
9363
2
11月 23
5374
2
5月 19
31676