[ADD]Odoo storage plugin : allow delete, write...,
Also some fixes (dicover, upload) and performance improvements (image not managed anymore).
This commit is contained in:
parent
60c6f10392
commit
a556b199b0
@ -26,7 +26,7 @@
|
||||
# 6. OK : Offer two (or more) calendar : own events, events where I'm attended
|
||||
# and all readable events
|
||||
# 7. Offer one calendar per user (via login/email)
|
||||
# 8. Begin write (two way) for contacts
|
||||
# 8. OK : Begin write (two way) for contacts
|
||||
# 9. Begin write (two way) for calendar
|
||||
|
||||
|
||||
@ -41,8 +41,6 @@ from radicale import xmlutils
|
||||
from radicale.storage import BaseCollection, Item, get_etag, get_uid_from_object
|
||||
from radicale_odoo_auth import Auth
|
||||
|
||||
# Application.do_PUT = do_PUT
|
||||
|
||||
|
||||
class Collection(BaseCollection):
|
||||
""" BaseCollection implementation for Odoo Radicale Storage """
|
||||
@ -257,9 +255,10 @@ class Collection(BaseCollection):
|
||||
street=' '.join([partner.get('street') or '', partner.get('street2') or '']),
|
||||
code=partner.get('zip') or '', city=partner.get('city') or '',
|
||||
region=state_name, country=country_name)
|
||||
if partner.get('image'):
|
||||
vobject_item.add('photo;encoding=b;type=jpeg').value = partner.get(
|
||||
'image').replace('\n', '')
|
||||
# Performance issue with large attached images...
|
||||
# if partner.get('image'):
|
||||
# vobject_item.add('photo;encoding=b;type=jpeg').value = partner.get(
|
||||
# 'image').replace('\n', '')
|
||||
if partner.get('phone'):
|
||||
tel = vobject_item.add('tel')
|
||||
tel.type_param = 'Tel'
|
||||
@ -361,7 +360,7 @@ class Collection(BaseCollection):
|
||||
def upload(self, href, item):
|
||||
""" Creation or update """
|
||||
self.logger.info('Upload href %s , item %s' % (href, item))
|
||||
# TODO : handle image
|
||||
# TODO : handle image ?
|
||||
|
||||
# Ref : important to keep track of creations outside of Odoo
|
||||
contact_data = {'ref': item.uid.value}
|
||||
@ -443,6 +442,7 @@ class Collection(BaseCollection):
|
||||
if href in self.partners.keys():
|
||||
partner = self.partners[href]
|
||||
partner_id = partner['id']
|
||||
# TODO: diff changes, do not write everything
|
||||
partner_obj.write([partner_id], contact_data)
|
||||
else:
|
||||
partner_id = partner_obj.create(contact_data)
|
||||
@ -450,7 +450,8 @@ class Collection(BaseCollection):
|
||||
self.partners[item.uid.value] = partner
|
||||
|
||||
res_item = self.get(item.uid.value)
|
||||
# print('item.etag : %s // res_item.etag : %s' % (item.etag, res_item.etag))
|
||||
# Avoid bad mismatch for CardDAV client with live upload
|
||||
del res_item.last_modified
|
||||
return res_item
|
||||
|
||||
def delete(self, href=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user