Skip to Content
Menu
This question has been flagged
1 Reply
2246 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
Related Posts Replies Views Activity
2
Sep 23
10423
1
May 16
15351
2
Sep 23
7367
2
Nov 23
3303
2
May 19
28500