mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[IMP] base_ical: Allow advanced snippets. Use apikeys with scope.
This commit is contained in:
@@ -1,10 +1,42 @@
|
||||
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.
|
||||
#. Create a iCalendar, 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 iCalendar
|
||||
#. A iCalendar is only available to the allowed users. Use the `Allow automatically` to make the iCalendar available to all users
|
||||
#. See the examples below for a start
|
||||
|
||||
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`.
|
||||
Examples
|
||||
~~~~~~~~
|
||||
|
||||
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
|
||||
Simple 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`.
|
||||
|
||||
Advanced example, for model ``calendar.event``, you'd use ``calendar = record._get_ics_file()`` in the code.
|
||||
|
||||
Advanced example, for model ``hr.leave``, you can use the following code and ``[("employee_id.user_id", "=", user.id)]`` in the `domain` to export the own time offs. 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.:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
confirmed = ("validate", "validate1")
|
||||
if record.request_unit_half or record.request_unit_hours:
|
||||
event = {
|
||||
"dtstart": event["dtstart"].date(),
|
||||
"dtend": event["dtend"].date() + timedelta(days=1),
|
||||
}
|
||||
else:
|
||||
event = {
|
||||
"dtstart": record.date_from,
|
||||
"dtend": record.date_to,
|
||||
}
|
||||
|
||||
event["summary"] = record.name
|
||||
event["status"] = "CONFIRMED" if record.state in confirmed else "TENTATIVE"
|
||||
|
||||
Advanced example, for model ``mail.activity``, you can use the following code and ``[("user_id", "=", user.id)]`` and `domain` to export all user activities.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
todo = {
|
||||
"summary": record.display_name,
|
||||
"due": record.date_deadline,
|
||||
"description": html2plaintext(record.note) if record.note else ""
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
* Holger Brunn <mail@hunki-enterprises.com> (https://hunki-enterprises.com)
|
||||
* Florian Kantelberg <florian.kantelberg@initos.com> (https://www.initos.com)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
The development of this module has been financially supported by:
|
||||
|
||||
* Company 1 name
|
||||
* Company 2 name
|
||||
Reference in New Issue
Block a user