Commit f61f17f3 authored by ryanss's avatar ryanss
Browse files

Implement set_document_revision, set_relationship

parent 7e58238a
......@@ -139,6 +139,16 @@ get_entry_list(query_object)
login(username, password, app="Python", lang="en_us")
Logs a user into the SugarCRM application.
set_document_revision(document, file)
Creates a new document revision for a specific document record.
.. code-block:: python
doc = sugarcrm.Document(document_name="Test Doc", revision=1)
sugar.set_entry(doc)
sugar.set_document_revision(doc, "/path/to/test.pdf")
set_entry(sugar_object)
Creates or updates a specific object.
......@@ -160,6 +170,17 @@ set_note_attachment(note, attachment)
sugar.set_note_attachment(note2, "test2.pdf")
print note1.filename, note2.filename
set_relationship(parent, child, delete=False)
Sets the relationships between two records.
.. code-block:: python
doc = sugarcrm.Document(document_name="Test Doc", revision=1)
sugar.set_entry(doc)
sugar.set_document_revision(doc, "/path/to/test.pdf")
opportunity = sugar.get_entry("Opportunities", "5b671886-cfe4-36f5-fa9d-5418a24e4aca")
sugar.set_relationship(opportunity, doc)
get_document_revision()
Method not implemented yet.
......@@ -235,15 +256,9 @@ search_by_module()
set_campaign_merge()
Method not implemented yet.
set_document_revision()
Method not implemented yet.
set_entries()
Method not implemented yet.
set_relationship()
Method not implemented yet.
set_relationships()
Method not implemented yet.
......
......@@ -184,8 +184,18 @@ class API:
def set_campaign_merge(self):
raise SugarError("Method not implemented yet.")
def set_document_revision(self):
raise SugarError("Method not implemented yet.")
def set_document_revision(self, doc, f, revision=None):
"""Creates a new document revision for a specific document record."""
if isinstance(f, str) or isinstance(f, unicode):
f = open(f, 'rb')
fields = {
'id': doc.id,
'filename': f.name,
'file': base64.b64encode(f.read()),
'revision': revision or doc.revision,
}
data = [self.session_id, fields]
return self._request('set_document_revision', data)
def set_entries(self):
raise SugarError("Method not implemented yet.")
......@@ -199,7 +209,7 @@ class API:
def set_note_attachment(self, note, f):
"""Creates an attachmentand associates it to a specific note object."""
if isinstance(f, str):
if isinstance(f, str) or isinstance(f, unicode):
f = open(f, 'rb')
fields = {
'id': note.id,
......@@ -209,8 +219,17 @@ class API:
data = [self.session_id, fields]
return self._request('set_note_attachment', data)
def set_relationship(self):
raise SugarError("Method not implemented yet.")
def set_relationship(self, parent, child, delete=False):
"""Sets relationships between two records."""
delete = int(delete)
related_ids = [child.id,]
name_value_list = [{
'name': "%s_%s" % (parent.module.lower(), child.module.lower()),
'value': 'Other',
}]
data = [self.session_id, parent.module, parent.id,
child.module.lower(), related_ids, name_value_list, delete]
return self._request('set_relationship', data)
def set_relationships(self):
raise SugarError("Method not implemented yet.")
......@@ -258,9 +277,15 @@ class SugarObject:
class Contact(SugarObject):
module = "Contacts"
class Document(SugarObject):
module = "Documents"
class Module(SugarObject):
module = "Modules"
class Note(SugarObject):
module = "Notes"
......
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