Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.0][PORT] 292 from 10.0 #293

Merged
merged 1 commit into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion mis_builder/models/mis_kpi_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def _compute_name(self):
rec.date_to,
)

@api.model
def _intersect_days(self, item_dt_from, item_dt_to, dt_from, dt_to):
return intersect_days(item_dt_from, item_dt_to, dt_from, dt_to)

@api.model
def _query_kpi_data(self, date_from, date_to, base_domain):
"""Query mis.kpi.data over a time period.
Expand All @@ -85,7 +89,9 @@ def _query_kpi_data(self, date_from, date_to, base_domain):
for item in self.search(domain):
item_dt_from = fields.Date.from_string(item.date_from)
item_dt_to = fields.Date.from_string(item.date_to)
i_days, item_days = intersect_days(item_dt_from, item_dt_to, dt_from, dt_to)
i_days, item_days = self._intersect_days(
item_dt_from, item_dt_to, dt_from, dt_to
)
if item.kpi_expression_id.kpi_id.accumulation_method == ACC_SUM:
# accumulate pro-rata overlap between item and reporting period
res[item.kpi_expression_id] += item.amount * i_days / item_days
Expand Down
6 changes: 5 additions & 1 deletion mis_builder/models/prorata_read_group_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def _search_date(self, operator, value):
_("Unsupported operator %s for searching on date") % (operator,)
)

@api.model
def _intersect_days(self, item_dt_from, item_dt_to, dt_from, dt_to):
return intersect_days(item_dt_from, item_dt_to, dt_from, dt_to)

@api.model
def read_group(
self, domain, flds, groupby, offset=0, limit=None, orderby=False, lazy=True
Expand Down Expand Up @@ -75,7 +79,7 @@ def read_group(
for sum_field in sum_fields:
item_dt_from = fields.Date.from_string(item["date_from"])
item_dt_to = fields.Date.from_string(item["date_to"])
i_days, item_days = intersect_days(
i_days, item_days = self._intersect_days(
item_dt_from, item_dt_to, dt_from, dt_to
)
res_item[sum_field] += item[sum_field] * i_days / item_days
Expand Down
3 changes: 3 additions & 0 deletions mis_builder/readme/newsfragments/280.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The ``_intersect_date`` model method has been restored on ``mis.kpi.data``,
and added on ``prorata.read_group.mixin`` as a semi-supported way to override
the pro-rata temporis budget reporting mechanism.