Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
5000 Tampilan

Hello, I am writing a tool to import leads into our openerp instance.

The XMLRPC examples are very good, however I'm having trouble figuring out how to set the many2many_tags we need to tag the new lead with "New Lead".

xmlsock_common = xmlrpclib.ServerProxy(openerp_xmlrpcpath_common)
openerp_uid = xmlsock_common.login(
        openerp_dbname, openerp_username, openerp_password)

xmlsock_object = xmlrpclib.ServerProxy(openerp_xmlrpcpath_object)
    name =  '%s %s' % (wrapnone(message.pop("FirstName")),
            wrapnone(message.pop("LastName")))
    company = wrapnone(message.pop("Company"))
    title = "%s - %s - %s" % (company, name, wrapnone(message.pop("FormName", "unknownform")))
    #company name - contact name - FormName"

    lead = {
            'name': title,
            'partner_name': company,
            'contact_name': name,  # Contact Name
            'email_from': wrapnone(message.pop("EMail")),
            #'city': 'Santa Clara', # City
            'type': 'lead',
            'priority': '3',
            'description': notes,
            'phone': wrapnone(message.pop("Phone")),
            #'categ_ids': new_lead_ids,
            }

    xmlsock_object.execute(openerp_dbname, openerp_uid,
            openerp_password, 'crm.lead', 'create', lead)

The "field" I'm trying to set is:

Field: categ_ids
Object: crm.leads
Type: many2many
Widget: many2many_tags
Context: {'object_name': 'crm.lead'}
Domain: [('object_id.model','=','crm.lead')]
Relation: crm.case.categ

How can I look up "New Lead" in the "tags" table and set it on the new lead please?

Are there any examples using xmlrpc to fetch/set many2many2_tags I can use?

thank you, -Alfred

Avatar
Buang
Jawaban Terbai

You can search the id of 'New Lead" entry in the table crm.case.categ.

Once you have it, try :

lead = {
   [...]
   'categ_ids':  [(6,0,[newLead_id])],
   }
Avatar
Buang
Penulis

Sven, thank you !

Here is my query code:

# Query for 'New Lead' tag we need to assign.
print "Getting 'New Lead' id..."
args = [('categ', '=', 'New Lead')] #query clause
new_lead_ids = xmlsock_object.execute(
        openerp_dbname, openerp_uid, openerp_password,
        'crm.case', 'search', args)
print "done => %s" % new_lead_ids

However that seems to hang. Any ideas what I am doing wrong?

If you print new_lead_ids, what did you get ? Can you describe your crm.case table ? (what fields in ?)

Penulis

Sven, thank you for your help. I finally figured out the fetch problem, my code incorrect, I was matching 'categ' = 'new lead' and using the wrong table 'crm.case' this is the fixed fetch code:

# Query for 'New Lead' tag we need to assign.
#print "Getting 'New Lead' id..."
#args = [('name', '=', 'New Lead')] #query clause
#new_lead_ids = xmlsock_object.execute(
    #    openerp_dbname, openerp_uid, openerp_password,
    #    'crm.case.categ', 'search', args)
#print "done => %s" % new_lead_ids

Thanks again for your help.

No problem. Can you close the question ? (With a [Closed] in the title.)

Penulis Jawaban Terbai

Sven answered my question. Closed.

Avatar
Buang
Penulis

done! thank you.

By the way, why don't the notification emails give me html link to the question I asked? Pretty frustrating.

Maybe some bug on the help.openerp.com :s

Post Terkait Replies Tampilan Aktivitas
1
Sep 23
1756
2
Nov 22
3337
4
Okt 21
23631
4
Okt 17
27943
2
Jun 16
10974