Skip to content

Commit

Permalink
[MIG] web_timeline: Migration to 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza authored and bvanjeelharia committed Mar 1, 2023
1 parent 1379a70 commit 5df300f
Show file tree
Hide file tree
Showing 7 changed files with 307 additions and 359 deletions.
120 changes: 90 additions & 30 deletions web_timeline/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,106 @@
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

===============
Timeline Widget
===============
=============
Timeline view
=============

Define a new widget displaying events in an interactive visualization chart.
Define a new view displaying events in an interactive visualization chart.

The widget is based on the external library
http://visjs.org/timeline_examples.html

Usage
=====
Configuration
=============

You need to define a view with the tag <timeline> as base element. These are
the possible attributes for the tag:

* date_start (required): it defines the name of the field of type date that
contains the start of the event.
* date_end (optional): it defines the name of the field of type date that
contains the end of the event.
* date_delay (optional): it defines the name of the field of type date that
contains the end of the event.
* default_group_by (required): it 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.
* event_open_popup (optional): 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.
* colors (optional): it allows to set certain specific colors if the expressed
condition (JS syntax) is met.

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"?>
<openerp>
<data>

<record id="view_task_timeline" model="ir.ui.view">
<field name="name">project.task.timeline</field>
<field name="model">project.task</field>
<field name="type">timeline</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<timeline date_start="date_start"
date_stop="date_end"
date_delay='1'
string="Tasks"
default_group_by="user_id" event_open_popup="true" colors="#ec7063:user_id == false;#2ecb71:kanban_state=='done';">
</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>
</data>
</openerp>
<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_start"
date_stop="date_end"
string="Tasks"
default_group_by="user_id"
event_open_popup="true"
colors="#ec7063:user_id == false;#2ecb71:kanban_state=='done';">
</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.


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162/8.0

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

* Implement support for vis.js timeline range item addition (with Ctrl key
pressed).
* Implement a more efficient way of refreshing timeline after a record update.

Bug Tracker
===========

Expand All @@ -65,6 +123,8 @@ 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>

Maintainer
----------
Expand All @@ -77,4 +137,4 @@ This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.
14 changes: 7 additions & 7 deletions web_timeline/__openerp__.py → web_timeline/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

{
'name': "Web timeline",
'summary': """
Interactive visualization chart to visualize events in time
""",
"version": "8.0.1.0.0",
'author': 'ACSONE SA/NV,'
'summary': "Interactive visualization chart to show events in time",
"version": "10.0.1.0.0",
'author': 'ACSONE SA/NV, '
'Tecnativa, '
'Monk Software, ',
'Odoo Community Association (OCA)',
"category": "Tools",
"category": "web",
"website": "http://acsone.eu",
'depends': [
'web'
'web',
],
'qweb': [
'static/src/xml/web_timeline.xml',
Expand Down
15 changes: 2 additions & 13 deletions web_timeline/models/ir_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models
from openerp import api
from openerp import fields, models


TIMELINE_VIEW = ('timeline', 'Timeline')
Expand All @@ -12,14 +11,4 @@
class IrUIView(models.Model):
_inherit = 'ir.ui.view'

@api.model
def _setup_fields(self):
"""Hack due since the field 'type' is not defined with the new api.
"""
cls = type(self)
type_selection = cls._fields['type'].selection
if TIMELINE_VIEW not in type_selection:
tmp = list(type_selection)
tmp.append(TIMELINE_VIEW)
cls._fields['type'].selection = tuple(set(tmp))
super(IrUIView, self)._setup_fields()
type = fields.Selection(selection_add=[TIMELINE_VIEW])
Binary file added web_timeline/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 4 additions & 24 deletions web_timeline/static/src/css/web_timeline.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,19 @@
.openerp .oe_view_manager .oe_view_manager_switch .oe_vm_switch_timeline:after {
content: "N";
}
.timeline-navigation-zoom-in .ui-icon{
background: none !important;
}

.timeline-navigation-zoom-out .ui-icon{
background: none !important;
}
.timeline-navigation-move-left .ui-icon{
background: none !important;
}
.timeline-navigation-move-right .ui-icon{
background: none !important;
}
/*.vis.timeline .timeaxis .grid.odd {
background: #f5f5f5;
} */

/* gray background in weekends, white text color */
/* very light gray background in weekends */
.vis.timeline .timeaxis .grid.saturday,
.vis.timeline .timeaxis .grid.sunday {
background: gray;
background: #DCDCDC;
}
/* .vis.timeline .timeaxis .text.saturday,
.vis.timeline .timeaxis .text.sunday {
color: white;
} */

.vis.timeline .item.range .content {
overflow: visible;
overflow: visible;
}

.oe_chatter_toggle {
padding: 15px;
padding: 15px;
}

.oe_timeline_view .vlabel .inner:hover{
Expand Down
Loading

0 comments on commit 5df300f

Please sign in to comment.