Skip to content

Commit

Permalink
[MIG] base_dav: Migration to 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarlr committed Dec 29, 2021
1 parent 19a5cd6 commit 9fa5f65
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 28 deletions.
11 changes: 6 additions & 5 deletions base_dav/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Caldav and Carddav support
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
:target: https://github.com/OCA/server-backend/tree/11.0/base_dav
:target: https://github.com/OCA/server-backend/tree/12.0/base_dav
:alt: OCA/server-backend
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-backend-11-0/server-backend-11-0-base_dav
:target: https://translation.odoo-community.org/projects/server-backend-12-0/server-backend-12-0-base_dav
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/253/11.0
:target: https://runbot.odoo-community.org/runbot/253/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -60,7 +60,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_dav%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_dav%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -78,6 +78,7 @@ Contributors

* Holger Brunn <hbrunn@therp.nl>
* Florian Kantelberg <florian.kantelberg@initos.com>
* César López Ramírez <cesar.lopez@coopdevs.org>

Other credits
~~~~~~~~~~~~~
Expand All @@ -98,6 +99,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/11.0/base_dav>`_ project on GitHub.
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/12.0/base_dav>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion base_dav/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Caldav and Carddav support",
"version": "11.0.1.0.0",
"version": "12.0.1.0.0",
"author": "initOS GmbH,Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Extra Tools",
Expand Down
10 changes: 5 additions & 5 deletions base_dav/demo/dav_collection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
</record>
<record id="field_mapping_addressbook_n" model="dav.collection.field_mapping">
<field name="name">N</field>
<field name="field_id" ref="base.field_res_partner_name" />
<field name="field_id" ref="base.field_res_partner__name" />
<field name="collection_id" ref="collection_addressbook" />
</record>
<record id="field_mapping_addressbook_fn" model="dav.collection.field_mapping">
<field name="name">FN</field>
<field name="field_id" ref="base.field_res_partner_display_name" />
<field name="field_id" ref="base.field_res_partner__display_name" />
<field name="collection_id" ref="collection_addressbook" />
</record>
<record id="field_mapping_addressbook_photo" model="dav.collection.field_mapping">
<field name="name">photo</field>
<field name="field_id" ref="base.field_res_partner_image" />
<field name="field_id" ref="base.field_res_partner__image" />
<field name="collection_id" ref="collection_addressbook" />
</record>
<record id="field_mapping_addressbook_email" model="dav.collection.field_mapping">
<field name="name">email</field>
<field name="field_id" ref="base.field_res_partner_email" />
<field name="field_id" ref="base.field_res_partner__email" />
<field name="collection_id" ref="collection_addressbook" />
</record>
<record id="field_mapping_addressbook_tel" model="dav.collection.field_mapping">
<field name="name">tel</field>
<field name="field_id" ref="base.field_res_partner_phone" />
<field name="field_id" ref="base.field_res_partner__phone" />
<field name="collection_id" ref="collection_addressbook" />
</record>
</odoo>
5 changes: 2 additions & 3 deletions base_dav/models/dav_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,14 @@ def to_vobject(self, record):
if 'uid' not in vobj.contents:
vobj.add('uid').value = '%s,%s' % (record._name, record.id)
if 'rev' not in vobj.contents and 'write_date' in record._fields:
vobj.add('rev').value = record.write_date.\
replace(':', '').replace(' ', 'T').replace('.', '') + 'Z'
vobj.add('rev').value = record.write_date.strftime('%Y-%m-%dT%H%M%SZ')
return result

@api.model
def _odoo_to_http_datetime(self, value):
return time.strftime(
'%a, %d %b %Y %H:%M:%S GMT',
time.strptime(value, '%Y-%m-%d %H:%M:%S'),
value.timetuple(),
)

@api.model
Expand Down
5 changes: 3 additions & 2 deletions base_dav/models/dav_collection_field_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import datetime

from odoo import api, fields, models, tools
from odoo.tools.safe_eval import safe_eval

import dateutil
import vobject
Expand Down Expand Up @@ -67,7 +68,7 @@ def _from_vobject_code(self, child):
'tz': tz,
'vobject': vobject,
}
tools.safe_eval(self.import_code, context, mode="exec", nocopy=True)
safe_eval(self.import_code, context, mode="exec", nocopy=True)
return context.get('result', {})

@api.multi
Expand Down Expand Up @@ -137,7 +138,7 @@ def _to_vobject_code(self, record):
'tz': tz,
'vobject': vobject,
}
tools.safe_eval(self.export_code, context, mode="exec", nocopy=True)
safe_eval(self.export_code, context, mode="exec", nocopy=True)
return context.get('result', None)

@api.multi
Expand Down
2 changes: 1 addition & 1 deletion base_dav/radicale/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __init__(self, path):
def _odoo_to_http_datetime(self, value):
return time.strftime(
'%a, %d %b %Y %H:%M:%S GMT',
time.strptime(value, '%Y-%m-%d %H:%M:%S'),
value.timetuple(),
)

def get_meta(self, key=None):
Expand Down
1 change: 1 addition & 0 deletions base_dav/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Holger Brunn <hbrunn@therp.nl>
* Florian Kantelberg <florian.kantelberg@initos.com>
* César López Ramírez <cesar.lopez@coopdevs.org>
9 changes: 5 additions & 4 deletions base_dav/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Caldav and Carddav support</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Caldav and Carddav support</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-backend/tree/11.0/base_dav"><img alt="OCA/server-backend" src="https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-backend-11-0/server-backend-11-0-base_dav"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/253/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-backend/tree/12.0/base_dav"><img alt="OCA/server-backend" src="https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-backend-12-0/server-backend-12-0-base_dav"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/253/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds WebDAV support to Odoo, specifically CalDAV and CardDAV.</p>
<p>You can configure arbitrary objects as a calendar or an address book, thus make arbitrary information accessible in external systems or your mobile.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -409,7 +409,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-backend/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-backend/issues/new?body=module:%20base_dav%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/server-backend/issues/new?body=module:%20base_dav%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -426,6 +426,7 @@ <h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li>Holger Brunn &lt;<a class="reference external" href="mailto:hbrunn&#64;therp.nl">hbrunn&#64;therp.nl</a>&gt;</li>
<li>Florian Kantelberg &lt;<a class="reference external" href="mailto:florian.kantelberg&#64;initos.com">florian.kantelberg&#64;initos.com</a>&gt;</li>
<li>César López Ramírez &lt;<a class="reference external" href="mailto:cesar.lopez&#64;coopdevs.org">cesar.lopez&#64;coopdevs.org</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand All @@ -442,7 +443,7 @@ <h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-backend/tree/11.0/base_dav">OCA/server-backend</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-backend/tree/12.0/base_dav">OCA/server-backend</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
18 changes: 11 additions & 7 deletions base_dav/tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ def setUp(self):
})

self.create_field_mapping(
"login", "base.field_res_users_login",
"login", "base.field_res_users__login",
excode="result = record.login",
imcode="result = item.value",
)
self.create_field_mapping(
"name", "base.field_res_users_name",
"name", "base.field_res_users__name",
)
self.create_field_mapping(
"dtstart", "base.field_res_users_create_date",
"dtstart", "base.field_res_users__create_date",
)
self.create_field_mapping(
"dtend", "base.field_res_users_write_date",
"dtend", "base.field_res_users__write_date",
)

start = datetime.now()
Expand All @@ -59,8 +59,12 @@ def compare_record(self, vobj, rec=None):

self.assertEqual((rec or self.record).login, tmp["login"])
self.assertEqual((rec or self.record).name, tmp["name"])
self.assertEqual((rec or self.record).create_date, tmp["create_date"])
self.assertEqual((rec or self.record).write_date, tmp["write_date"])
self.assertEqual((rec or self.record).create_date.strftime(
DEFAULT_SERVER_DATETIME_FORMAT), tmp["create_date"]
)
self.assertEqual((rec or self.record).write_date.strftime(
DEFAULT_SERVER_DATETIME_FORMAT), tmp["write_date"]
)

def test_import_export(self):
# Exporting and importing should result in the same record
Expand All @@ -72,7 +76,7 @@ def test_get_record(self):
self.assertEqual(rec, self.record)

self.collection.field_uuid = self.env.ref(
"base.field_res_users_login",
"base.field_res_users__login",
).id
rec = self.collection.get_record([self.record.login])
self.assertEqual(rec, self.record)
Expand Down
1 change: 1 addition & 0 deletions setup/base_dav/odoo/addons/base_dav
12 changes: 12 additions & 0 deletions setup/base_dav/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon={
'external_dependencies_override': {
'python': {
'radicale': 'Radicale==2.1.11'
}
}
},
)

0 comments on commit 9fa5f65

Please sign in to comment.