Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
5105 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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])],
   }
Awatar
Odrzuć
Autor

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 ?)

Autor

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.)

Autor Najlepsza odpowiedź

Sven answered my question. Closed.

Awatar
Odrzuć
Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
1
wrz 23
1828
2
lis 22
3422
4
paź 21
23772
4
paź 17
28079
2
cze 16
11071