Use the collection as first argument in the creation of the items

This commit is contained in:
fkantelberg
2020-01-16 14:35:05 +01:00
parent 4e406c849a
commit 9238fd20c1
2 changed files with 11 additions and 11 deletions

View File

@@ -172,7 +172,7 @@ class DavCollection(models.Model):
)) ))
@api.multi @api.multi
def dav_list(self, path_components): def dav_list(self, collection, path_components):
self.ensure_one() self.ensure_one()
if self.dav_type == 'files': if self.dav_type == 'files':
@@ -215,7 +215,7 @@ class DavCollection(models.Model):
return result return result
@api.multi @api.multi
def dav_delete(self, components): def dav_delete(self, collection, components):
self.ensure_one() self.ensure_one()
if self.dav_type == "files": if self.dav_type == "files":
@@ -225,7 +225,7 @@ class DavCollection(models.Model):
self.get_record(components).unlink() self.get_record(components).unlink()
@api.multi @api.multi
def dav_upload(self, href, item): def dav_upload(self, collection, href, item):
self.ensure_one() self.ensure_one()
components = self._split_path(href) components = self._split_path(href)
@@ -248,14 +248,14 @@ class DavCollection(models.Model):
record.write(data) record.write(data)
return Item( return Item(
self, collection,
item=self.to_vobject(record), item=self.to_vobject(record),
href=href, href=href,
last_modified=self._odoo_to_http_datetime(record.write_date), last_modified=self._odoo_to_http_datetime(record.write_date),
) )
@api.multi @api.multi
def dav_get(self, href): def dav_get(self, collection, href):
self.ensure_one() self.ensure_one()
components = self._split_path(href) components = self._split_path(href)
@@ -279,7 +279,7 @@ class DavCollection(models.Model):
('name', '=', components[3]), ('name', '=', components[3]),
], limit=1) ], limit=1)
return FileItem( return FileItem(
self, collection,
item=attachment, item=attachment,
href=href, href=href,
last_modified=self._odoo_to_http_datetime( last_modified=self._odoo_to_http_datetime(
@@ -293,7 +293,7 @@ class DavCollection(models.Model):
return None return None
return Item( return Item(
self, collection,
item=self.to_vobject(record), item=self.to_vobject(record),
href=href, href=href,
last_modified=self._odoo_to_http_datetime(record.write_date), last_modified=self._odoo_to_http_datetime(record.write_date),

View File

@@ -120,13 +120,13 @@ class Collection(BaseCollection):
self.logger.warning('unsupported metadata %s', key) self.logger.warning('unsupported metadata %s', key)
def get(self, href): def get(self, href):
return self.collection.dav_get(href) return self.collection.dav_get(self, href)
def upload(self, href, vobject_item): def upload(self, href, vobject_item):
return self.collection.dav_upload(href, vobject_item) return self.collection.dav_upload(self, href, vobject_item)
def delete(self, href): def delete(self, href):
return self.collection.dav_delete(self._split_path(href)) return self.collection.dav_delete(self, self._split_path(href))
def list(self): def list(self):
return self.collection.dav_list(self.path_components) return self.collection.dav_list(self, self.path_components)