[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
|
# 6. OK : Offer two (or more) calendar : own events, events where I'm attended
|
||||||
# and all readable events
|
# and all readable events
|
||||||
# 7. Offer one calendar per user (via login/email)
|
# 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
|
# 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.storage import BaseCollection, Item, get_etag, get_uid_from_object
|
||||||
from radicale_odoo_auth import Auth
|
from radicale_odoo_auth import Auth
|
||||||
|
|
||||||
# Application.do_PUT = do_PUT
|
|
||||||
|
|
||||||
|
|
||||||
class Collection(BaseCollection):
|
class Collection(BaseCollection):
|
||||||
""" BaseCollection implementation for Odoo Radicale Storage """
|
""" BaseCollection implementation for Odoo Radicale Storage """
|
||||||
@ -257,9 +255,10 @@ class Collection(BaseCollection):
|
|||||||
street=' '.join([partner.get('street') or '', partner.get('street2') or '']),
|
street=' '.join([partner.get('street') or '', partner.get('street2') or '']),
|
||||||
code=partner.get('zip') or '', city=partner.get('city') or '',
|
code=partner.get('zip') or '', city=partner.get('city') or '',
|
||||||
region=state_name, country=country_name)
|
region=state_name, country=country_name)
|
||||||
if partner.get('image'):
|
# Performance issue with large attached images...
|
||||||
vobject_item.add('photo;encoding=b;type=jpeg').value = partner.get(
|
# if partner.get('image'):
|
||||||
'image').replace('\n', '')
|
# vobject_item.add('photo;encoding=b;type=jpeg').value = partner.get(
|
||||||
|
# 'image').replace('\n', '')
|
||||||
if partner.get('phone'):
|
if partner.get('phone'):
|
||||||
tel = vobject_item.add('tel')
|
tel = vobject_item.add('tel')
|
||||||
tel.type_param = 'Tel'
|
tel.type_param = 'Tel'
|
||||||
@ -361,7 +360,7 @@ class Collection(BaseCollection):
|
|||||||
def upload(self, href, item):
|
def upload(self, href, item):
|
||||||
""" Creation or update """
|
""" Creation or update """
|
||||||
self.logger.info('Upload href %s , item %s' % (href, item))
|
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
|
# Ref : important to keep track of creations outside of Odoo
|
||||||
contact_data = {'ref': item.uid.value}
|
contact_data = {'ref': item.uid.value}
|
||||||
@ -443,6 +442,7 @@ class Collection(BaseCollection):
|
|||||||
if href in self.partners.keys():
|
if href in self.partners.keys():
|
||||||
partner = self.partners[href]
|
partner = self.partners[href]
|
||||||
partner_id = partner['id']
|
partner_id = partner['id']
|
||||||
|
# TODO: diff changes, do not write everything
|
||||||
partner_obj.write([partner_id], contact_data)
|
partner_obj.write([partner_id], contact_data)
|
||||||
else:
|
else:
|
||||||
partner_id = partner_obj.create(contact_data)
|
partner_id = partner_obj.create(contact_data)
|
||||||
@ -450,7 +450,8 @@ class Collection(BaseCollection):
|
|||||||
self.partners[item.uid.value] = partner
|
self.partners[item.uid.value] = partner
|
||||||
|
|
||||||
res_item = self.get(item.uid.value)
|
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
|
return res_item
|
||||||
|
|
||||||
def delete(self, href=None):
|
def delete(self, href=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user