mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[ADD] base_ical
This commit is contained in:
committed by
fkantelberg
parent
35dbc22d7e
commit
1e6b6ceda7
130
base_ical/README.rst
Normal file
130
base_ical/README.rst
Normal file
@@ -0,0 +1,130 @@
|
||||
================================
|
||||
Readonly publishing of calendars
|
||||
================================
|
||||
|
||||
..
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:f98a0b075e11b8bf4075af16bbe8ba8b249d03f4b675874d232c68a897235579
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Alpha
|
||||
.. |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/15.0/base_ical
|
||||
: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-15-0/server-backend-15-0-base_ical
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-backend&target_branch=15.0
|
||||
:alt: Try me on Runboat
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module allows administrators to configure iCalendars based on an arbitrary selection on arbitrary models.
|
||||
|
||||
Users can selectively subscribe to them by enabling them in their profile form.
|
||||
|
||||
This is useful for exposing Odoo data to calendaring application like Nextcloud.
|
||||
|
||||
.. IMPORTANT::
|
||||
This is an alpha version, the data model and design can change at any time without warning.
|
||||
Only for development or testing purpose, do not use in production.
|
||||
`More details on development status <https://odoo-community.org/page/development-status>`_
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
To configure this module, you need to:
|
||||
|
||||
#. Go to Settings/Technical/iCalendars
|
||||
#. Create a calendar, fill in the model you want to expose and possibly a domain to restrict records. You can use the ``user`` variable to restrict things relative to the user using the calendar
|
||||
#. A few iCalendar-fields have defaults that should work for any model, you'll have to fill in expressions manually though for the start and end date of the records.
|
||||
|
||||
For example, for model ``calendar.event``, you'd fill in ``record.allday and record.start_date or record.start`` as `DTSTART` and ``record.allday and record.stop_date or record.stop`` as `DTEND`.
|
||||
|
||||
For model ``hr.leave``, you'd write ``(record.request_unit_half or record.request_unit_hours) and record.date_from or record.date_from.date()`` for `DTSTART` and ``(record.request_unit_half or record.request_unit_hours) and record.date_to or (record.date_to.date() + timedelta(days=1))`` for `DTEND` - this is a bit more complex because of the way Odoo handles the begin and end times of leaves, and you'll want the extra day as most clients interpret the end date as non-inclusive.
|
||||
#. Existing calendars are available for users in the tab `Calendars` of their profile form, where they can enable them to obtain a link they can paste into whatever client they are going to use
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To use this module, you need to:
|
||||
|
||||
#. Go to your profile form
|
||||
#. Click `Enable` on one of the calendars listed in tab `Calendars`
|
||||
#. Copy the URL to the application you use
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* support all of https://datatracker.ietf.org/doc/html/rfc5545#section-3.8
|
||||
* allow users to define their own calendars
|
||||
|
||||
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 to smash it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_ical%0Aversion:%2015.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
|
||||
~~~~~~~
|
||||
|
||||
* Hunki Enterprises BV
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Holger Brunn <mail@hunki-enterprises.com> (https://hunki-enterprises.com)
|
||||
|
||||
Other credits
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
|
||||
* Company 1 name
|
||||
* Company 2 name
|
||||
|
||||
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.
|
||||
|
||||
.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px
|
||||
:target: https://github.com/hbrunn
|
||||
:alt: hbrunn
|
||||
|
||||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
||||
|
||||
|maintainer-hbrunn|
|
||||
|
||||
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/15.0/base_ical>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
2
base_ical/__init__.py
Normal file
2
base_ical/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import models
|
||||
from . import controllers
|
||||
29
base_ical/__manifest__.py
Normal file
29
base_ical/__manifest__.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Copyright 2023 Hunki Enterprises BV
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
|
||||
|
||||
{
|
||||
"name": "Readonly publishing of calendars",
|
||||
"summary": "Provide (readonly) .ics URLs to calendar-like models",
|
||||
"version": "15.0.1.0.0",
|
||||
"development_status": "Alpha",
|
||||
"category": "Tools",
|
||||
"website": "https://github.com/OCA/server-backend",
|
||||
"author": "Hunki Enterprises BV, Odoo Community Association (OCA)",
|
||||
"maintainers": ["hbrunn"],
|
||||
"license": "AGPL-3",
|
||||
"external_dependencies": {
|
||||
"python": ["vobject"],
|
||||
},
|
||||
"depends": [
|
||||
"web",
|
||||
],
|
||||
"data": [
|
||||
"security/base_ical.xml",
|
||||
"security/ir.model.access.csv",
|
||||
"views/base_ical.xml",
|
||||
"views/res_users.xml",
|
||||
],
|
||||
"demo": [
|
||||
"demo/base_ical.xml",
|
||||
],
|
||||
}
|
||||
1
base_ical/controllers/__init__.py
Normal file
1
base_ical/controllers/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import main
|
||||
27
base_ical/controllers/main.py
Normal file
27
base_ical/controllers/main.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright 2023 Hunki Enterprises BV
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
|
||||
|
||||
|
||||
from odoo import http
|
||||
|
||||
|
||||
class MyController(http.Controller):
|
||||
@http.route(
|
||||
"/base_ical/<string:token>",
|
||||
auth="public",
|
||||
csrf=False,
|
||||
methods=["GET"],
|
||||
type="http",
|
||||
)
|
||||
def get_ical(self, token):
|
||||
# TODO: respect if-modified-since headers
|
||||
token = (
|
||||
http.request.env["base.ical.token"].sudo().search([("token", "=", token)])
|
||||
)
|
||||
if not token:
|
||||
return http.request.not_found()
|
||||
response = http.request.make_response(
|
||||
token.ical_id.with_user(token.user_id)._get_ical(),
|
||||
headers={"content-type": "text/calendar"},
|
||||
)
|
||||
return response
|
||||
12
base_ical/demo/base_ical.xml
Normal file
12
base_ical/demo/base_ical.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2023 Hunki Enterprises BV
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
|
||||
<data>
|
||||
<record id="demo_calendar" model="base.ical">
|
||||
<field name="name">Demo calendar</field>
|
||||
<field name="model_id" ref="base.model_res_users" />
|
||||
<field name="expression_uid">str(record.id)</field>
|
||||
<field name="expression_dtstart">record.create_date</field>
|
||||
<field name="expression_dtend">record.write_date</field>
|
||||
</record>
|
||||
</data>
|
||||
0
base_ical/i18n/.empty
Normal file
0
base_ical/i18n/.empty
Normal file
3
base_ical/models/__init__.py
Normal file
3
base_ical/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from . import res_users
|
||||
from . import base_ical
|
||||
from . import base_ical_token
|
||||
226
base_ical/models/base_ical.py
Normal file
226
base_ical/models/base_ical.py
Normal file
@@ -0,0 +1,226 @@
|
||||
# Copyright 2023 Hunki Enterprises BV
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
|
||||
|
||||
|
||||
import datetime
|
||||
from urllib.parse import urlparse, urlunparse
|
||||
|
||||
import pytz
|
||||
import vobject
|
||||
from dateutil import relativedelta
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
|
||||
|
||||
class BaseIcal(models.Model):
|
||||
_name = "base.ical"
|
||||
_description = "Definition of an iCal export"
|
||||
|
||||
active = fields.Boolean(default=True)
|
||||
name = fields.Char(required=True, translate=True)
|
||||
model_id = fields.Many2one("ir.model", required=True, ondelete="cascade")
|
||||
model = fields.Char(related="model_id.model")
|
||||
domain = fields.Char(
|
||||
required=True, default="[]", help="You can use variables `env` and `user` here"
|
||||
)
|
||||
preview = fields.Text(compute="_compute_preview")
|
||||
expression_dtstamp = fields.Char(
|
||||
required=True,
|
||||
vevent_field="dtstamp",
|
||||
string="DTSTAMP",
|
||||
help="You can use variables `record` and `user` here",
|
||||
default="record.write_date",
|
||||
)
|
||||
expression_uid = fields.Char(
|
||||
required=True,
|
||||
vevent_field="uid",
|
||||
string="UID",
|
||||
help="You can use variables `record` and `user` here",
|
||||
)
|
||||
expression_dtstart = fields.Char(
|
||||
required=True,
|
||||
vevent_field="dtstart",
|
||||
string="DTSTART",
|
||||
help="You can use variables `record` and `user` here",
|
||||
)
|
||||
expression_dtend = fields.Char(
|
||||
required=True,
|
||||
vevent_field="dtend",
|
||||
string="DTEND",
|
||||
help="You can use variables `record` and `user` here",
|
||||
)
|
||||
expression_summary = fields.Char(
|
||||
required=True,
|
||||
vevent_field="summary",
|
||||
string="SUMMARY",
|
||||
help="You can use variables `record` and `user` here",
|
||||
default="record.display_name",
|
||||
)
|
||||
user_url = fields.Char(compute="_compute_user_fields", string="URL")
|
||||
user_active = fields.Boolean(compute="_compute_user_fields")
|
||||
auto = fields.Boolean(
|
||||
"Enable automatically",
|
||||
help="If you check this, the calendar will be enabled for all current and "
|
||||
"future users. Not that unchecking this will not disable existing calendar "
|
||||
"subscriptions",
|
||||
)
|
||||
|
||||
def _valid_field_parameter(self, field, name):
|
||||
return super()._valid_field_parameter(field, name) or name == "vevent_field"
|
||||
|
||||
@api.depends(
|
||||
"model_id",
|
||||
"domain",
|
||||
"expression_dtstamp",
|
||||
"expression_uid",
|
||||
"expression_dtstart",
|
||||
"expression_dtend",
|
||||
"expression_summary",
|
||||
)
|
||||
def _compute_preview(self):
|
||||
for this in self:
|
||||
this.preview = this._get_ical()
|
||||
|
||||
def _compute_user_fields(self):
|
||||
base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url")
|
||||
for this in self:
|
||||
token = this._get_user_tokens()[:1]
|
||||
vals = {"user_url": False, "user_active": False}
|
||||
if token:
|
||||
vals.update(
|
||||
user_url=urlunparse(
|
||||
urlparse(base_url)._replace(path="/base_ical/%s" % token.token)
|
||||
),
|
||||
user_active=token.active,
|
||||
)
|
||||
this.update(vals)
|
||||
|
||||
@api.onchange("model_id")
|
||||
def _onchange_model_id(self):
|
||||
for field_name, field in self._fields.items():
|
||||
if hasattr(field, "vevent_field"):
|
||||
self[field_name] = False
|
||||
self.update(
|
||||
self.default_get(["domain", "expression_dtstamp", "expression_summary"])
|
||||
)
|
||||
base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url")
|
||||
self.expression_uid = "'%%s-%s@%s' %% record.id" % (
|
||||
self.env.cr.dbname,
|
||||
urlparse(base_url).hostname,
|
||||
)
|
||||
|
||||
@api.constrains(
|
||||
"domain",
|
||||
"expression_dtstamp",
|
||||
"expression_uid",
|
||||
"expression_dtstart",
|
||||
"expression_dtend",
|
||||
"expression_summary",
|
||||
)
|
||||
def _check_domain(self):
|
||||
for this in self:
|
||||
this._get_ical()
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
"""Enable calendar for all users if auto flag is checked"""
|
||||
result = super().create(vals_list)
|
||||
result.filtered("auto")._enable_all_users()
|
||||
return result
|
||||
|
||||
def write(self, vals):
|
||||
"""Enable calendar for all users if auto flag is checked"""
|
||||
result = super().write(vals)
|
||||
if vals.get("auto"):
|
||||
self._enable_all_users()
|
||||
return result
|
||||
|
||||
def _get_user_tokens(self):
|
||||
return (
|
||||
self.env["base.ical.token"]
|
||||
.with_context(active_test=False)
|
||||
.search(
|
||||
[
|
||||
("user_id", "=", self.env.user.id),
|
||||
("ical_id", "in", self.ids),
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
def _get_eval_expression_context(self, record):
|
||||
"""Return the evaluation context for expression evaluation"""
|
||||
return {
|
||||
"record": record,
|
||||
"user": self.env.user,
|
||||
"timedelta": datetime.timedelta,
|
||||
"relativedelta": relativedelta.relativedelta,
|
||||
}
|
||||
|
||||
def _get_eval_domain_context(self):
|
||||
"""Return the evaluation context for domain evaluation"""
|
||||
return {
|
||||
"user": self.env.user,
|
||||
"env": self.env,
|
||||
}
|
||||
|
||||
def _get_events(self):
|
||||
"""Return events based on model_id and domain"""
|
||||
self.ensure_one()
|
||||
return self.env[self.model_id.sudo().model].search(
|
||||
safe_eval(self.domain, self._get_eval_domain_context())
|
||||
)
|
||||
|
||||
def _get_ical(self):
|
||||
"""Return the vcalendar as text"""
|
||||
if not all(
|
||||
self[field_name]
|
||||
for field_name, field in self._fields.items()
|
||||
if hasattr(field, "vevent_field") and field.required
|
||||
):
|
||||
return False
|
||||
calendar = vobject.iCalendar()
|
||||
for record in self._get_events():
|
||||
event = calendar.add("vevent")
|
||||
for field_name, field in self._fields.items():
|
||||
if not hasattr(field, "vevent_field"):
|
||||
continue
|
||||
value = safe_eval(
|
||||
self[field_name], self._get_eval_expression_context(record)
|
||||
)
|
||||
event.add(field.vevent_field).value = self._format_ical_value(
|
||||
field, value
|
||||
)
|
||||
return calendar.serialize()
|
||||
|
||||
def _format_ical_value(self, field, value):
|
||||
"""Add timezone to datetime values"""
|
||||
if isinstance(value, datetime.datetime):
|
||||
return pytz.utc.localize(value).astimezone(
|
||||
pytz.timezone(self.env.user.tz or "UTC")
|
||||
)
|
||||
return value
|
||||
|
||||
def _enable_all_users(self, users=None):
|
||||
"""Enable calendar for all users"""
|
||||
for this in self:
|
||||
for user in users or self.env["res.users"].search(
|
||||
[("groups_id", "=", self.env.ref("base.group_user").id)]
|
||||
):
|
||||
this.with_user(user).action_enable()
|
||||
|
||||
def action_enable(self):
|
||||
"""Create or activate current user's token"""
|
||||
token = self._get_user_tokens()[:1]
|
||||
if token and not token.active:
|
||||
token.active = True
|
||||
elif not token:
|
||||
self.env["base.ical.token"].create(
|
||||
{"ical_id": self.id, "user_id": self.env.user.id}
|
||||
)
|
||||
|
||||
def action_disable(self):
|
||||
"""Deactivate current user's token"""
|
||||
token = self._get_user_tokens()[:1]
|
||||
if token and token.active:
|
||||
token.active = False
|
||||
22
base_ical/models/base_ical_token.py
Normal file
22
base_ical/models/base_ical_token.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Copyright 2023 Hunki Enterprises BV
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
|
||||
|
||||
|
||||
import secrets
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class BaseIcalToken(models.Model):
|
||||
_name = "base.ical.token"
|
||||
_description = "User token of an iCal export"
|
||||
_rec_name = "ical_id"
|
||||
|
||||
active = fields.Boolean(default=True)
|
||||
ical_id = fields.Many2one("base.ical", required=True, ondelete="cascade")
|
||||
user_id = fields.Many2one("res.users", required=True, ondelete="cascade")
|
||||
token = fields.Char(required=True, default=lambda self: secrets.token_urlsafe())
|
||||
|
||||
_sql_constraints = [
|
||||
("token_uniqe", "unique(token)", "The token must be unique"),
|
||||
]
|
||||
26
base_ical/models/res_users.py
Normal file
26
base_ical/models/res_users.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright 2023 Hunki Enterprises BV
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
|
||||
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = "res.users"
|
||||
|
||||
ical_ids = fields.One2many("base.ical", compute="_compute_ical_ids")
|
||||
ical_token_ids = fields.One2many("base.ical.token", "user_id")
|
||||
|
||||
def _compute_ical_ids(self):
|
||||
for this in self:
|
||||
this.ical_ids = self.env["base.ical"].search([])
|
||||
|
||||
@property
|
||||
def SELF_READABLE_FIELDS(self):
|
||||
return super().SELF_READABLE_FIELDS + ["ical_ids"]
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
result = super().create(vals_list)
|
||||
self.env["base.ical"].search([("auto", "=", True)])._enable_all_users(result)
|
||||
return result
|
||||
10
base_ical/readme/CONFIGURE.rst
Normal file
10
base_ical/readme/CONFIGURE.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
To configure this module, you need to:
|
||||
|
||||
#. Go to Settings/Technical/iCalendars
|
||||
#. Create a calendar, fill in the model you want to expose and possibly a domain to restrict records. You can use the ``user`` variable to restrict things relative to the user using the calendar
|
||||
#. A few iCalendar-fields have defaults that should work for any model, you'll have to fill in expressions manually though for the start and end date of the records.
|
||||
|
||||
For example, for model ``calendar.event``, you'd fill in ``record.allday and record.start_date or record.start`` as `DTSTART` and ``record.allday and record.stop_date or record.stop`` as `DTEND`.
|
||||
|
||||
For model ``hr.leave``, you'd write ``(record.request_unit_half or record.request_unit_hours) and record.date_from or record.date_from.date()`` for `DTSTART` and ``(record.request_unit_half or record.request_unit_hours) and record.date_to or (record.date_to.date() + timedelta(days=1))`` for `DTEND` - this is a bit more complex because of the way Odoo handles the begin and end times of leaves, and you'll want the extra day as most clients interpret the end date as non-inclusive.
|
||||
#. Existing calendars are available for users in the tab `Calendars` of their profile form, where they can enable them to obtain a link they can paste into whatever client they are going to use
|
||||
1
base_ical/readme/CONTRIBUTORS.rst
Normal file
1
base_ical/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1 @@
|
||||
* Holger Brunn <mail@hunki-enterprises.com> (https://hunki-enterprises.com)
|
||||
4
base_ical/readme/CREDITS.rst
Normal file
4
base_ical/readme/CREDITS.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
The development of this module has been financially supported by:
|
||||
|
||||
* Company 1 name
|
||||
* Company 2 name
|
||||
5
base_ical/readme/DESCRIPTION.rst
Normal file
5
base_ical/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
This module allows administrators to configure iCalendars based on an arbitrary selection on arbitrary models.
|
||||
|
||||
Users can selectively subscribe to them by enabling them in their profile form.
|
||||
|
||||
This is useful for exposing Odoo data to calendaring application like Nextcloud.
|
||||
2
base_ical/readme/ROADMAP.rst
Normal file
2
base_ical/readme/ROADMAP.rst
Normal file
@@ -0,0 +1,2 @@
|
||||
* support all of https://datatracker.ietf.org/doc/html/rfc5545#section-3.8
|
||||
* allow users to define their own calendars
|
||||
5
base_ical/readme/USAGE.rst
Normal file
5
base_ical/readme/USAGE.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
To use this module, you need to:
|
||||
|
||||
#. Go to your profile form
|
||||
#. Click `Enable` on one of the calendars listed in tab `Calendars`
|
||||
#. Copy the URL to the application you use
|
||||
25
base_ical/security/base_ical.xml
Normal file
25
base_ical/security/base_ical.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2023 Hunki Enterprises BV
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
|
||||
<data>
|
||||
<record id="rule_base_ical_token" model="ir.rule">
|
||||
<field name="name">Ical export tokens</field>
|
||||
<field name="model_id" ref="model_base_ical_token" />
|
||||
<field name="groups" eval="[(4, ref('base.group_user'))]" />
|
||||
<field name="perm_create" eval="True" />
|
||||
<field name="perm_read" eval="True" />
|
||||
<field name="perm_write" eval="True" />
|
||||
<field name="perm_unlink" eval="True" />
|
||||
<field name="domain_force">[('user_id', '=', user.id)]</field>
|
||||
</record>
|
||||
<record id="rule_base_ical_token_admin" model="ir.rule">
|
||||
<field name="name">Ical export tokens</field>
|
||||
<field name="model_id" ref="model_base_ical_token" />
|
||||
<field name="groups" eval="[(4, ref('base.group_system'))]" />
|
||||
<field name="perm_create" eval="True" />
|
||||
<field name="perm_read" eval="True" />
|
||||
<field name="perm_write" eval="True" />
|
||||
<field name="perm_unlink" eval="True" />
|
||||
<field name="domain_force">[(1, '=', 1)]</field>
|
||||
</record>
|
||||
</data>
|
||||
4
base_ical/security/ir.model.access.csv
Normal file
4
base_ical/security/ir.model.access.csv
Normal file
@@ -0,0 +1,4 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_base_ical,access_base_ical,model_base_ical,base.group_user,1,0,0,0
|
||||
modify_base_ical,modify_base_ical,model_base_ical,base.group_system,1,1,1,1
|
||||
modify_base_ical_token,modify_base_ical_token,model_base_ical_token,base.group_user,1,1,1,1
|
||||
|
BIN
base_ical/static/description/icon.png
Normal file
BIN
base_ical/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
475
base_ical/static/description/index.html
Normal file
475
base_ical/static/description/index.html
Normal file
@@ -0,0 +1,475 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<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: http://docutils.sourceforge.net/" />
|
||||
<title>Readonly publishing of calendars</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
|
||||
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
/* used to remove borders from tables and images */
|
||||
.borderless, table.borderless td, table.borderless th {
|
||||
border: 0 }
|
||||
|
||||
table.borderless td, table.borderless th {
|
||||
/* Override padding for "table.docutils td" with "! important".
|
||||
The right padding separates the table cells. */
|
||||
padding: 0 0.5em 0 0 ! important }
|
||||
|
||||
.first {
|
||||
/* Override more specific margin styles with "! important". */
|
||||
margin-top: 0 ! important }
|
||||
|
||||
.last, .with-subtitle {
|
||||
margin-bottom: 0 ! important }
|
||||
|
||||
.hidden {
|
||||
display: none }
|
||||
|
||||
.subscript {
|
||||
vertical-align: sub;
|
||||
font-size: smaller }
|
||||
|
||||
.superscript {
|
||||
vertical-align: super;
|
||||
font-size: smaller }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
blockquote.epigraph {
|
||||
margin: 2em 5em ; }
|
||||
|
||||
dl.docutils dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
*/
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||
div.hint, div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title, .code .error {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||
compound paragraphs.
|
||||
div.compound .compound-first, div.compound .compound-middle {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.compound .compound-last, div.compound .compound-middle {
|
||||
margin-top: 0.5em }
|
||||
*/
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
clear: both;
|
||||
font-size: smaller }
|
||||
|
||||
div.line-block {
|
||||
display: block ;
|
||||
margin-top: 1em ;
|
||||
margin-bottom: 1em }
|
||||
|
||||
div.line-block div.line-block {
|
||||
margin-top: 0 ;
|
||||
margin-bottom: 0 ;
|
||||
margin-left: 1.5em }
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em ;
|
||||
border: medium outset ;
|
||||
padding: 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||
margin-top: 0.4em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr.docutils {
|
||||
width: 75% }
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||
clear: left ;
|
||||
float: left ;
|
||||
margin-right: 1em }
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||
clear: right ;
|
||||
float: right ;
|
||||
margin-left: 1em }
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left }
|
||||
|
||||
.align-center {
|
||||
clear: both ;
|
||||
text-align: center }
|
||||
|
||||
.align-right {
|
||||
text-align: right }
|
||||
|
||||
/* reset inner alignment in figures */
|
||||
div.align-right {
|
||||
text-align: inherit }
|
||||
|
||||
/* div.align-center * { */
|
||||
/* text-align: left } */
|
||||
|
||||
.align-top {
|
||||
vertical-align: top }
|
||||
|
||||
.align-middle {
|
||||
vertical-align: middle }
|
||||
|
||||
.align-bottom {
|
||||
vertical-align: bottom }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font: inherit }
|
||||
|
||||
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: grey; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
/* font-size relative to parent (h1..h6 element) */
|
||||
font-size: 80% }
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.docutils {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid 1px black;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docutils td, table.docutils th,
|
||||
table.docinfo td, table.docinfo th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap ;
|
||||
padding-left: 0 }
|
||||
|
||||
/* "booktabs" style (no vertical lines) */
|
||||
table.docutils.booktabs {
|
||||
border: 0px;
|
||||
border-top: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.docutils.booktabs * {
|
||||
border: 0px;
|
||||
}
|
||||
table.docutils.booktabs th {
|
||||
border-bottom: thin solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||
font-size: 100% }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="readonly-publishing-of-calendars">
|
||||
<h1 class="title">Readonly publishing of calendars</h1>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:08b4b5a2737a01f894ac4e4e5382694dcd87bf6e5ac5bb46ca91df22d8d8e51a
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.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/15.0/base_ical"><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-15-0/server-backend-15-0-base_ical"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/server-backend&target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module allows administrators to configure iCalendars based on an arbitrary selection on arbitrary models.</p>
|
||||
<p>Users can selectively subscribe to them by enabling them in their profile form.</p>
|
||||
<p>This is useful for exposing Odoo data to calendaring application like Nextcloud.</p>
|
||||
<div class="admonition important">
|
||||
<p class="first admonition-title">Important</p>
|
||||
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
|
||||
Only for development or testing purpose, do not use in production.
|
||||
<a class="reference external" href="https://odoo-community.org/page/development-status">More details on development status</a></p>
|
||||
</div>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
|
||||
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
|
||||
<li><a class="reference internal" href="#known-issues-roadmap" id="id3">Known issues / Roadmap</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id5">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id6">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id7">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#other-credits" id="id8">Other credits</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id9">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="configuration">
|
||||
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
|
||||
<p>To configure this module, you need to:</p>
|
||||
<ol class="arabic">
|
||||
<li><p class="first">Go to Settings/Technical/iCalendars</p>
|
||||
</li>
|
||||
<li><p class="first">Create a calendar, fill in the model you want to expose and possibly a domain to restrict records. You can use the <tt class="docutils literal">user</tt> variable to restrict things relative to the user using the calendar</p>
|
||||
</li>
|
||||
<li><p class="first">A few iCalendar-fields have defaults that should work for any model, you’ll have to fill in expressions manually though for the start and end date of the records.</p>
|
||||
<p>For example, for model <tt class="docutils literal">calendar.event</tt>, you’d fill in <tt class="docutils literal">record.allday and record.start_date or record.start</tt> as <cite>DTSTART</cite> and <tt class="docutils literal">record.allday and record.stop_date or record.stop</tt> as <cite>DTEND</cite>.</p>
|
||||
<p>For model <tt class="docutils literal">hr.leave</tt>, you’d write <tt class="docutils literal">(record.request_unit_half or record.request_unit_hours) and record.date_from or record.date_from.date()</tt> for <cite>DTSTART</cite> and <tt class="docutils literal">(record.request_unit_half or record.request_unit_hours) and record.date_to or (record.date_to.date() + timedelta(days=1))</tt> for <cite>DTEND</cite> - this is a bit more complex because of the way Odoo handles the begin and end times of leaves, and you’ll want the extra day as most clients interpret the end date as non-inclusive.</p>
|
||||
</li>
|
||||
<li><p class="first">Existing calendars are available for users in the tab <cite>Calendars</cite> of their profile form, where they can enable them to obtain a link they can paste into whatever client they are going to use</p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
|
||||
<p>To use this module, you need to:</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Go to your profile form</li>
|
||||
<li>Click <cite>Enable</cite> on one of the calendars listed in tab <cite>Calendars</cite></li>
|
||||
<li>Copy the URL to the application you use</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="known-issues-roadmap">
|
||||
<h1><a class="toc-backref" href="#id3">Known issues / Roadmap</a></h1>
|
||||
<ul class="simple">
|
||||
<li>support all of <a class="reference external" href="https://datatracker.ietf.org/doc/html/rfc5545#section-3.8">https://datatracker.ietf.org/doc/html/rfc5545#section-3.8</a></li>
|
||||
<li>allow users to define their own calendars</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#id4">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 to smash it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/server-backend/issues/new?body=module:%20base_ical%0Aversion:%2015.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">
|
||||
<h1><a class="toc-backref" href="#id5">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#id6">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Hunki Enterprises BV</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id7">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Holger Brunn <<a class="reference external" href="mailto:mail@hunki-enterprises.com">mail@hunki-enterprises.com</a>> (<a class="reference external" href="https://hunki-enterprises.com">https://hunki-enterprises.com</a>)</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="other-credits">
|
||||
<h2><a class="toc-backref" href="#id8">Other credits</a></h2>
|
||||
<p>The development of this module has been financially supported by:</p>
|
||||
<ul class="simple">
|
||||
<li>Company 1 name</li>
|
||||
<li>Company 2 name</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#id9">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<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>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||
<p><a class="reference external" href="https://github.com/hbrunn"><img alt="hbrunn" src="https://github.com/hbrunn.png?size=40px" /></a></p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-backend/tree/15.0/base_ical">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>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
1
base_ical/tests/__init__.py
Normal file
1
base_ical/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_base_ical
|
||||
54
base_ical/tests/test_base_ical.py
Normal file
54
base_ical/tests/test_base_ical.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# Copyright 2023 Hunki Enterprises BV
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
|
||||
|
||||
|
||||
from odoo.tests.common import Form, TransactionCase
|
||||
|
||||
|
||||
class TestBaseIcal(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.calendar = cls.env.ref("base_ical.demo_calendar")
|
||||
|
||||
def test_profile(self):
|
||||
"""Test url generation"""
|
||||
user = self.env.ref("base.user_demo")
|
||||
token_domain = [
|
||||
("user_id", "=", user.id),
|
||||
("ical_id", "=", self.calendar.id),
|
||||
]
|
||||
token_search = (
|
||||
self.env["base.ical.token"].with_context(active_test=False).search
|
||||
)
|
||||
self.assertFalse(token_search(token_domain))
|
||||
self.assertFalse(self.calendar.with_user(user).user_active)
|
||||
self.calendar.with_user(user).action_enable()
|
||||
token = token_search(token_domain)
|
||||
self.assertTrue(token.active)
|
||||
self.calendar.invalidate_cache()
|
||||
self.assertTrue(self.calendar.with_user(user).user_active)
|
||||
self.calendar.with_user(user).action_disable()
|
||||
self.calendar.invalidate_cache()
|
||||
self.assertFalse(self.calendar.with_user(user).user_active)
|
||||
|
||||
def test_config(self):
|
||||
"""Configure calendar"""
|
||||
with Form(self.calendar) as calendar_form:
|
||||
calendar_form.model_id = self.env.ref("base.model_res_partner")
|
||||
self.assertFalse(calendar_form.expression_dtstart)
|
||||
self.assertFalse(calendar_form.preview)
|
||||
calendar_form.expression_dtstart = "record.create_date"
|
||||
calendar_form.expression_dtend = "record.write_date"
|
||||
self.assertTrue(calendar_form.preview)
|
||||
|
||||
def test_auto_flag(self):
|
||||
"""Test the auto flag is honored"""
|
||||
user = self.env.ref("base.user_demo")
|
||||
self.assertFalse(user.ical_token_ids)
|
||||
self.calendar.auto = True
|
||||
self.assertTrue(user.ical_token_ids)
|
||||
self.calendar.copy()
|
||||
self.assertEqual(len(user.ical_token_ids), 2)
|
||||
new_user = user.copy()
|
||||
self.assertEqual(len(new_user.ical_token_ids), 2)
|
||||
52
base_ical/views/base_ical.xml
Normal file
52
base_ical/views/base_ical.xml
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2023 Hunki Enterprises BV
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
|
||||
<data>
|
||||
<record id="view_base_ical_form" model="ir.ui.view">
|
||||
<field name="model">base.ical</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<label class="oe_edit_only" for="name" />
|
||||
<h1><field name="name" /></h1>
|
||||
<group>
|
||||
<group name="main">
|
||||
<field name="model_id" />
|
||||
<field name="model" invisible="True" />
|
||||
<field
|
||||
name="domain"
|
||||
placeholder="[('user_id', '=', user.id)]"
|
||||
/>
|
||||
<field name="auto" />
|
||||
</group>
|
||||
<group name="fields">
|
||||
<field name="expression_dtstamp" />
|
||||
<field name="expression_uid" />
|
||||
<field name="expression_dtstart" />
|
||||
<field name="expression_dtend" />
|
||||
<field name="expression_summary" />
|
||||
</group>
|
||||
</group>
|
||||
<field name="preview" widget="ace" groups="base.group_no_one" />
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_base_ical_tree" model="ir.ui.view">
|
||||
<field name="model">base.ical</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="name" />
|
||||
<field name="model_id" />
|
||||
<field name="domain" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_base_ical" model="ir.actions.act_window">
|
||||
<field name="name">iCalendars</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">base.ical</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem id="menu_ical" parent="base.menu_custom" action="action_base_ical" />
|
||||
</data>
|
||||
38
base_ical/views/res_users.xml
Normal file
38
base_ical/views/res_users.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2023 Hunki Enterprises BV
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
|
||||
<data>
|
||||
<record id="view_res_users_form" model="ir.ui.view">
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="inside">
|
||||
<page name="base_ical" string="Calendars">
|
||||
<field name="ical_ids">
|
||||
<tree>
|
||||
<button
|
||||
type="object"
|
||||
name="action_enable"
|
||||
attrs="{'invisible': [('user_active', '=', True)]}"
|
||||
string="Enable"
|
||||
/>
|
||||
<button
|
||||
type="object"
|
||||
name="action_disable"
|
||||
attrs="{'invisible': [('user_active', '=', False)]}"
|
||||
string="Disable"
|
||||
/>
|
||||
<field name="name" />
|
||||
<field name="user_active" invisible="1" />
|
||||
<field
|
||||
name="user_url"
|
||||
attrs="{'invisible': [('user_active', '=', False)]}"
|
||||
widget="url"
|
||||
/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
@@ -4,3 +4,4 @@ mysqlclient
|
||||
pymssql<=2.2.5
|
||||
sqlalchemy
|
||||
sqlalchemy-hana
|
||||
vobject
|
||||
|
||||
1
setup/base_ical/odoo/addons/base_ical
Symbolic link
1
setup/base_ical/odoo/addons/base_ical
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../base_ical
|
||||
6
setup/base_ical/setup.py
Normal file
6
setup/base_ical/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user