Skip to content

Commit

Permalink
[14.0][BACKPORT] project_forecast_line_bokeh_chart from 15.0 to 14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsirintanis committed Mar 21, 2024
1 parent 7721b37 commit 5be7294
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 38 deletions.
41 changes: 29 additions & 12 deletions project_forecast_line_bokeh_chart/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,39 @@
Project Forecast Lines Bokeh Chart
==================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c3531fb0c734d3d8fc5b939e61ebcdb3578fb6f36ffa26ee23a2a21c90907610
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github
:target: https://github.com/OCA/project/tree/15.0/project_forecast_line_bokeh_chart
:target: https://github.com/OCA/project/tree/14.0/project_forecast_line_bokeh_chart
:alt: OCA/project
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/project-15-0/project-15-0-project_forecast_line_bokeh_chart
:target: https://translation.odoo-community.org/projects/project-14-0/project-14-0-project_forecast_line_bokeh_chart
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/140/15.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/project&target_branch=14.0
:alt: Try me on Runboat

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

This module improves the reports of project_forecast_line by using the bokeh widget available in OCA/web.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
Expand All @@ -37,8 +45,8 @@ Bug Tracker

Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/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/project/issues/new?body=module:%20project_forecast_line_bokeh_chart%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_forecast_line_bokeh_chart%0Aversion:%2014.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.

Expand All @@ -54,6 +62,7 @@ Contributors
~~~~~~~~~~~~

* Alexandre Fayolle <[email protected]>
* Nikos Tsirintanis <[email protected]>

Maintainers
~~~~~~~~~~~
Expand All @@ -68,6 +77,14 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/project <https://github.com/OCA/project/tree/15.0/project_forecast_line_bokeh_chart>`_ project on GitHub.
.. |maintainer-ntsirintanis| image:: https://github.com/ntsirintanis.png?size=40px
:target: https://github.com/ntsirintanis
:alt: ntsirintanis

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-ntsirintanis|

