Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.0][MIG] base_dav: migration to 12.0 #226

Open
wants to merge 14 commits into
base: 12.0
Choose a base branch
from
Open
103 changes: 103 additions & 0 deletions base_dav/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
==========================
Caldav and Carddav support
==========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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
: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
: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
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds WebDAV support to Odoo, specifically CalDAV and CardDAV.

You can configure arbitrary objects as a calendar or an address book, thus make arbitrary information accessible in external systems or your mobile.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

#. go to `Settings / WebDAV Collections` and create or edit your collections. There, you'll also see the URL to point your clients to.

Note that you need to configure a dbfilter if you use multiple databases.

Known issues / Roadmap
======================

* much better UX for configuring collections (probably provide a group that sees the current fully flexible field mappings, and by default show some dumbed down version where you can select some preselected vobject fields)
* support todo lists and journals
* support configuring default field mappings per model
* support plain WebDAV collections to make some model's records accessible as folders, and the records' attachments as files (r/w)
* support configuring lists of calendars so that you can have a calendar for every project and appointments are tasks, or a calendar for every sales team and appointments are sale orders. Lots of possibilities

Backporting this to <=v10 will be tricky because radicale only supports python3. Probably it will be quite a hassle to backport the relevant code, so it might be more sensible to just backport the configuration part, and implement the rest as radicale auth/storage plugin that talks to Odoo via odoorpc. It should be possible to recycle most of the code from this addon, which actually implements those plugins, but then within Odoo.

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**>`_.

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

Credits
=======

Authors
~~~~~~~

* initOS GmbH
* Therp BV

Contributors
~~~~~~~~~~~~

* Holger Brunn <hbrunn@therp.nl>
* Florian Kantelberg <florian.kantelberg@initos.com>

Other credits
~~~~~~~~~~~~~

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_
* All the actual work is done by `Radicale <https://radicale.org>`_

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions base_dav/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models
from . import controllers
from . import radicale
25 changes: 25 additions & 0 deletions base_dav/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2018 Therp BV <https://therp.nl>
# Copyright 2019-2020 initOS GmbH <https://initos.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Caldav and Carddav support",
"version": "12.0.1.0.0",
"author": "initOS GmbH, Therp BV, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Extra Tools",
"summary": "Access Odoo data as calendar or address book",
"website": "https://github.com/OCA/server-backend",
"depends": [
"base",
],
"demo": [
"demo/dav_collection.xml",
],
"data": [
"views/dav_collection.xml",
"security/ir.model.access.csv",
],
"external_dependencies": {
"python": ["radicale"],
},
}
3 changes: 3 additions & 0 deletions base_dav/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import main
66 changes: 66 additions & 0 deletions base_dav/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

import logging
from configparser import RawConfigParser as ConfigParser

import werkzeug

from odoo import http
from odoo.http import request

try:
import radicale
except ImportError:
radicale = None

Check warning on line 15 in base_dav/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_dav/controllers/main.py#L14-L15

Added lines #L14 - L15 were not covered by tests

PREFIX = "/.dav"


class Main(http.Controller):
@http.route(
["/.well-known/carddav", "/.well-known/caldav", "/.well-known/webdav"],
type="http",
auth="none",
csrf=False,
)
def handle_well_known_request(self):
return werkzeug.utils.redirect(PREFIX, 301)

Check warning on line 28 in base_dav/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_dav/controllers/main.py#L28

Added line #L28 was not covered by tests

@http.route(
[PREFIX, "%s/<path:davpath>" % PREFIX],
type="http",
auth="none",
csrf=False,
)
def handle_dav_request(self, davpath=None):
config = ConfigParser()

Check warning on line 37 in base_dav/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_dav/controllers/main.py#L37

Added line #L37 was not covered by tests
for section, values in radicale.config.INITIAL_CONFIG.items():
config.add_section(section)

Check warning on line 39 in base_dav/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_dav/controllers/main.py#L39

Added line #L39 was not covered by tests
for key, data in values.items():
config.set(section, key, data["value"])
config.set("auth", "type", "odoo.addons.base_dav.radicale.auth")
config.set("storage", "type", "odoo.addons.base_dav.radicale.collection")
config.set("rights", "type", "odoo.addons.base_dav.radicale.rights")
config.set("web", "type", "none")
application = radicale.Application(

Check warning on line 46 in base_dav/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_dav/controllers/main.py#L41-L46

Added lines #L41 - L46 were not covered by tests
config,
logging.getLogger("radicale"),
)

response = None

Check warning on line 51 in base_dav/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_dav/controllers/main.py#L51

Added line #L51 was not covered by tests

def start_response(status, headers):

Check warning on line 53 in base_dav/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_dav/controllers/main.py#L53

Added line #L53 was not covered by tests
nonlocal response
response = http.Response(status=status, headers=headers)

Check warning on line 55 in base_dav/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_dav/controllers/main.py#L55

Added line #L55 was not covered by tests

result = application(

Check warning on line 57 in base_dav/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_dav/controllers/main.py#L57

Added line #L57 was not covered by tests
dict(
request.httprequest.environ,
HTTP_X_SCRIPT_NAME=PREFIX,
PATH_INFO=davpath or "",
),
start_response,
)
response.stream.write(result and result[0] or b"")
return response

Check warning on line 66 in base_dav/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_dav/controllers/main.py#L65-L66

Added lines #L65 - L66 were not covered by tests
34 changes: 34 additions & 0 deletions base_dav/demo/dav_collection.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="collection_addressbook" model="dav.collection">
<field name="name">Addressbook</field>
<field name="dav_type">addressbook</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="domain">[]</field>
</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="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="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="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="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="collection_id" ref="collection_addressbook" />
</record>
</odoo>
Loading
Loading