Community mailing list archives

community@mail.odoo.com

Re: Execute remote method in Odoo 8 xmlrpc

by
Phillip
- 01/29/2016 11:58:15
Also when using RPC ensure your method returns True or False

On 2016-01-29 10:08 AM, Ange DJEDJE wrote:
<blockquote cite="mid:1237814667.585331.1454079902032.JavaMail.zimbra@veone.net" type="cite">
Hi Hardik,

the remote function is my own function, not native or exist code.
this is the function :

@api.one
def save_server_data(self):
    self.env.cr.execute('select model from ir_model where id in (select model_id from base_synchro_obj)')
    filename = '/home/odoo/workspace/Odoov8/openerp/addons/base_synchro_extension/file/'

    objects = self.env.cr.fetchall()

    for obj in objects :

        object_name = str(obj[0]).replace('.','_')
        self.env.cr.execute("""select column_name from information_schema.columns where table_name=%s""",(object_name,))
        columns = self.env.cr.fetchall()
        self.env.cr.execute('select * from ' + object_name)
        result = self.env.cr.fetchall()

        file = open(filename + str(object_name) + '_' + str(datetime.now()) + '.csv', 'w')

        for column in columns :
            file.write('"' + column[0] + '"' + ',')

        file.write('\n')

      nb_col = len(result)
      print nb_col
      c = 0
     for partner in result :
         while c < nb_col :
            file.write('"' + str(partner[c]) + '"' + ',')
           c += 1
      file.write('\n')
      c = 0

file.close()

 

---
Cordialement.
Ange DJEDJE | Coordonnateur Projet
1ère Entreprise Numérique 2015 de Côte d'Ivoire
Tel : +225 22 435 257 | Fax : +225 22 478 054 | Mob : +225 77 70 02 73
Site : www.veone.net | Adr : Cocody Riviera Bonoumin lot 302, ilot 23
Email : ange.djedje@veone.net | Skype : ange.djedje




De: "Hardik Goswami" <hardikgiri.goswami@gmail.com>
À: "Community" <community@mail.odoo.com>
Envoyé: Vendredi 29 Janvier 2016 11:34:35
Objet: Re: Execute remote method in Odoo 8 xmlrpc

Hello Ange,

As I see, your code is looking good which is in the blue. But can you describe which remote method you want to execute. So I can suggest you parameter list too, with proper syntax.

Regards,
Hardikgiri Goswami
Skype : hardikgiri.goswami


On 2:53PM, Fri, Jan 29, 2016 Ange DJEDJE <ange.djedje@veone.net> wrote:
Hello dears,

Please how can I execute a remote method I wrote with xmlrpc in Odoo 8 new api.
I used this way but it does'nt work :

url = 'http://remote_adresse:8069'
db = 'database'
username = 'admin'
password = 'admin'
common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
common.version()
uid = common.authenticate(db, username, password, {})

models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))
liste = models.execute_kw(db, uid, password,
'my.model', 'my_method')


Thanks in advance !

---
Cordialement.
VEONE

Ange DJEDJE | Coordonnateur Projet
1ère Entreprise Numérique 2015 de Côte d'Ivoire
Tel : +225 22 435 257 | Fax : +225 22 478 054 | Mob : +225 77 70 02 73
Site : www.veone.net | Adr : Cocody Riviera Bonoumin lot 302, ilot 23
Email : ange.djedje@veone.net | Skype : ange.djedje


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


-- 
Phillip 

AIM Systems