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 Jun 26, 2023
1 parent 6e160e3 commit 8931632
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
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
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
43 changes: 43 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,43 @@
# 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}
else:
group["__range"][field_name] = 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]>

0 comments on commit 8931632

Please sign in to comment.