This question has been flagged
1 Reply
2138 Views

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
Discard
Best Answer

UP +1

Avatar
Discard