3
0
Fork 0

Merge PR #1557 into 13.0

Signed-off-by pedrobaeza
13.0
OCA-git-bot 2020-04-17 07:27:16 +00:00
commit c73870e5bf
33 changed files with 4820 additions and 3 deletions

View File

@ -9,4 +9,4 @@ line_length=88
known_odoo=odoo known_odoo=odoo
known_odoo_addons=odoo.addons known_odoo_addons=odoo.addons
sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER
default_section=THIRDPARTY known_third_party=setuptools

View File

@ -0,0 +1 @@
../../../../web_timeline

View File

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

View File

@ -2,8 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import json import json
from unittest import mock
import mock
from odoo import exceptions from odoo import exceptions
from odoo.tests import common from odoo.tests import common

View File

@ -0,0 +1,213 @@
============
Web timeline
============
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |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%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/13.0/web_timeline
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_timeline
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
Define a new view displaying events in an interactive visualization chart.
The widget is based on the external library
https://visjs.github.io/vis-timeline/examples/timeline
**Table of contents**
.. contents::
:local:
Configuration
=============
You need to define a view with the tag <timeline> as base element. These are
the possible attributes for the tag:
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Attribute | Required? | Description |
+====================+===========+===========================================================================================================================================================================================================================================================================+
| date_start | **Yes** | Defines the name of the field of type date that contains the start of the event. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| date_stop | No | Defines the name of the field of type date that contains the end of the event. The date_stop can be equal to the attribute date_start to display events has 'point' on the Timeline (instantaneous event). |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| date_delay | No | Defines the name of the field of type float/integer that contain the duration in hours of the event, default = 1. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| default_group_by | **Yes** | Defines the name of the field that will be taken as default group by when accessing the view or when no other group by is selected. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| zoomKey | No | Specifies whether the Timeline is only zoomed when an additional key is down. Available values are '' (does not apply), 'altKey', 'ctrlKey', or 'metaKey'. Set this option if you want to be able to use the scroll to navigate vertically on views with a lot of events. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| mode | No | Specifies the initial visible window. Available values are: 'day' to display the current day, 'week', 'month' and 'fit'. Default value is 'fit' to adjust the visible window such that it fits all items. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| margin | No | Specifies the margins around the items. It should respect the JSON format. For example '{"item":{"horizontal":-10}}'. Available values are: '{"axis":<number>}' (The minimal margin in pixels between items and the time axis) |
| | | '{"item":<number>}' (The minimal margin in pixels between items in both horizontal and vertical direction), '{"item":{"horizontal":<number>}}' (The minimal horizontal margin in pixels between items), |
| | | '{"item":{"vertical":<number>}}' (The minimal vertical margin in pixels between items), '{"item":{"horizontal":<number>,"vertical":<number>}}' (Combination between horizontal and vertical margins in pixels between items). |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| event_open_popup | No | When set to true, it allows to edit the events in a popup. If not (default value), the record is edited changing to form view. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| stack | No | When set to false, items will not be stacked on top of each other such that they do overlap. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| colors | No | Allows to set certain specific colors if the expressed condition (JS syntax) is met. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| dependency_arrow | No | Set this attribute to a x2many field to draw arrows between the records referenced in the x2many field. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Optionally you can declare a custom template, which will be used to render the
timeline items. You have to name the template 'timeline-item'.
These are the variables available in template rendering:
* ``record``: to access the fields values selected in the timeline definition.
* ``field_utils``: used to format and parse values (see available functions in ``web.field_utils``).
You also need to declare the view in an action window of the involved model.
Example:
.. code-block:: xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_task_timeline" model="ir.ui.view">
<field name="model">project.task</field>
<field name="type">timeline</field>
<field name="arch" type="xml">
<timeline date_start="date_assign"
date_stop="date_end"
string="Tasks"
default_group_by="user_id"
event_open_popup="true"
zoomKey="ctrlKey"
colors="#ec7063:user_id == false;#2ecb71:kanban_state=='done';"
dependency_arrow="task_dependency_ids">
<field name="user_id"/>
<templates>
<div t-name="timeline-item">
<div t-esc="record.display_name"/>
Assigned to:
<span t-esc="record.user_id[1]"/>
</div>
</templates>
</timeline>
</field>
</record>
<record id="project.action_view_task" model="ir.actions.act_window">
<field name="view_mode">kanban,tree,form,calendar,gantt,timeline,graph</field>
</record>
</odoo>
Usage
=====
For accessing the timeline view, you have to click on the button with the clock
icon in the view switcher. The first time you access to it, the timeline window
is zoomed to fit all the current elements, the same as when you perform a
search, filter or group by operation.
You can use the mouse scroll to zoom in or out in the timeline, and click on
any free area and drag for panning the view in that direction.
The records of your model will be shown as rectangles whose widths are the
duration of the event according our definition. You can select them clicking
on this rectangle. You can also use Ctrl or Shift keys for adding discrete
or range selections. Selected records are hightlighted with a different color
(but the difference will be more noticeable depending on the background color).
Once selected, you can drag and move the selected records across the timeline.
When a record is selected, a red cross button appears on the upper left corner
that allows to remove that record. This doesn't work for multiple records
although they were selected.
Records are grouped in different blocks depending on the group by criteria
selected (if none is specified, then the default group by is applied).
Dragging a record from one block to another change the corresponding field to
the value that represents the block. You can also click on the group name to
edit the involved record directly.
Double-click on the record to edit it. Double-click in open area to create a
new record with the group and start date linked to the area you clicked in.
By holding the Ctrl key and dragging left to right, you can create a new record
with the dragged start and end date.
Known issues / Roadmap
======================
* Implement a more efficient way of refreshing timeline after a record update;
* Make `attrs` attribute work;
* Make action attributes work (create, edit, delete) like in form and tree views.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/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/web/issues/new?body=module:%20web_timeline%0Aversion:%2013.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
~~~~~~~
* ACSONE SA/NV
* Tecnativa
* Monk Software
* Onestein
* Trobz
Contributors
~~~~~~~~~~~~
* Laurent Mignon <laurent.mignon@acsone.eu>
* Adrien Peiffer <adrien.peiffer@acsone.eu>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Leonardo Donelli <donelli@webmonks.it>
* Adrien Didenot <adrien.didenot@horanet.com>
* Dennis Sluijk <d.sluijk@onestein.nl>
* Thong Nguyen Van <thongnv@trobz.com>
* Alexandre Díaz <alexandre.diaz@tecnativa.com>
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-tarteo| image:: https://github.com/tarteo.png?size=40px
:target: https://github.com/tarteo
:alt: tarteo
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-tarteo|
This module is part of the `OCA/web <https://github.com/OCA/web/tree/13.0/web_timeline>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -0,0 +1,4 @@
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

View File

@ -0,0 +1,24 @@
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Web timeline",
"summary": "Interactive visualization chart to show events in time",
"version": "13.0.1.0.0",
"development_status": "Production/Stable",
"author": "ACSONE SA/NV, "
"Tecnativa, "
"Monk Software, "
"Onestein, "
"Trobz, "
"Odoo Community Association (OCA)",
"category": "web",
"license": "AGPL-3",
"website": "https://github.com/OCA/web",
"depends": ["web"],
"qweb": ["static/src/xml/web_timeline.xml"],
"data": ["views/web_timeline.xml"],
"maintainers": ["tarteo"],
"application": False,
"installable": True,
}

View File

@ -0,0 +1,159 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_timeline
#
# Translators:
# Pedro M. Baeza <pedro.baeza@gmail.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-03 03:50+0000\n"
"PO-Revision-Date: 2018-01-03 03:50+0000\n"
"Last-Translator: Pedro M. Baeza <pedro.baeza@gmail.com>, 2017\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Activity"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:243
#, fuzzy, python-format
msgid "Are you sure you want to delete this record?"
msgstr "¿Está seguro que desea eliminar este registro?"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Calendar"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:8
#, python-format
msgid "Day"
msgstr "Día"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Diagram"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Form"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Gantt"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Graph"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Kanban"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:10
#, python-format
msgid "Month"
msgstr "Mes"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Pivot"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "QWeb"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Search"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:467
#, python-format
msgid "Template \"timeline-item\" not present in timeline view definition."
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_view.js:32
#: selection:ir.ui.view,type:0
#, python-format
msgid "Timeline"
msgstr "Línea de tiempo"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:63
#, python-format
msgid "Timeline view has not defined 'date_start' attribute."
msgstr ""
"La vista de línea de tiempo no tiene definido el atributo 'date_start'."
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:5
#, python-format
msgid "Today"
msgstr "Hoy"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Tree"
msgstr ""
#. module: web_timeline
#: model:ir.model,name:web_timeline.model_ir_ui_view
msgid "View"
msgstr ""
#. module: web_timeline
#: model:ir.model.fields,field_description:web_timeline.field_ir_ui_view__type
msgid "View Type"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:246
#, python-format
msgid "Warning"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:9
#, python-format
msgid "Week"
msgstr "Semana"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:11
#, python-format
msgid "Year"
msgstr "Año"
#~ msgid "ir.ui.view"
#~ msgstr "ir.ui.view"

View File

@ -0,0 +1,162 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_timeline
#
# Translators:
# leemannd <denis.leemann@camptocamp.com>, 2017
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-03 03:50+0000\n"
"PO-Revision-Date: 2019-08-06 12:44+0000\n"
"Last-Translator: Nicolas JEUDY <njeudy@panda-chi.io>\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 3.7.1\n"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Activity"
msgstr "Activité"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:243
#, python-format
msgid "Are you sure you want to delete this record?"
msgstr "Êtes vous sûr de vouloir supprimer cet enregistrement ?"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Calendar"
msgstr "Calendrier"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:8
#, python-format
msgid "Day"
msgstr "Jour"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Diagram"
msgstr "Diagramme"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Form"
msgstr "Formulaire"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Gantt"
msgstr "Gantt"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Graph"
msgstr "Graphique"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Kanban"
msgstr "Kanban"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:10
#, python-format
msgid "Month"
msgstr "Mois"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Pivot"
msgstr "Pivot"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "QWeb"
msgstr "QWeb"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Search"
msgstr "Recherche"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:467
#, python-format
msgid "Template \"timeline-item\" not present in timeline view definition."
msgstr ""
"Le modèle \"timeline-item\" n'est pas présent dans la définition de la vue "
"timeline."
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_view.js:32
#: selection:ir.ui.view,type:0
#, python-format
msgid "Timeline"
msgstr "Chronologie"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:63
#, python-format
msgid "Timeline view has not defined 'date_start' attribute."
msgstr "La vue chronologique n'a pas défini l'attribut 'date_start'."
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:5
#, python-format
msgid "Today"
msgstr "Aujourd'hui"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Tree"
msgstr "Arborescence"
#. module: web_timeline
#: model:ir.model,name:web_timeline.model_ir_ui_view
msgid "View"
msgstr "Vue"
#. module: web_timeline
#: model:ir.model.fields,field_description:web_timeline.field_ir_ui_view__type
msgid "View Type"
msgstr "Type de vue"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:246
#, python-format
msgid "Warning"
msgstr "Alerte"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:9
#, python-format
msgid "Week"
msgstr "Semaine"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:11
#, python-format
msgid "Year"
msgstr "Année"
#~ msgid "ir.ui.view"
#~ msgstr "ir.ui.view"

View File

@ -0,0 +1,161 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_timeline
#
# Translators:
# Bole <bole@dajmi5.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-03 03:50+0000\n"
"PO-Revision-Date: 2019-11-14 10:34+0000\n"
"Last-Translator: Bole <bole@dajmi5.com>\n"
"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n"
"Language: hr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<="
"4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Weblate 3.8\n"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Activity"
msgstr "Aktivnost"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:243
#, python-format
msgid "Are you sure you want to delete this record?"
msgstr "Jeste li sigurni da želite brisati ovaj zapis?"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Calendar"
msgstr "Kalendar"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:8
#, python-format
msgid "Day"
msgstr "Dan"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Diagram"
msgstr "Diagram"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Form"
msgstr "Forma"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Gantt"
msgstr "Gant"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Graph"
msgstr "Graf"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Kanban"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:10
#, python-format
msgid "Month"
msgstr "Mjesec"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Pivot"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "QWeb"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Search"
msgstr "Pretraga"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:467
#, python-format
msgid "Template \"timeline-item\" not present in timeline view definition."
msgstr ""
"Predložak za \"stavku_vremenske_crte\" nije pronađen u definiciji pogleda."
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_view.js:32
#: selection:ir.ui.view,type:0
#, python-format
msgid "Timeline"
msgstr "Vremenska crta"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:63
#, python-format
msgid "Timeline view has not defined 'date_start' attribute."
msgstr "Pogled vremenske crte nema definiran atribut 'date_start'."
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:5
#, python-format
msgid "Today"
msgstr "Danas"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Tree"
msgstr "Lista"
#. module: web_timeline
#: model:ir.model,name:web_timeline.model_ir_ui_view
msgid "View"
msgstr "Pogled"
#. module: web_timeline
#: model:ir.model.fields,field_description:web_timeline.field_ir_ui_view__type
msgid "View Type"
msgstr "Vrsta pogleda"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:246
#, python-format
msgid "Warning"
msgstr "Upozorenje"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:9
#, python-format
msgid "Week"
msgstr "Tjedan"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:11
#, python-format
msgid "Year"
msgstr "Godina"
#~ msgid "ir.ui.view"
#~ msgstr "ir.ui.view"

View File

@ -0,0 +1,159 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_timeline
#
# Translators:
# Peter Hageman <hageman.p@gmail.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-03 03:50+0000\n"
"PO-Revision-Date: 2018-01-03 03:50+0000\n"
"Last-Translator: Peter Hageman <hageman.p@gmail.com>, 2017\n"
"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/"
"teams/23907/nl_NL/)\n"
"Language: nl_NL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Activity"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:243
#, fuzzy, python-format
msgid "Are you sure you want to delete this record?"
msgstr "Weet je zeker dat je dit record wil verwijderen?"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Calendar"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:8
#, python-format
msgid "Day"
msgstr "Dag"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Diagram"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Form"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Gantt"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Graph"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Kanban"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:10
#, python-format
msgid "Month"
msgstr "Maand"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Pivot"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "QWeb"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Search"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:467
#, python-format
msgid "Template \"timeline-item\" not present in timeline view definition."
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_view.js:32
#: selection:ir.ui.view,type:0
#, python-format
msgid "Timeline"
msgstr "Tijdlijn"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:63
#, python-format
msgid "Timeline view has not defined 'date_start' attribute."
msgstr "Tijdlijn heeft geen 'date_start' eigenschap."
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:5
#, python-format
msgid "Today"
msgstr "Vandaag"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Tree"
msgstr ""
#. module: web_timeline
#: model:ir.model,name:web_timeline.model_ir_ui_view
msgid "View"
msgstr ""
#. module: web_timeline
#: model:ir.model.fields,field_description:web_timeline.field_ir_ui_view__type
msgid "View Type"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:246
#, python-format
msgid "Warning"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:9
#, python-format
msgid "Week"
msgstr "Week"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:11
#, python-format
msgid "Year"
msgstr "Jaar"
#~ msgid "ir.ui.view"
#~ msgstr "ir.ui.view"

View File

@ -0,0 +1,155 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_timeline
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2019-08-12 11:44+0000\n"
"Last-Translator: Pedro Castro Silva <pedrocs@exo.pt>\n"
"Language-Team: none\n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 3.7.1\n"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Activity"
msgstr "Atividade"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:243
#, python-format
msgid "Are you sure you want to delete this record?"
msgstr "Está seguro de que quer eliminar este registo?"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Calendar"
msgstr "Calendário"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:8
#, python-format
msgid "Day"
msgstr "Dia"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Diagram"
msgstr "Diagrama"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Form"
msgstr "Formulário"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Gantt"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Graph"
msgstr "Gráfico"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Kanban"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:10
#, python-format
msgid "Month"
msgstr "Mês"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Pivot"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "QWeb"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Search"
msgstr "Pesquisar"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:467
#, python-format
msgid "Template \"timeline-item\" not present in timeline view definition."
msgstr ""
"O modelo \"timeline-item\" não está presente na definição da vista da linha "
"temporal."
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_view.js:32
#: selection:ir.ui.view,type:0
#, python-format
msgid "Timeline"
msgstr "Linha Temporal"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:63
#, python-format
msgid "Timeline view has not defined 'date_start' attribute."
msgstr "A vista da linha temporal não tem o atributo 'date_start' definido."
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:5
#, python-format
msgid "Today"
msgstr "Hoje"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Tree"
msgstr "Árvore"
#. module: web_timeline
#: model:ir.model,name:web_timeline.model_ir_ui_view
msgid "View"
msgstr "Vista"
#. module: web_timeline
#: model:ir.model.fields,field_description:web_timeline.field_ir_ui_view__type
msgid "View Type"
msgstr "Tipo de Vista"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:246
#, python-format
msgid "Warning"
msgstr "Aviso"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:9
#, python-format
msgid "Week"
msgstr "Semana"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:11
#, python-format
msgid "Year"
msgstr "Ano"

View File

@ -0,0 +1,151 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_timeline
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Activity"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:243
#, python-format
msgid "Are you sure you want to delete this record?"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Calendar"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:8
#, python-format
msgid "Day"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Diagram"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Form"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Gantt"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Graph"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Kanban"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:10
#, python-format
msgid "Month"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Pivot"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "QWeb"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Search"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:467
#, python-format
msgid "Template \"timeline-item\" not present in timeline view definition."
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_view.js:32
#: selection:ir.ui.view,type:0
#, python-format
msgid "Timeline"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:63
#, python-format
msgid "Timeline view has not defined 'date_start' attribute."
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:5
#, python-format
msgid "Today"
msgstr ""
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Tree"
msgstr ""
#. module: web_timeline
#: model:ir.model,name:web_timeline.model_ir_ui_view
msgid "View"
msgstr ""
#. module: web_timeline
#: model:ir.model.fields,field_description:web_timeline.field_ir_ui_view__type
msgid "View Type"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:246
#, python-format
msgid "Warning"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:9
#, python-format
msgid "Week"
msgstr ""
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:11
#, python-format
msgid "Year"
msgstr ""

View File

@ -0,0 +1,153 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_timeline
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2019-09-01 12:52+0000\n"
"Last-Translator: 黎伟杰 <674416404@qq.com>\n"
"Language-Team: none\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 3.8\n"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Activity"
msgstr "活动"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:243
#, python-format
msgid "Are you sure you want to delete this record?"
msgstr "您确定要删除此记录吗?"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Calendar"
msgstr "日历"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:8
#, python-format
msgid "Day"
msgstr "天"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Diagram"
msgstr "图表"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Form"
msgstr "表单"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Gantt"
msgstr "甘特图"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Graph"
msgstr "图形"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Kanban"
msgstr "看板"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:10
#, python-format
msgid "Month"
msgstr "月"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Pivot"
msgstr "透视表"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "QWeb"
msgstr "QWeb"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Search"
msgstr "搜索"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:467
#, python-format
msgid "Template \"timeline-item\" not present in timeline view definition."
msgstr "时间线视图定义中不存在模板“timeline-item”。"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_view.js:32
#: selection:ir.ui.view,type:0
#, python-format
msgid "Timeline"
msgstr "时间线"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_renderer.js:63
#, python-format
msgid "Timeline view has not defined 'date_start' attribute."
msgstr "时间线视图尚未定义\"date_start\"属性。"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:5
#, python-format
msgid "Today"
msgstr "今天"
#. module: web_timeline
#: selection:ir.ui.view,type:0
msgid "Tree"
msgstr "树形"
#. module: web_timeline
#: model:ir.model,name:web_timeline.model_ir_ui_view
msgid "View"
msgstr "视图"
#. module: web_timeline
#: model:ir.model.fields,field_description:web_timeline.field_ir_ui_view__type
msgid "View Type"
msgstr "查看类型"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/js/timeline_controller.js:246
#, python-format
msgid "Warning"
msgstr "警告"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:9
#, python-format
msgid "Week"
msgstr "周"
#. module: web_timeline
#. openerp-web
#: code:addons/web_timeline/static/src/xml/web_timeline.xml:11
#, python-format
msgid "Year"
msgstr "年"

View File

@ -0,0 +1,4 @@
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import ir_ui_view

View File

@ -0,0 +1,12 @@
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
TIMELINE_VIEW = ("timeline", "Timeline")
class IrUIView(models.Model):
_inherit = "ir.ui.view"
type = fields.Selection(selection_add=[TIMELINE_VIEW])

View File

@ -0,0 +1,74 @@
You need to define a view with the tag <timeline> as base element. These are
the possible attributes for the tag:
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Attribute | Required? | Description |
+====================+===========+===========================================================================================================================================================================================================================================================================+
| date_start | **Yes** | Defines the name of the field of type date that contains the start of the event. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| date_stop | No | Defines the name of the field of type date that contains the end of the event. The date_stop can be equal to the attribute date_start to display events has 'point' on the Timeline (instantaneous event). |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| date_delay | No | Defines the name of the field of type float/integer that contain the duration in hours of the event, default = 1. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| default_group_by | **Yes** | Defines the name of the field that will be taken as default group by when accessing the view or when no other group by is selected. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| zoomKey | No | Specifies whether the Timeline is only zoomed when an additional key is down. Available values are '' (does not apply), 'altKey', 'ctrlKey', or 'metaKey'. Set this option if you want to be able to use the scroll to navigate vertically on views with a lot of events. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| mode | No | Specifies the initial visible window. Available values are: 'day' to display the current day, 'week', 'month' and 'fit'. Default value is 'fit' to adjust the visible window such that it fits all items. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| margin | No | Specifies the margins around the items. It should respect the JSON format. For example '{"item":{"horizontal":-10}}'. Available values are: '{"axis":<number>}' (The minimal margin in pixels between items and the time axis) |
| | | '{"item":<number>}' (The minimal margin in pixels between items in both horizontal and vertical direction), '{"item":{"horizontal":<number>}}' (The minimal horizontal margin in pixels between items), |
| | | '{"item":{"vertical":<number>}}' (The minimal vertical margin in pixels between items), '{"item":{"horizontal":<number>,"vertical":<number>}}' (Combination between horizontal and vertical margins in pixels between items). |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| event_open_popup | No | When set to true, it allows to edit the events in a popup. If not (default value), the record is edited changing to form view. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| stack | No | When set to false, items will not be stacked on top of each other such that they do overlap. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| colors | No | Allows to set certain specific colors if the expressed condition (JS syntax) is met. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| dependency_arrow | No | Set this attribute to a x2many field to draw arrows between the records referenced in the x2many field. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Optionally you can declare a custom template, which will be used to render the
timeline items. You have to name the template 'timeline-item'.
These are the variables available in template rendering:
* ``record``: to access the fields values selected in the timeline definition.
* ``field_utils``: used to format and parse values (see available functions in ``web.field_utils``).
You also need to declare the view in an action window of the involved model.
Example:
.. code-block:: xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_task_timeline" model="ir.ui.view">
<field name="model">project.task</field>
<field name="type">timeline</field>
<field name="arch" type="xml">
<timeline date_start="date_assign"
date_stop="date_end"
string="Tasks"
default_group_by="user_id"
event_open_popup="true"
zoomKey="ctrlKey"
colors="#ec7063:user_id == false;#2ecb71:kanban_state=='done';"
dependency_arrow="task_dependency_ids">
<field name="user_id"/>
<templates>
<div t-name="timeline-item">
<div t-esc="record.display_name"/>
Assigned to:
<span t-esc="record.user_id[1]"/>
</div>
</templates>
</timeline>
</field>
</record>
<record id="project.action_view_task" model="ir.actions.act_window">
<field name="view_mode">kanban,tree,form,calendar,gantt,timeline,graph</field>
</record>
</odoo>

View File

@ -0,0 +1,8 @@
* Laurent Mignon <laurent.mignon@acsone.eu>
* Adrien Peiffer <adrien.peiffer@acsone.eu>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Leonardo Donelli <donelli@webmonks.it>
* Adrien Didenot <adrien.didenot@horanet.com>
* Dennis Sluijk <d.sluijk@onestein.nl>
* Thong Nguyen Van <thongnv@trobz.com>
* Alexandre Díaz <alexandre.diaz@tecnativa.com>

View File

@ -0,0 +1,4 @@
Define a new view displaying events in an interactive visualization chart.
The widget is based on the external library
https://visjs.github.io/vis-timeline/examples/timeline

View File

@ -0,0 +1,3 @@
* Implement a more efficient way of refreshing timeline after a record update;
* Make `attrs` attribute work;
* Make action attributes work (create, edit, delete) like in form and tree views.

View File

@ -0,0 +1,29 @@
For accessing the timeline view, you have to click on the button with the clock
icon in the view switcher. The first time you access to it, the timeline window
is zoomed to fit all the current elements, the same as when you perform a
search, filter or group by operation.
You can use the mouse scroll to zoom in or out in the timeline, and click on
any free area and drag for panning the view in that direction.
The records of your model will be shown as rectangles whose widths are the
duration of the event according our definition. You can select them clicking
on this rectangle. You can also use Ctrl or Shift keys for adding discrete
or range selections. Selected records are hightlighted with a different color
(but the difference will be more noticeable depending on the background color).
Once selected, you can drag and move the selected records across the timeline.
When a record is selected, a red cross button appears on the upper left corner
that allows to remove that record. This doesn't work for multiple records
although they were selected.
Records are grouped in different blocks depending on the group by criteria
selected (if none is specified, then the default group by is applied).
Dragging a record from one block to another change the corresponding field to
the value that represents the block. You can also click on the group name to
edit the involved record directly.
Double-click on the record to edit it. Double-click in open area to create a
new record with the group and start date linked to the area you clicked in.
By holding the Ctrl key and dragging left to right, you can create a new record
with the dragged start and end date.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,579 @@
<?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 0.15.1: http://docutils.sourceforge.net/" />
<title>Web timeline</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="web-timeline">
<h1 class="title">Web timeline</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="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/web/tree/13.0/web_timeline"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_timeline"><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/162/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Define a new view displaying events in an interactive visualization chart.</p>
<p>The widget is based on the external library
<a class="reference external" href="https://visjs.github.io/vis-timeline/examples/timeline">https://visjs.github.io/vis-timeline/examples/timeline</a></p>
<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="#maintainers" id="id8">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>You need to define a view with the tag &lt;timeline&gt; as base element. These are
the possible attributes for the tag:</p>
<table border="1" class="docutils">
<colgroup>
<col width="7%" />
<col width="4%" />
<col width="90%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Attribute</th>
<th class="head">Required?</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>date_start</td>
<td><strong>Yes</strong></td>
<td>Defines the name of the field of type date that contains the start of the event.</td>
</tr>
<tr><td>date_stop</td>
<td>No</td>
<td>Defines the name of the field of type date that contains the end of the event. The date_stop can be equal to the attribute date_start to display events has point on the Timeline (instantaneous event).</td>
</tr>
<tr><td>date_delay</td>
<td>No</td>
<td>Defines the name of the field of type float/integer that contain the duration in hours of the event, default = 1.</td>
</tr>
<tr><td>default_group_by</td>
<td><strong>Yes</strong></td>
<td>Defines the name of the field that will be taken as default group by when accessing the view or when no other group by is selected.</td>
</tr>
<tr><td>zoomKey</td>
<td>No</td>
<td>Specifies whether the Timeline is only zoomed when an additional key is down. Available values are (does not apply), altKey, ctrlKey, or metaKey. Set this option if you want to be able to use the scroll to navigate vertically on views with a lot of events.</td>
</tr>
<tr><td>mode</td>
<td>No</td>
<td>Specifies the initial visible window. Available values are: day to display the current day, week, month and fit. Default value is fit to adjust the visible window such that it fits all items.</td>
</tr>
<tr><td>margin</td>
<td>No</td>
<td>Specifies the margins around the items. It should respect the JSON format. For example {“item”:{“horizontal”:-10}}. Available values are: {“axis”:&lt;number&gt;} (The minimal margin in pixels between items and the time axis)
{“item”:&lt;number&gt;} (The minimal margin in pixels between items in both horizontal and vertical direction), {“item”:{“horizontal”:&lt;number&gt;}} (The minimal horizontal margin in pixels between items),
{“item”:{“vertical”:&lt;number&gt;}} (The minimal vertical margin in pixels between items), {“item”:{“horizontal”:&lt;number&gt;,”vertical”:&lt;number&gt;}} (Combination between horizontal and vertical margins in pixels between items).</td>
</tr>
<tr><td>event_open_popup</td>
<td>No</td>
<td>When set to true, it allows to edit the events in a popup. If not (default value), the record is edited changing to form view.</td>
</tr>
<tr><td>stack</td>
<td>No</td>
<td>When set to false, items will not be stacked on top of each other such that they do overlap.</td>
</tr>
<tr><td>colors</td>
<td>No</td>
<td>Allows to set certain specific colors if the expressed condition (JS syntax) is met.</td>
</tr>
<tr><td>dependency_arrow</td>
<td>No</td>
<td>Set this attribute to a x2many field to draw arrows between the records referenced in the x2many field.</td>
</tr>
</tbody>
</table>
<p>Optionally you can declare a custom template, which will be used to render the
timeline items. You have to name the template timeline-item.
These are the variables available in template rendering:</p>
<ul class="simple">
<li><tt class="docutils literal">record</tt>: to access the fields values selected in the timeline definition.</li>
<li><tt class="docutils literal">field_utils</tt>: used to format and parse values (see available functions in <tt class="docutils literal">web.field_utils</tt>).</li>
</ul>
<p>You also need to declare the view in an action window of the involved model.</p>
<p>Example:</p>
<pre class="code xml literal-block">
<span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span>
<span class="nt">&lt;odoo&gt;</span>
<span class="nt">&lt;record</span> <span class="na">id=</span><span class="s">&quot;view_task_timeline&quot;</span> <span class="na">model=</span><span class="s">&quot;ir.ui.view&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;model&quot;</span><span class="nt">&gt;</span>project.task<span class="nt">&lt;/field&gt;</span>
<span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;type&quot;</span><span class="nt">&gt;</span>timeline<span class="nt">&lt;/field&gt;</span>
<span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;arch&quot;</span> <span class="na">type=</span><span class="s">&quot;xml&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;timeline</span> <span class="na">date_start=</span><span class="s">&quot;date_assign&quot;</span>
<span class="na">date_stop=</span><span class="s">&quot;date_end&quot;</span>
<span class="na">string=</span><span class="s">&quot;Tasks&quot;</span>
<span class="na">default_group_by=</span><span class="s">&quot;user_id&quot;</span>
<span class="na">event_open_popup=</span><span class="s">&quot;true&quot;</span>
<span class="na">zoomKey=</span><span class="s">&quot;ctrlKey&quot;</span>
<span class="na">colors=</span><span class="s">&quot;#ec7063:user_id == false;#2ecb71:kanban_state=='done';&quot;</span>
<span class="na">dependency_arrow=</span><span class="s">&quot;task_dependency_ids&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;user_id&quot;</span><span class="nt">/&gt;</span>
<span class="nt">&lt;templates&gt;</span>
<span class="nt">&lt;div</span> <span class="na">t-name=</span><span class="s">&quot;timeline-item&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;div</span> <span class="na">t-esc=</span><span class="s">&quot;record.display_name&quot;</span><span class="nt">/&gt;</span>
Assigned to:
<span class="nt">&lt;span</span> <span class="na">t-esc=</span><span class="s">&quot;record.user_id[1]&quot;</span><span class="nt">/&gt;</span>
<span class="nt">&lt;/div&gt;</span>
<span class="nt">&lt;/templates&gt;</span>
<span class="nt">&lt;/timeline&gt;</span>
<span class="nt">&lt;/field&gt;</span>
<span class="nt">&lt;/record&gt;</span>
<span class="nt">&lt;record</span> <span class="na">id=</span><span class="s">&quot;project.action_view_task&quot;</span> <span class="na">model=</span><span class="s">&quot;ir.actions.act_window&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;view_mode&quot;</span><span class="nt">&gt;</span>kanban,tree,form,calendar,gantt,timeline,graph<span class="nt">&lt;/field&gt;</span>
<span class="nt">&lt;/record&gt;</span>
<span class="nt">&lt;/odoo&gt;</span>
</pre>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
<p>For accessing the timeline view, you have to click on the button with the clock
icon in the view switcher. The first time you access to it, the timeline window
is zoomed to fit all the current elements, the same as when you perform a
search, filter or group by operation.</p>
<p>You can use the mouse scroll to zoom in or out in the timeline, and click on
any free area and drag for panning the view in that direction.</p>
<p>The records of your model will be shown as rectangles whose widths are the
duration of the event according our definition. You can select them clicking
on this rectangle. You can also use Ctrl or Shift keys for adding discrete
or range selections. Selected records are hightlighted with a different color
(but the difference will be more noticeable depending on the background color).
Once selected, you can drag and move the selected records across the timeline.</p>
<p>When a record is selected, a red cross button appears on the upper left corner
that allows to remove that record. This doesnt work for multiple records
although they were selected.</p>
<p>Records are grouped in different blocks depending on the group by criteria
selected (if none is specified, then the default group by is applied).
Dragging a record from one block to another change the corresponding field to
the value that represents the block. You can also click on the group name to
edit the involved record directly.</p>
<p>Double-click on the record to edit it. Double-click in open area to create a
new record with the group and start date linked to the area you clicked in.
By holding the Ctrl key and dragging left to right, you can create a new record
with the dragged start and end date.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id3">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Implement a more efficient way of refreshing timeline after a record update;</li>
<li>Make <cite>attrs</cite> attribute work;</li>
<li>Make action attributes work (create, edit, delete) like in form and tree views.</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/web/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/web/issues/new?body=module:%20web_timeline%0Aversion:%2013.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>ACSONE SA/NV</li>
<li>Tecnativa</li>
<li>Monk Software</li>
<li>Onestein</li>
<li>Trobz</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id7">Contributors</a></h2>
<ul class="simple">
<li>Laurent Mignon &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li>
<li>Adrien Peiffer &lt;<a class="reference external" href="mailto:adrien.peiffer&#64;acsone.eu">adrien.peiffer&#64;acsone.eu</a>&gt;</li>
<li>Pedro M. Baeza &lt;<a class="reference external" href="mailto:pedro.baeza&#64;tecnativa.com">pedro.baeza&#64;tecnativa.com</a>&gt;</li>
<li>Leonardo Donelli &lt;<a class="reference external" href="mailto:donelli&#64;webmonks.it">donelli&#64;webmonks.it</a>&gt;</li>
<li>Adrien Didenot &lt;<a class="reference external" href="mailto:adrien.didenot&#64;horanet.com">adrien.didenot&#64;horanet.com</a>&gt;</li>
<li>Dennis Sluijk &lt;<a class="reference external" href="mailto:d.sluijk&#64;onestein.nl">d.sluijk&#64;onestein.nl</a>&gt;</li>
<li>Thong Nguyen Van &lt;<a class="reference external" href="mailto:thongnv&#64;trobz.com">thongnv&#64;trobz.com</a>&gt;</li>
<li>Alexandre Díaz &lt;<a class="reference external" href="mailto:alexandre.diaz&#64;tecnativa.com">alexandre.diaz&#64;tecnativa.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id8">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/tarteo"><img alt="tarteo" src="https://github.com/tarteo.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/13.0/web_timeline">OCA/web</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>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,160 @@
/* Copyright 2018 Onestein
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
odoo.define("web_timeline.TimelineCanvas", function(require) {
"use strict";
const Widget = require("web.Widget");
/**
* Used to draw stuff on upon the timeline view.
*/
const TimelineCanvas = Widget.extend({
template: "TimelineView.Canvas",
/**
* Clears all drawings (svg elements) from the canvas.
*/
clear: function() {
this.$(" > :not(defs)").remove();
},
/**
* Gets the path from one point to another.
*
* @param {Object} rectFrom
* @param {Object} rectTo
* @param {Number} widthMarker The marker's width of the polyline
* @param {Number} breakAt The space between the line turns
* @returns {Array} Each item represents a coordinate
*/
get_polyline_points: function(rectFrom, rectTo, widthMarker, breakAt) {
let fromX = 0,
toX = 0;
if (rectFrom.x < rectTo.x + rectTo.w) {
fromX = rectFrom.x + rectFrom.w + widthMarker;
toX = rectTo.x;
} else {
fromX = rectFrom.x - widthMarker;
toX = rectTo.x + rectTo.w;
}
let deltaBreak = 0;
if (fromX < toX) {
deltaBreak = fromX + breakAt - (toX - breakAt);
} else {
deltaBreak = fromX - breakAt - (toX + breakAt);
}
const fromHalfHeight = rectFrom.h / 2;
const fromY = rectFrom.y + fromHalfHeight;
const toHalfHeight = rectTo.h / 2;
const toY = rectTo.y + toHalfHeight;
const xDiff = fromX - toX;
const yDiff = fromY - toY;
const threshold = breakAt + widthMarker;
const spaceY = toHalfHeight + 2;
const points = [[fromX, fromY]];
const _addPoints = (space, ePoint, mode) => {
if (mode) {
points.push([fromX + breakAt, fromY]);
points.push([fromX + breakAt, ePoint + space]);
points.push([toX - breakAt, toY + space]);
points.push([toX - breakAt, toY]);
} else {
points.push([fromX - breakAt, fromY]);
points.push([fromX - breakAt, ePoint + space]);
points.push([toX + breakAt, toY + space]);
points.push([toX + breakAt, toY]);
}
};
if (fromY !== toY) {
if (Math.abs(xDiff) < threshold) {
points.push([fromX + breakAt, toY + yDiff]);
points.push([fromX + breakAt, toY]);
} else {
const yDiffSpace = yDiff > 0 ? spaceY : -spaceY;
_addPoints(yDiffSpace, toY, rectFrom.x < rectTo.x + rectTo.w);
}
} else if (Math.abs(deltaBreak) >= threshold) {
_addPoints(spaceY, fromY, fromX < toX);
}
points.push([toX, toY]);
return points;
},
/**
* Draws an arrow.
*
* @param {HTMLElement} from Element to draw the arrow from
* @param {HTMLElement} to Element to draw the arrow to
* @param {String} color Color of the line
* @param {Number} width Width of the line
* @returns {HTMLElement} The created SVG polyline
*/
draw_arrow: function(from, to, color, width) {
return this.draw_line(from, to, color, width, "#arrowhead", 10, 12);
},
/**
* Draws a line.
*
* @param {HTMLElement} from Element to draw the line from
* @param {HTMLElement} to Element to draw the line to
* @param {String} color Color of the line
* @param {Number} width Width of the line
* @param {String} markerStart Start marker of the line
* @param {Number} widthMarker The marker's width of the polyline
* @param {Number} breakLineAt The space between the line turns
* @returns {HTMLElement} The created SVG polyline
*/
draw_line: function(
from,
to,
color,
width,
markerStart,
widthMarker,
breakLineAt
) {
const $from = $(from);
const childPosFrom = $from.offset();
const parentPosFrom = $from.closest(".vis-center").offset();
const rectFrom = {
x: childPosFrom.left - parentPosFrom.left,
y: childPosFrom.top - parentPosFrom.top,
w: $from.width(),
h: $from.height(),
};
const $to = $(to);
const childPosTo = $to.offset();
const parentPosTo = $to.closest(".vis-center").offset();
const rectTo = {
x: childPosTo.left - parentPosTo.left,
y: childPosTo.top - parentPosTo.top,
w: $to.width(),
h: $to.height(),
};
const points = this.get_polyline_points(
rectFrom,
rectTo,
widthMarker,
breakLineAt
);
const line = document.createElementNS(
"http://www.w3.org/2000/svg",
"polyline"
);
line.setAttribute("points", _.flatten(points).join(","));
line.setAttribute("stroke", color || "#000");
line.setAttribute("stroke-width", width || 1);
line.setAttribute("fill", "none");
if (markerStart) {
line.setAttribute("marker-start", "url(" + markerStart + ")");
}
this.$el.append(line);
return line;
},
});
return TimelineCanvas;
});

View File

@ -0,0 +1,355 @@
odoo.define("web_timeline.TimelineController", function(require) {
"use strict";
const AbstractController = require("web.AbstractController");
const dialogs = require("web.view_dialogs");
const core = require("web.core");
const time = require("web.time");
const Dialog = require("web.Dialog");
const _t = core._t;
const TimelineController = AbstractController.extend({
custom_events: _.extend({}, AbstractController.prototype.custom_events, {
onGroupClick: "_onGroupClick",
onUpdate: "_onUpdate",
onRemove: "_onRemove",
onMove: "_onMove",
onAdd: "_onAdd",
}),
/**
* @override
*/
init: function(parent, model, renderer, params) {
this._super.apply(this, arguments);
this.open_popup_action = params.open_popup_action;
this.date_start = params.date_start;
this.date_stop = params.date_stop;
this.date_delay = params.date_delay;
this.context = params.actionContext;
this.moveQueue = [];
this.debouncedInternalMove = _.debounce(this.internalMove, 0);
},
/**
* @override
*/
update: function(params, options) {
const res = this._super.apply(this, arguments);
if (_.isEmpty(params)) {
return res;
}
const defaults = _.defaults({}, options, {
adjust_window: true,
});
const domains = params.domain;
const contexts = params.context;
const group_bys = params.groupBy;
this.last_domains = domains;
this.last_contexts = contexts;
// Select the group by
let n_group_bys = group_bys;
if (!n_group_bys.length && this.renderer.arch.attrs.default_group_by) {
n_group_bys = this.renderer.arch.attrs.default_group_by.split(",");
}
this.renderer.last_group_bys = n_group_bys;
this.renderer.last_domains = domains;
let fields = this.renderer.fieldNames;
fields = _.uniq(fields.concat(n_group_bys));
return $.when(
res,
this._rpc({
model: this.model.modelName,
method: "search_read",
kwargs: {
fields: fields,
domain: domains,
},
context: this.getSession().user_context,
}).then(data =>
this.renderer.on_data_loaded(
data,
n_group_bys,
defaults.adjust_window
)
)
);
},
/**
* Gets triggered when a group in the timeline is
* clicked (by the TimelineRenderer).
*
* @private
* @param {EventObject} event
* @returns {jQuery.Deferred}
*/
_onGroupClick: function(event) {
const groupField = this.renderer.last_group_bys[0];
return this.do_action({
type: "ir.actions.act_window",
res_model: this.renderer.fields[groupField].relation,
res_id: event.data.item.group,
target: "new",
views: [[false, "form"]],
});
},
/**
* Opens a form view of a clicked timeline
* item (triggered by the TimelineRenderer).
*
* @private
* @param {EventObject} event
*/
_onUpdate: function(event) {
this.renderer = event.data.renderer;
const rights = event.data.rights;
const item = event.data.item;
const id = Number(item.evt.id) || item.evt.id;
const title = item.evt.__name;
if (this.open_popup_action) {
new dialogs.FormViewDialog(this, {
res_model: this.model.modelName,
res_id: id,
context: this.getSession().user_context,
title: title,
view_id: Number(this.open_popup_action),
on_saved: () => {
this.write_completed();
},
}).open();
} else {
let mode = "readonly";
if (rights.write) {
mode = "edit";
}
this.trigger_up("switch_view", {
view_type: "form",
res_id: id,
mode: mode,
model: this.model.modelName,
});
}
},
/**
* Gets triggered when a timeline item is
* moved (triggered by the TimelineRenderer).
*
* @private
* @param {EventObject} event
*/
_onMove: function(event) {
const item = event.data.item;
const fields = this.renderer.fields;
const event_start = item.start;
const event_end = item.end;
let group = false;
if (item.group !== -1) {
group = item.group;
}
const data = {};
// In case of a move event, the date_delay stay the same,
// only date_start and stop must be updated
data[this.date_start] = time.auto_date_to_str(
event_start,
fields[this.date_start].type
);
if (this.date_stop) {
// In case of instantaneous event, item.end is not defined
if (event_end) {
data[this.date_stop] = time.auto_date_to_str(
event_end,
fields[this.date_stop].type
);
} else {
data[this.date_stop] = data[this.date_start];
}
}
if (this.date_delay && event_end) {
const diff_seconds = Math.round(
(event_end.getTime() - event_start.getTime()) / 1000
);
data[this.date_delay] = diff_seconds / 3600;
}
if (
this.renderer.last_group_bys &&
this.renderer.last_group_bys instanceof Array
) {
data[this.renderer.last_group_bys[0]] = group;
}
this.moveQueue.push({
id: event.data.item.id,
data: data,
event: event,
});
this.debouncedInternalMove();
},
/**
* Write enqueued moves to Odoo. After all writes are finished it updates
* the view once (prevents flickering of the view when multiple timeline items
* are moved at once).
*
* @returns {jQuery.Deferred}
*/
internalMove: function() {
const queues = this.moveQueue.slice();
this.moveQueue = [];
const defers = [];
for (const item of queues) {
defers.push(
this._rpc({
model: this.model.modelName,
method: "write",
args: [[item.event.data.item.id], item.data],
context: this.getSession().user_context,
}).then(() => {
item.event.data.callback(item.event.data.item);
})
);
}
return $.when.apply($, defers).done(() => {
this.write_completed({
adjust_window: false,
});
});
},
/**
* Triggered when a timeline item gets removed from the view.
* Requires user confirmation before it gets actually deleted.
*
* @private
* @param {EventObject} event
* @returns {jQuery.Deferred}
*/
_onRemove: function(event) {
var def = $.Deferred();
Dialog.confirm(this, _t("Are you sure you want to delete this record?"), {
title: _t("Warning"),
confirm_callback: () => {
this.remove_completed(event).then(def.resolve.bind(def));
},
cancel_callback: def.resolve.bind(def),
});
return def;
},
/**
* Triggered when a timeline item gets added and opens a form view.
*
* @private
* @param {EventObject} event
* @returns {dialogs.FormViewDialog}
*/
_onAdd: function(event) {
const item = event.data.item;
// Initialize default values for creation
const default_context = {};
default_context["default_".concat(this.date_start)] = item.start;
if (this.date_delay) {
default_context["default_".concat(this.date_delay)] = 1;
}
if (this.date_start) {
default_context["default_".concat(this.date_start)] = moment(item.start)
.add(1, "hours")
.format("YYYY-MM-DD HH:mm:ss");
}
if (this.date_stop && item.end) {
default_context["default_".concat(this.date_stop)] = moment(item.end)
.add(1, "hours")
.format("YYYY-MM-DD HH:mm:ss");
}
if (item.group > 0) {
default_context["default_".concat(this.renderer.last_group_bys[0])] =
item.group;
}
// Show popup
new dialogs.FormViewDialog(this, {
res_model: this.model.modelName,
res_id: null,
context: _.extend(default_context, this.context),
view_id: Number(this.open_popup_action),
on_saved: record => {
this.create_completed([record.res_id]);
},
})
.open()
.on("closed", this, () => {
event.data.callback();
});
return false;
},
/**
* Triggered upon completion of a new record.
* Updates the timeline view with the new record.
*
* @param {RecordId} id
* @returns {jQuery.Deferred}
*/
create_completed: function(id) {
return this._rpc({
model: this.model.modelName,
method: "read",
args: [id, this.model.fieldNames],
context: this.context,
}).then(records => {
var new_event = this.renderer.event_data_transform(records[0]);
var items = this.renderer.timeline.itemsData;
items.add(new_event);
this.renderer.timeline.setItems(items);
this.reload();
});
},
/**
* Triggered upon completion of writing a record.
* @param {ControllerOptions} options
*/
write_completed: function(options) {
const params = {
domain: this.renderer.last_domains,
context: this.context,
groupBy: this.renderer.last_group_bys,
};
this.update(params, options);
},
/**
* Triggered upon confirm of removing a record.
* @param {EventObject} event
* @returns {jQuery.Deferred}
*/
remove_completed: function(event) {
return this._rpc({
model: this.modelName,
method: "unlink",
args: [[event.data.item.id]],
context: this.getSession().user_context,
}).then(() => {
let unlink_index = false;
for (var i = 0; i < this.model.data.data.length; i++) {
if (this.model.data.data[i].id === event.data.item.id) {
unlink_index = i;
}
}
if (!isNaN(unlink_index)) {
this.model.data.data.splice(unlink_index, 1);
}
event.data.callback(event.data.item);
});
},
});
return TimelineController;
});

View File

@ -0,0 +1,73 @@
odoo.define("web_timeline.TimelineModel", function(require) {
"use strict";
const AbstractModel = require("web.AbstractModel");
const TimelineModel = AbstractModel.extend({
init: function() {
this._super.apply(this, arguments);
},
load: function(params) {
this.modelName = params.modelName;
this.fieldNames = params.fieldNames;
if (!this.preload_def) {
this.preload_def = $.Deferred();
$.when(
this._rpc({
model: this.modelName,
method: "check_access_rights",
args: ["write", false],
}),
this._rpc({
model: this.modelName,
method: "check_access_rights",
args: ["unlink", false],
}),
this._rpc({
model: this.modelName,
method: "check_access_rights",
args: ["create", false],
})
).then((write, unlink, create) => {
this.write_right = write;
this.unlink_right = unlink;
this.create_right = create;
this.preload_def.resolve();
});
}
this.data = {
domain: params.domain,
context: params.context,
};
return this.preload_def.then(this._loadTimeline.bind(this));
},
/**
* Read the records for the timeline.
*
* @private
* @returns {jQuery.Deferred}
*/
_loadTimeline: function() {
return this._rpc({
model: this.modelName,
method: "search_read",
context: this.data.context,
fields: this.fieldNames,
domain: this.data.domain,
}).then(events => {
this.data.data = events;
this.data.rights = {
unlink: this.unlink_right,
create: this.create_right,
write: this.write_right,
};
});
},
});
return TimelineModel;
});

View File

@ -0,0 +1,590 @@
/* global vis, py */
odoo.define("web_timeline.TimelineRenderer", function(require) {
"use strict";
const AbstractRenderer = require("web.AbstractRenderer");
const core = require("web.core");
const time = require("web.time");
const utils = require("web.utils");
const session = require("web.session");
const QWeb = require("web.QWeb");
const field_utils = require("web.field_utils");
const TimelineCanvas = require("web_timeline.TimelineCanvas");
const _t = core._t;
const TimelineRenderer = AbstractRenderer.extend({
template: "TimelineView",
events: _.extend({}, AbstractRenderer.prototype.events, {
"click .oe_timeline_button_today": "_onTodayClicked",
"click .oe_timeline_button_scale_day": "_onScaleDayClicked",
"click .oe_timeline_button_scale_week": "_onScaleWeekClicked",
"click .oe_timeline_button_scale_month": "_onScaleMonthClicked",
"click .oe_timeline_button_scale_year": "_onScaleYearClicked",
}),
init: function(parent, state, params) {
this._super.apply(this, arguments);
this.modelName = params.model;
this.mode = params.mode;
this.options = params.options;
this.min_height = params.min_height;
this.date_start = params.date_start;
this.date_stop = params.date_stop;
this.date_delay = params.date_delay;
this.colors = params.colors;
this.fieldNames = params.fieldNames;
this.dependency_arrow = params.dependency_arrow;
this.modelClass = params.view.model;
this.fields = params.fields;
this.timeline = false;
},
/**
* @override
*/
start: function() {
const attrs = this.arch.attrs;
this.current_window = {
start: new moment(),
end: new moment().add(24, "hours"),
};
this.$el.addClass(attrs.class);
this.$timeline = this.$(".oe_timeline_widget");
if (!this.date_start) {
throw new Error(
_t("Timeline view has not defined 'date_start' attribute.")
);
}
this._super.apply(this, arguments);
},
/**
* Triggered when the timeline is attached to the DOM.
*/
on_attach_callback: function() {
const height =
this.$el.parent().height() - this.$(".oe_timeline_buttons").height();
if (height > this.min_height && this.timeline) {
this.timeline.setOptions({
height: height,
});
}
},
/**
* @override
*/
_render: function() {
return Promise.resolve().then(() => {
// Prevent Double Rendering on Updates
if (!this.timeline) {
this.init_timeline();
$(window).trigger("resize");
}
});
},
/**
* Set the timeline window to today (day).
*
* @private
*/
_onTodayClicked: function() {
this.current_window = {
start: new moment(),
end: new moment().add(24, "hours"),
};
if (this.timeline) {
this.timeline.setWindow(this.current_window);
}
},
/**
* Scale the timeline window to a day.
*
* @private
*/
_onScaleDayClicked: function() {
this._scaleCurrentWindow(24);
},
/**
* Scale the timeline window to a week.
*
* @private
*/
_onScaleWeekClicked: function() {
this._scaleCurrentWindow(24 * 7);
},
/**
* Scale the timeline window to a month.
*
* @private
*/
_onScaleMonthClicked: function() {
this._scaleCurrentWindow(
24 * moment(this.current_window.start).daysInMonth()
);
},
/**
* Scale the timeline window to a year.
*
* @private
*/
_onScaleYearClicked: function() {
this._scaleCurrentWindow(
24 * (moment(this.current_window.start).isLeapYear() ? 366 : 365)
);
},
/**
* Scales the timeline window based on the current window.
*
* @param {Integer} factor The timespan (in hours) the window must be scaled to.
* @private
*/
_scaleCurrentWindow: function(factor) {
if (this.timeline) {
this.current_window = this.timeline.getWindow();
this.current_window.end = moment(this.current_window.start).add(
factor,
"hours"
);
this.timeline.setWindow(this.current_window);
}
},
/**
* Computes the initial visible window.
*
* @private
*/
_computeMode: function() {
if (this.mode) {
let start = false,
end = false;
switch (this.mode) {
case "day":
start = new moment().startOf("day");
end = new moment().endOf("day");
break;
case "week":
start = new moment().startOf("week");
end = new moment().endOf("week");
break;
case "month":
start = new moment().startOf("month");
end = new moment().endOf("month");
break;
}
if (end && start) {
this.options.start = start;
this.options.end = end;
} else {
this.mode = "fit";
}
}
},
/**
* Initializes the timeline
* (https://visjs.github.io/vis-timeline/docs/timeline).
*
* @private
*/
init_timeline: function() {
this._computeMode();
this.options.editable = {
// Add new items by double tapping
add: this.modelClass.data.rights.create,
// Drag items horizontally
updateTime: this.modelClass.data.rights.write,
// Drag items from one group to another
updateGroup: this.modelClass.data.rights.write,
// Delete an item by tapping the delete button top right
remove: this.modelClass.data.rights.unlink,
};
$.extend(this.options, {
onAdd: this.on_add,
onMove: this.on_move,
onUpdate: this.on_update,
onRemove: this.on_remove,
});
this.qweb = new QWeb(session.debug, {_s: session.origin}, false);
if (this.arch.children.length) {
const tmpl = utils.json_node_to_xml(
_.filter(this.arch.children, item => item.tag === "templates")[0]
);
this.qweb.add_template(tmpl);
}
this.timeline = new vis.Timeline(this.$timeline.get(0));
this.timeline.setOptions(this.options);
if (this.mode && this["on_scale_" + this.mode + "_clicked"]) {
this["on_scale_" + this.mode + "_clicked"]();
}
this.timeline.on("click", this.on_group_click);
const group_bys = this.arch.attrs.default_group_by.split(",");
this.last_group_bys = group_bys;
this.last_domains = this.modelClass.data.domain;
this.on_data_loaded(this.modelClass.data.data, group_bys);
this.$centerContainer = $(this.timeline.dom.centerContainer);
this.canvas = new TimelineCanvas(this);
this.canvas.appendTo(this.$centerContainer);
this.timeline.on("changed", () => {
this.draw_canvas();
});
},
/**
* Clears and draws the canvas items.
*
* @private
*/
draw_canvas: function() {
this.canvas.clear();
if (this.dependency_arrow) {
this.draw_dependencies();
}
},
/**
* Draw item dependencies on canvas.
*
* @private
*/
draw_dependencies: function() {
const items = this.timeline.itemSet.items;
const datas = this.timeline.itemsData;
if (!items || !datas) {
return;
}
const keys = Object.keys(items);
for (const key of keys) {
const item = items[key];
const data = datas._data[key];
if (!data || !data.evt) {
return;
}
for (const id of data.evt[this.dependency_arrow]) {
if (keys.indexOf(id.toString()) !== -1) {
this.draw_dependency(item, items[id]);
}
}
}
},
/**
* Draws a dependency arrow between 2 timeline items.
*
* @param {Object} from Start timeline item
* @param {Object} to Destination timeline item
* @param {Object} options
* @param {Object} options.line_color Color of the line
* @param {Object} options.line_width The width of the line
* @private
*/
draw_dependency: function(from, to, options) {
if (!from.displayed || !to.displayed) {
return;
}
const defaults = _.defaults({}, options, {
line_color: "black",
line_width: 1,
});
this.canvas.draw_arrow(
from.dom.box,
to.dom.box,
defaults.line_color,
defaults.line_width
);
},
/**
* Load display_name of records.
*
* @param {Object[]} events
* @param {String[]} group_bys
* @param {Boolean} adjust_window
* @private
* @returns {jQuery.Deferred}
*/
on_data_loaded: function(events, group_bys, adjust_window) {
const ids = _.pluck(events, "id");
return this._rpc({
model: this.modelName,
method: "name_get",
args: [ids],
context: this.getSession().user_context,
}).then(names => {
const nevents = _.map(events, event =>
_.extend(
{
__name: _.detect(names, name => name[0] === event.id)[1],
},
event
)
);
return this.on_data_loaded_2(nevents, group_bys, adjust_window);
});
},
/**
* Set groups and events.
*
* @param {Object[]} events
* @param {String[]} group_bys
* @param {Boolean} adjust_window
* @private
*/
on_data_loaded_2: function(events, group_bys, adjust_window) {
const data = [];
this.grouped_by = group_bys;
for (const evt of events) {
if (evt[this.date_start]) {
data.push(this.event_data_transform(evt));
}
}
const groups = this.split_groups(events, group_bys);
this.timeline.setGroups(groups);
this.timeline.setItems(data);
const mode = !this.mode || this.mode === "fit";
const adjust = _.isUndefined(adjust_window) || adjust_window;
if (mode && adjust) {
this.timeline.fit();
}
},
/**
* Get the groups.
*
* @param {Object[]} events
* @param {String[]} group_bys
* @private
* @returns {Array}
*/
split_groups: function(events, group_bys) {
if (group_bys.length === 0) {
return events;
}
const groups = [];
groups.push({id: -1, content: _t("<b>UNASSIGNED</b>")});
for (const evt of events) {
const group_name = evt[_.first(group_bys)];
if (group_name) {
if (group_name instanceof Array) {
const group = _.find(
groups,
existing_group => existing_group.id === group_name[0]
);
if (_.isUndefined(group)) {
groups.push({
id: group_name[0],
content: group_name[1],
});
}
}
}
}
return groups;
},
/**
* Get dates from given event
*
* @param {TransformEvent} evt
* @returns {Object}
*/
_get_event_dates: function(evt) {
let date_start = new moment();
let date_stop = null;
const date_delay = evt[this.date_delay] || false,
all_day = this.all_day ? evt[this.all_day] : false;
if (all_day) {
date_start = time.auto_str_to_date(
evt[this.date_start].split(" ")[0],
"start"
);
if (this.no_period) {
date_stop = date_start;
} else {
date_stop = this.date_stop
? time.auto_str_to_date(
evt[this.date_stop].split(" ")[0],
"stop"
)
: null;
}
} else {
date_start = time.auto_str_to_date(evt[this.date_start]);
date_stop = this.date_stop
? time.auto_str_to_date(evt[this.date_stop])
: null;
}
if (!date_stop && date_delay) {
date_stop = date_start
.clone()
.add(date_delay, "hours")
.toDate();
}
return [date_start, date_stop];
},
/**
* Transform Odoo event object to timeline event object.
*
* @param {TransformEvent} evt
* @private
* @returns {Object}
*/
event_data_transform: function(evt) {
const [date_start, date_stop] = this._get_event_dates(evt);
let group = evt[this.last_group_bys[0]];
if (group && group instanceof Array) {
group = _.first(group);
} else {
group = -1;
}
for (const color of this.colors) {
if (py.eval(`'${evt[color.field]}' ${color.opt} '${color.value}'`)) {
this.color = color.color;
}
}
let content = evt.__name || evt.display_name;
if (this.arch.children.length) {
content = this.render_timeline_item(evt);
}
const r = {
start: date_start,
content: content,
id: evt.id,
group: group,
evt: evt,
style: `background-color: ${this.color};`,
};
// Check if the event is instantaneous,
// if so, display it with a point on the timeline (no 'end')
if (date_stop && !moment(date_start).isSame(date_stop)) {
r.end = date_stop;
}
this.color = null;
return r;
},
/**
* Render timeline item template.
*
* @param {Object} evt Record
* @private
* @returns {String} Rendered template
*/
render_timeline_item: function(evt) {
if (this.qweb.has_template("timeline-item")) {
return this.qweb.render("timeline-item", {
record: evt,
field_utils: field_utils,
});
}
console.error(
_t('Template "timeline-item" not present in timeline view definition.')
);
},
/**
* Handle a click on a group header.
*
* @param {ClickEvent} e
* @private
*/
on_group_click: function(e) {
if (e.what === "group-label" && e.group !== -1) {
this._trigger(
e,
() => {
// Do nothing
},
"onGroupClick"
);
}
},
/**
* Trigger onUpdate.
*
* @param {Object} item
* @param {Function} callback
* @private
*/
on_update: function(item, callback) {
this._trigger(item, callback, "onUpdate");
},
/**
* Trigger onMove.
*
* @param {Object} item
* @param {Function} callback
* @private
*/
on_move: function(item, callback) {
this._trigger(item, callback, "onMove");
},
/**
* Trigger onRemove.
*
* @param {Object} item
* @param {Function} callback
* @private
*/
on_remove: function(item, callback) {
this._trigger(item, callback, "onRemove");
},
/**
* Trigger onAdd.
*
* @param {Object} item
* @param {Function} callback
* @private
*/
on_add: function(item, callback) {
this._trigger(item, callback, "onAdd");
},
/**
* Trigger_up encapsulation adds by default the rights, and the renderer.
*
* @param {HTMLElement} item
* @param {Function} callback
* @param {String} trigger
* @private
*/
_trigger: function(item, callback, trigger) {
this.trigger_up(trigger, {
item: item,
callback: callback,
rights: this.modelClass.data.rights,
renderer: this,
});
},
});
return TimelineRenderer;
});

View File

@ -0,0 +1,186 @@
/* global py */
/* Odoo web_timeline
* Copyright 2015 ACSONE SA/NV
* Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
odoo.define("web_timeline.TimelineView", function(require) {
"use strict";
const core = require("web.core");
const utils = require("web.utils");
const view_registry = require("web.view_registry");
const AbstractView = require("web.AbstractView");
const TimelineRenderer = require("web_timeline.TimelineRenderer");
const TimelineController = require("web_timeline.TimelineController");
const TimelineModel = require("web_timeline.TimelineModel");
const _lt = core._lt;
function isNullOrUndef(value) {
return _.isUndefined(value) || _.isNull(value);
}
var TimelineView = AbstractView.extend({
display_name: _lt("Timeline"),
icon: "fa-tasks",
jsLibs: ["/web_timeline/static/lib/vis-timeline/vis-timeline-graph2d.min.js"],
cssLibs: ["/web_timeline/static/lib/vis-timeline/vis-timeline-graph2d.min.css"],
config: {
Model: TimelineModel,
Controller: TimelineController,
Renderer: TimelineRenderer,
},
/**
* @override
*/
init: function(viewInfo, params) {
this._super.apply(this, arguments);
this.modelName = this.controllerParams.modelName;
const action = params.action;
this.arch = this.rendererParams.arch;
const attrs = this.arch.attrs;
const date_start = attrs.date_start;
const date_stop = attrs.date_stop;
const date_delay = attrs.date_delay;
const dependency_arrow = attrs.dependency_arrow;
const fields = viewInfo.fields;
let fieldNames = fields.display_name ? ["display_name"] : [];
const fieldsToGather = [
"date_start",
"date_stop",
"default_group_by",
"progress",
"date_delay",
attrs.default_group_by,
];
for (const field of fieldsToGather) {
if (attrs[field]) {
fieldNames.push(attrs[field]);
}
}
const archFieldNames = _.map(
_.filter(this.arch.children, item => item.tag === "field"),
item => item.attrs.name
);
fieldNames = _.union(fieldNames, archFieldNames);
const colors = this.parse_colors();
for (const color of colors) {
fieldNames.push(color.field);
}
if (dependency_arrow) {
fieldNames.push(dependency_arrow);
}
const mode = attrs.mode || attrs.default_window || "fit";
const min_height = attrs.min_height || 300;
const current_window = {
start: new moment(),
end: new moment().add(24, "hours"),
};
if (!isNullOrUndef(attrs.quick_create_instance)) {
this.quick_create_instance = "instance." + attrs.quick_create_instance;
}
let open_popup_action = false;
if (
!isNullOrUndef(attrs.event_open_popup) &&
utils.toBoolElse(attrs.event_open_popup, true)
) {
open_popup_action = attrs.event_open_popup;
}
this.rendererParams.mode = mode;
this.rendererParams.model = this.modelName;
this.rendererParams.view = this;
this.rendererParams.options = this._preapre_vis_timeline_options(attrs);
this.rendererParams.current_window = current_window;
this.rendererParams.date_start = date_start;
this.rendererParams.date_stop = date_stop;
this.rendererParams.date_delay = date_delay;
this.rendererParams.colors = colors;
this.rendererParams.fieldNames = fieldNames;
this.rendererParams.min_height = min_height;
this.rendererParams.dependency_arrow = dependency_arrow;
this.rendererParams.fields = fields;
this.loadParams.modelName = this.modelName;
this.loadParams.fieldNames = fieldNames;
this.controllerParams.open_popup_action = open_popup_action;
this.controllerParams.date_start = date_start;
this.controllerParams.date_stop = date_stop;
this.controllerParams.date_delay = date_delay;
this.controllerParams.actionContext = action.context;
this.withSearchPanel = false;
},
_preapre_vis_timeline_options: function(attrs) {
return {
groupOrder: this.group_order,
orientation: "both",
selectable: true,
multiselect: true,
showCurrentTime: true,
stack: isNullOrUndef(attrs.stack)
? true
: utils.toBoolElse(attrs.stack, true),
margin: attrs.margin ? JSON.parse(attrs.margin) : {item: 2},
zoomKey: attrs.zoomKey || "ctrlKey",
};
},
/**
* Order function for groups.
* @param {Object} grp1
* @param {Object} grp2
* @returns {Integer}
*/
group_order: function(grp1, grp2) {
// Display non grouped elements first
if (grp1.id === -1) {
return -1;
}
if (grp2.id === -1) {
return 1;
}
return grp1.content.localeCompare(grp2.content);
},
/**
* Parse the colors attribute.
*
* @private
* @returns {Array}
*/
parse_colors: function() {
if (this.arch.attrs.colors) {
return _(this.arch.attrs.colors.split(";"))
.chain()
.compact()
.map(color_pair => {
const pair = color_pair.split(":");
const color = pair[0];
const expr = pair[1];
const temp = py.parse(py.tokenize(expr));
return {
color: color,
field: temp.expressions[0].value,
opt: temp.operators[0],
value: temp.expressions[1].value,
};
})
.value();
}
return [];
},
});
view_registry.add("timeline", TimelineView);
return TimelineView;
});

View File

@ -0,0 +1,32 @@
$vis-weekend-background-color: #dcdcdc;
$vis-item-content-padding: 0 3px !important;
.oe_timeline_view .vis-timeline {
.vis-grid {
&.vis-saturday,
&.vis-sunday {
background: $vis-weekend-background-color;
}
}
.vis-item {
&.vis-box:hover {
cursor: pointer !important;
}
&.vis-item-overflow {
overflow: visible;
}
.vis-item-content {
padding: $vis-item-content-padding;
}
}
}
.oe_timeline_view_canvas {
pointer-events: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<template>
<t t-name="TimelineView">
<div class="oe_timeline_view">
<div class="oe_timeline_buttons">
<button
class="btn btn-default btn-sm oe_timeline_button_today"
>Today</button>
<div class="btn-group btn-sm">
<button
class="btn btn-default oe_timeline_button_scale_day"
>Day</button>
<button
class="btn btn-default oe_timeline_button_scale_week"
>Week</button>
<button
class="btn btn-default oe_timeline_button_scale_month"
>Month</button>
<button
class="btn btn-default oe_timeline_button_scale_year"
>Year</button>
</div>
</div>
<div class="oe_timeline_widget" />
</div>
</t>
<svg t-name="TimelineView.Canvas" class="oe_timeline_view_canvas">
<defs>
<marker
id="arrowhead"
markerWidth="10"
markerHeight="7"
refX="10"
refY="3.5"
orient="auto"
>
<polygon points="10 0, 10 7, 0 3.5" />
</marker>
</defs>
</svg>
</template>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="assets_backend"
name="web_timeline assets"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<link
rel="stylesheet"
type="text/css"
href="/web_timeline/static/lib/vis-timeline/vis-timeline-graph2d.css"
/>
<link
rel="stylesheet"
type="text/scss"
href="/web_timeline/static/src/scss/web_timeline.scss"
/>
<script
type="text/javascript"
src="/web_timeline/static/lib/vis-timeline/vis-timeline-graph2d.min.js"
/>
<script
type="text/javascript"
src="/web_timeline/static/src/js/timeline_view.js"
/>
<script
type="text/javascript"
src="/web_timeline/static/src/js/timeline_renderer.js"
/>
<script
type="text/javascript"
src="/web_timeline/static/src/js/timeline_controller.js"
/>
<script
type="text/javascript"
src="/web_timeline/static/src/js/timeline_model.js"
/>
<script
type="text/javascript"
src="/web_timeline/static/src/js/timeline_canvas.js"
/>
</xpath>
</template>
</odoo>