Skip to content
Snippets Groups Projects
Commit 43817492 authored by Thibault Delavallée's avatar Thibault Delavallée
Browse files

[IMP] digest: correctly support studio fields in digest

Studio fields are prefixed by x_studio, not only x_ which are simple custom
fields. This commit update the field name check to correctly include fields
created through studio.

As studio automatically add x_studio as prefix help is updated to tell
users to only use kpi_ as prefix for their digest fields. Result will
be x_studio_kpi_foo and x_studio_kpi_foo_value which are the value digest
needs to run.

This commit is linked to task ID 1887619.
parent ae1fed50
Branches
Tags
No related merge requests found
......@@ -51,7 +51,7 @@ class Digest(models.Model):
for digest in self:
kpis_values_fields = []
for field_name, field in digest._fields.items():
if field.type == 'boolean' and (field_name.startswith('kpi_') or field_name.startswith('x_kpi_')) and digest[field_name]:
if field.type == 'boolean' and field_name.startswith(('kpi_', 'x_kpi_', 'x_studio_kpi_')) and digest[field_name]:
kpis_values_fields += [field_name + '_value']
digest.available_fields = ', '.join(kpis_values_fields)
......@@ -112,7 +112,7 @@ class Digest(models.Model):
previous_digest = self.with_context(start_date=tf[1][0], end_date=tf[1][1], company=company).sudo(user.id)
kpis = {}
for field_name, field in self._fields.items():
if field.type == 'boolean' and (field_name.startswith('kpi_') or field_name.startswith('x_kpi_')) and self[field_name]:
if field.type == 'boolean' and field_name.startswith(('kpi_', 'x_kpi_', 'x_studio_kpi_')) and self[field_name]:
try:
compute_value = digest[field_name + '_value']
......
......@@ -76,12 +76,12 @@
</li>
<li>
first create a boolean field called
<code>x_kpi_myfield</code>
<code>kpi_myfield</code>
and display it in the KPI's tab;
</li>
<li>
then create a computed field called
<code>x_kpi_myfield_value</code>
<code>kpi_myfield_value</code>
that will compute your customized KPI.
</li>
</ul>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment