Saturday 1 August 2015

XML-RPC Example

Hi All,
    Here am explaining how to use xml-rpc.

    Ex:suppose we need to create a partner


import xmlrpclib
username = 'admin' #the user
pwd = '******'      #the password of the user
dbname = 'db123'    #the database

# Get the uid
sock_common = xmlrpclib.ServerProxy ('http://localhost:1212/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)

#replace localhost with the address of the server
sock = xmlrpclib.ServerProxy('http://localhost:1212/xmlrpc/object')


values = {
    'name':"Partner1",

    
    }

sock.execute(dbname, uid, pwd, 'res.partner', 'create', values)

Example For Server Action

    Hi all,
         Here am explaining how to trigger an automatic email to immediate manager,while an employee submitting  his/her leave request.


Step1.

 

     Configure out going mail server(already explained in my previous post).


step2.

 

   *)Create a Template for mail

 

    name:template_leave_email
    Applies to:Leave
    subject:Leave Request from [[ object.employee_id.name ]]
    Message:Dear [[object.employee_id.parent_id.name]],
            You have one Leave Request from [[ object.employee_id.name ]].Please see that one.
            Thanking You.
    from:${object.employee_id.work_email}
    To(emails):${object.employee_id.parent_id.work_email}
    Language:${object.partner_id and object.partner_id.lang or ''}
    Outgoing mail server:(localhost)

























   *)Create a server action

 

     Action Name:leave_request_manager
     Base Model:Leave
     Action To Do:Send Email
     Condition:True
     Sequence:5
     Email Template:template_leave_email(select the template we are already created)


step3:Customize the workflow

 

      Setting->Workflows->Workflows->hr.wkf.holidays
      take the confirm button
      and attach our new server action with it.