This module is part of the `OCA/project <https://github.com/OCA/project/tree/14.0/project_forecast_line_bokeh_chart>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions project_forecast_line_bokeh_chart/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import report
4 changes: 3 additions & 1 deletion project_forecast_line_bokeh_chart/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
{
"name": "Project Forecast Lines Bokeh Chart",
"summary": "Project Forecast Lines Bokeh Chart",
"version": "15.0.1.0.1",
"version": "14.0.1.0.1",
"author": "Camptocamp SA, Odoo Community Association (OCA)",
"maintainers": ["ntsirintanis"],
"license": "AGPL-3",
"category": "Project",
"website": "https://github.com/OCA/project",
Expand All @@ -13,5 +14,6 @@
"security/ir.model.access.csv",
"report/forecast_line_reporting_views.xml",
],
"development_status": "Alpha",
"installable": True,
}
1 change: 1 addition & 0 deletions project_forecast_line_bokeh_chart/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import forecast_line
47 changes: 47 additions & 0 deletions project_forecast_line_bokeh_chart/models/forecast_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2022 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, models


class ForecastLine(models.Model):

_inherit = "forecast.line"

@api.model
def _read_group_raw(
self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True
):
"""
Inherit and add __range key, like in odoo 15
https://github.com/odoo/odoo/blob/15.0/odoo/models.py#L2431
"""
result = super()._read_group_raw(
domain,
fields,
groupby,
offset=offset,
limit=limit,
orderby=orderby,
lazy=lazy,
)
dt = [
f
for f in groupby
if self._fields[f.split(":")[0]].type
in ("date", "datetime") # e.g. 'date:month'
]
for group in result:
if dt:
group["__range"] = {}
for df in dt:
field_name = df.split(":")[0]
if group.get(df):
range_from, range_to = group[df][0].split("/")
group["__range"][field_name] = {"from": range_from, "to": range_to}
# Inject another date key in the result
# for easier retrieval later on
group["forecast_date_start"] = range_from
else:
group["__range"][field_name] = False
group["forecast_date_start"] = False
return result
1 change: 1 addition & 0 deletions project_forecast_line_bokeh_chart/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* Alexandre Fayolle <[email protected]>
* Nikos Tsirintanis <[email protected]>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import json

# pylint: disable=W7936
from bokeh import palettes
Expand Down Expand Up @@ -38,9 +37,7 @@ class ForecastLineReporting(models.TransientModel):
@api.onchange("project_ids")
def onchange_project_ids(self):
if self.project_ids:
self.employee_ids |= self.project_ids.mapped(
"task_ids.user_ids.employee_ids"
)
self.employee_ids |= self.project_ids.mapped("task_ids.user_id.employee_id")

@api.depends("date_from", "nb_months", "employee_ids", "granularity", "project_ids")
def _compute_bokeh_chart(self):
Expand All @@ -52,8 +49,8 @@ def _compute_bokeh_chart(self):
# period.
plots = self._build_plots()
grid = column(*plots)
script, div = components(grid, wrap_script=False)
self.bokeh_chart = json.dumps({"div": div, "script": script})
script, div = components(grid)
self.bokeh_chart = "%s%s" % (div, script)

def _prepare_bokeh_chart_data(self):
"""compute the data that will be plotted.
Expand Down Expand Up @@ -116,7 +113,7 @@ def _prepare_bokeh_chart_data(self):
data_project[employee] = {}
data_overload[employee] = {}
forecast = d["consolidated_forecast"]
date = d["__range"]["date_from"]["from"]
date = d["forecast_date_start"]
project = d.get("project_id")
if project:
project = project[1]._value
Expand Down
47 changes: 29 additions & 18 deletions project_forecast_line_bokeh_chart/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<?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/" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Project Forecast Lines Bokeh Chart</title>
<style type="text/css">

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z 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
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

Expand Down Expand Up @@ -366,51 +366,62 @@ <h1 class="title">Project Forecast Lines Bokeh Chart</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c3531fb0c734d3d8fc5b939e61ebcdb3578fb6f36ffa26ee23a2a21c90907610
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.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/project/tree/15.0/project_forecast_line_bokeh_chart"><img alt="OCA/project" src="https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/project-15-0/project-15-0-project_forecast_line_bokeh_chart"><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/140/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" 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 image-reference" href="https://github.com/OCA/project/tree/14.0/project_forecast_line_bokeh_chart"><img alt="OCA/project" src="https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/project-14-0/project-14-0-project_forecast_line_bokeh_chart"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/project&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module improves the reports of project_forecast_line by using the bokeh widget available in OCA/web.</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
<a class="reference external" href="https://odoo-community.org/page/development-status">More details on development status</a></p>
</div>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/project/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/project/issues/new?body=module:%20project_forecast_line_bokeh_chart%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/project/issues/new?body=module:%20project_forecast_line_bokeh_chart%0Aversion:%2014.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="#id2">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<ul class="simple">
<li>Camptocamp SA</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>Alexandre Fayolle &lt;<a class="reference external" href="mailto:alexandre.fayolle&#64;camptocamp.com">alexandre.fayolle&#64;camptocamp.com</a>&gt;</li>
<li>Nikos Tsirintanis &lt;<a class="reference external" href="mailto:ntsirintanis&#64;therp.nl">ntsirintanis&#64;therp.nl</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">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>This module is part of the <a class="reference external" href="https://github.com/OCA/project/tree/15.0/project_forecast_line_bokeh_chart">OCA/project</a> project on GitHub.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/ntsirintanis"><img alt="ntsirintanis" src="https://github.com/ntsirintanis.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/project/tree/14.0/project_forecast_line_bokeh_chart">OCA/project</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>
Expand Down
6 changes: 6 additions & 0 deletions setup/project_forecast_line_bokeh_chart/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 5be7294

Please sign in to comment.