diff --git a/project_forecast_line_bokeh_chart/README.rst b/project_forecast_line_bokeh_chart/README.rst index b1ed759475..4dc3fe8053 100644 --- a/project_forecast_line_bokeh_chart/README.rst +++ b/project_forecast_line_bokeh_chart/README.rst @@ -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 `_ + **Table of contents** .. contents:: @@ -37,8 +45,8 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -54,6 +62,7 @@ Contributors ~~~~~~~~~~~~ * Alexandre Fayolle +* Nikos Tsirintanis Maintainers ~~~~~~~~~~~ @@ -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 `_ project on GitHub. +.. |maintainer-ntsirintanis| image:: https://github.com/ntsirintanis.png?size=40px + :target: https://github.com/ntsirintanis + :alt: ntsirintanis + +Current `maintainer `__: + +|maintainer-ntsirintanis| + +This module is part of the `OCA/project `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/project_forecast_line_bokeh_chart/__init__.py b/project_forecast_line_bokeh_chart/__init__.py index 4c4f242fa0..bf588bc8b8 100644 --- a/project_forecast_line_bokeh_chart/__init__.py +++ b/project_forecast_line_bokeh_chart/__init__.py @@ -1 +1,2 @@ +from . import models from . import report diff --git a/project_forecast_line_bokeh_chart/__manifest__.py b/project_forecast_line_bokeh_chart/__manifest__.py index 9ab681a19a..e350cb4085 100644 --- a/project_forecast_line_bokeh_chart/__manifest__.py +++ b/project_forecast_line_bokeh_chart/__manifest__.py @@ -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", @@ -13,5 +14,6 @@ "security/ir.model.access.csv", "report/forecast_line_reporting_views.xml", ], + "development_status": "Alpha", "installable": True, } diff --git a/project_forecast_line_bokeh_chart/models/__init__.py b/project_forecast_line_bokeh_chart/models/__init__.py new file mode 100644 index 0000000000..d4f5b72ba7 --- /dev/null +++ b/project_forecast_line_bokeh_chart/models/__init__.py @@ -0,0 +1 @@ +from . import forecast_line diff --git a/project_forecast_line_bokeh_chart/models/forecast_line.py b/project_forecast_line_bokeh_chart/models/forecast_line.py new file mode 100644 index 0000000000..da05c66d2a --- /dev/null +++ b/project_forecast_line_bokeh_chart/models/forecast_line.py @@ -0,0 +1,47 @@ +# Copyright 2022 Therp BV . +# 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 diff --git a/project_forecast_line_bokeh_chart/readme/CONTRIBUTORS.rst b/project_forecast_line_bokeh_chart/readme/CONTRIBUTORS.rst index 8785f72c06..b3c64a952a 100644 --- a/project_forecast_line_bokeh_chart/readme/CONTRIBUTORS.rst +++ b/project_forecast_line_bokeh_chart/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Alexandre Fayolle +* Nikos Tsirintanis diff --git a/project_forecast_line_bokeh_chart/report/forecast_line_reporting.py b/project_forecast_line_bokeh_chart/report/forecast_line_reporting.py index f87e3715a2..468ab92206 100644 --- a/project_forecast_line_bokeh_chart/report/forecast_line_reporting.py +++ b/project_forecast_line_bokeh_chart/report/forecast_line_reporting.py @@ -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 @@ -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): @@ -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. @@ -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 diff --git a/project_forecast_line_bokeh_chart/static/description/index.html b/project_forecast_line_bokeh_chart/static/description/index.html index d79b6f6b02..cddaf0c312 100644 --- a/project_forecast_line_bokeh_chart/static/description/index.html +++ b/project_forecast_line_bokeh_chart/static/description/index.html @@ -1,20 +1,20 @@ - + - + Project Forecast Lines Bokeh Chart