Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
3367 Visninger

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 :)

Avatar
Kassér
Bedste svar

UP +1

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
2
sep. 23
13142
1
maj 16
17412
2
sep. 23
9317
2
nov. 23
5350
2
maj 19
31637