我正在使用以下包: https://pypi.python.org/pypi/sugarcrm/0.1
使用以下代码我可以创建一个潜在客户:
import sugarcrm
# Connect
url = "http://localhost:8080/service/v4/rest.php"
username = 'admin'
password = 'admin'
session = sugarcrm.Session(url, username, password)
# Create a lead
lead = sugarcrm.Lead(first_name="Tester",
last_name="Test",
email1="tester@test.com",
description="Submit",
do_not_call=True)
session.set_entry(lead)
但是,我在crm中有一些自定义模块要维护,我找不到在这些模块中创建条目的任何方法。有谁知道怎么做?
答案 0 :(得分:1)
我所拥有的一个自定义模块称为APPSV_Credit_Cards
。查看https://pypi.python.org/pypi/sugarcrm/0.1的源代码,发现以下工作:
>>> class CreditCards(sugarcrm.SugarObject):
... module = "APPSV_Credit_Cards"
...
>>> creditCards = CreditCards()
>>> creditCards
<__main__.CreditCards instance at 0x7f72c1e2fc68>
>>> crmSession.get_entry_list(creditCards)
[]
>>> creditCards = CreditCards(name='AMEX Platinum', product_code='AMEXPLT', product_desc='American Express Platinum Card')
>>> response = crmSession.set_entry(creditCards)
>>> response = crmSession.get_entry_list(creditCards)
>>> response[0].__dict__
{'modified_user_id': u'916110f8-f8cb-fc6c-9d78-58357676adce', 'date_entered': u'2016-12-11 04:31:38', 'name': u'AMEX Platinum', 'date_modified': u'2016-12-11 04:31:38', 'deleted': u'0', 'created_by_name': u'Usercity API', 'product_desc': u'American Express Platinum Card', 'assigned_user_id': u'', 'module': 'APPSV_Credit_Cards', 'modified_by_name': u'Usercity API', 'assigned_user_name': u'', 'product_code': u'AMEXPLT', 'id': u'dba547ee-fc95-b088-f39c-584cd647ae75', 'created_by': u'916110f8-f8cb-fc6c-9d78-58357676adce', 'description': u''}
>>>