Commit 7b449a06 authored by ryanss's avatar ryanss
Browse files

Add changing sales_stage example to README

parent c126a111
......@@ -33,3 +33,9 @@ Example Usage
user_id = result[0]['name_value_list']['assigned_user_id']['value']
result = sugar.get_entry("Users", user_id)
email = result[0]['name_value_list']['email1']['value']
# Change the status of an Opportunity
op = sugarcrm.Opportunity()
op.id = "82f72939-735e-53a2-0944-5418c4edae2a"
op.sales_stage = "Approved"
sugar.set_entry(op)
......@@ -24,7 +24,9 @@ class API:
'rest_data': json.dumps(params)
}
r = requests.post(self.url, data=data)
return json.loads(r.text)
if r.status_code == 200:
return json.loads(r.text)
return {'status_code': r.status_code}
def get_entry(self, module, id, track_view=False):
data = [self.session_id, module, id, [], [], track_view]
......@@ -43,6 +45,8 @@ class API:
def set_entry(self, obj):
data = [self.session_id, obj.type, obj.fields]
result = self.request('set_entry', data)
if 'status_code' in result:
return False
obj.id = result['id']
def set_note_attachment(self, note, f):
......@@ -84,7 +88,6 @@ class SugarObject:
q += "%s.%s LIKE '%s' " % (self.type.lower(), key, str(value))
else:
q += "%s.%s='%s' " % (self.type.lower(), key, str(value))
print q
return q
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment