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

[16.0][IMP] mis_builder: introduce annotation in reports #676

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

AnizR
Copy link
Contributor

@AnizR AnizR commented Apr 3, 2025

This PR introduces 'annotation' in mis_builder reports.
An annotation is a comment or a remark that a user can write on a cell.

It tries to solve issue: #159 (opened 6 yeas ago!)

Description

The goal is to write a remark on a cell (independently of the pivot date).
These annotations are visible directly within the view but also at export in .pdf and in .xlsx.

Edit: 2 security groups have been introduced to allow edit and read of annotaitons

Overview

UI in mis_builder_widget

On cells, we have now a drop down menu to drill down or annotate:
image
It opens a window to write an annotation:
image
Before refreshing, annotations are pushed to the db, added in the 'footnotes' and if we try to 're-annotate', the annotation is displayed but the sequence is not yet set.
After refreshing, annotations are numbered. I did this to avoid the user to force to refresh his report each time he writes an annotation.
image

Print .pdf

The annotation is also present in the .pdf:
image

Export .xls

In the .xls, the annotation are added as 'comment' on cells:
image

@OCA-git-bot
Copy link
Contributor

Hi @sbidoul,
some modules you are maintaining are being modified, check this out!

@AnizR AnizR marked this pull request as draft April 3, 2025 09:05
@AnizR AnizR force-pushed the zra-mis-builder-annotation branch from e1171ed to 17e5985 Compare April 3, 2025 09:27
@AnizR AnizR marked this pull request as ready for review April 3, 2025 09:33
@sbidoul sbidoul added this to the 16.0 milestone Apr 3, 2025
@hitrosol
Copy link

hitrosol commented Apr 3, 2025

Long wait feature finally come.

I tried on runboat using Chrome, Edge and Safari. The drop down menu is behind the other row.

Screen Shot 2025-04-03 at 11 19 37 PM

It looks okay on Firefox, but no sequence number is added in the footnotes. If I refresh the browser the notes is gone.
Screen Shot 2025-04-03 at 11 21 59 PM

Thanks

@sbidoul
Copy link
Member

sbidoul commented Apr 3, 2025

Long wait feature finally come.

It was just waiting for someone to fund it.

@AnizR
Copy link
Contributor Author

AnizR commented Apr 3, 2025

Long wait feature finally come.

I tried on runboat using Chrome, Edge and Safari. The drop down menu is behind the other row.

Screen Shot 2025-04-03 at 11 19 37 PM

It looks okay on Firefox, but no sequence number is added in the footnotes. If I refresh the browser the notes is gone. Screen Shot 2025-04-03 at 11 21 59 PM

Thanks

Thanks for your feedback.
I am using firefox but I'll try to figure out why it doesn't work with other browsers.
Regarding the annotations, I opened your instance and indeed, it doesn't work with your column '3 M Budget' but it works with others. I'll fix it:
image

@AnizR AnizR force-pushed the zra-mis-builder-annotation branch from 17e5985 to 63ac433 Compare April 7, 2025 15:42
@AnizR
Copy link
Contributor Author

AnizR commented Apr 7, 2025

Long wait feature finally come.

I tried on runboat using Chrome, Edge and Safari. The drop down menu is behind the other row.

Screen Shot 2025-04-03 at 11 19 37 PM

It looks okay on Firefox, but no sequence number is added in the footnotes. If I refresh the browser the notes is gone. Screen Shot 2025-04-03 at 11 21 59 PM

Thanks

It should be fixed now.
Thanks for your feedback!

Copy link
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AnizR. Here is a first round of comment after a quick look.

@AnizR AnizR force-pushed the zra-mis-builder-annotation branch from 63ac433 to 267c047 Compare April 8, 2025 09:52
Copy link

@SAnnabelle SAnnabelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works well!

Would it be possible to make the annotations company-dependent? This would allow each company to have its own comments if the report is shared between several companies.

@AnizR AnizR force-pushed the zra-mis-builder-annotation branch from 267c047 to 9b9bb7b Compare April 9, 2025 10:01
@AnizR
Copy link
Contributor Author

AnizR commented Apr 9, 2025

It works well!

Would it be possible to make the annotations company-dependent? This would allow each company to have its own comments if the report is shared between several companies.

Thanks for your feedback!

Annotations are now linked to a company.
This company is the 'main' company of the user when creating the annotation.

@AnizR AnizR requested a review from SAnnabelle April 9, 2025 10:02
@sbidoul
Copy link
Member

sbidoul commented Apr 9, 2025

Annotations are now linked to a company.
This company is the 'main' company of the user when creating the annotation.

Is that not potentially surprising for the user?

For instance, what if it is a multi-company consolidation report?

@sbidoul
Copy link
Member

sbidoul commented Apr 9, 2025

I wonder to what extent the annotation should be linked to (some of) the filter values of the report (effective companies, pivot date, ...).

@AnizR
Copy link
Contributor Author

AnizR commented Apr 9, 2025

Annotations are now linked to a company.
This company is the 'main' company of the user when creating the annotation.

Is that not potentially surprising for the user?

For instance, what if it is a multi-company consolidation report?

I figured that the 'final user' would always use the same 'main company' when watching his report. Therefore, in my case, it makes sense to attach annotations to the 'main company'. What would you prefer? Storing every companies selected when watching the report?

I wonder to what extent the annotation should be linked to (some of) the filter values of the report (effective companies, pivot date, ...).

I thought about adding the pivot date but realized that in odoo enterprise, they also have an 'annotation' feature but they don't store the pivot date. The annotation is linked to the 'cell'.

@AnizR AnizR force-pushed the zra-mis-builder-annotation branch from 9b9bb7b to 6c0cd21 Compare April 11, 2025 08:50
@AnizR
Copy link
Contributor Author

AnizR commented Apr 11, 2025

I wonder to what extent the annotation should be linked to (some of) the filter values of the report (effective companies, pivot date, ...).

I changed a bit my code:

  • I removed the field 'company_id' on annotations
  • I introduced a 'annotation_context' that represents the context in which an annotation has been added and in which we should display an annotation.

For now, I only use the 'query_company_ids' from the mis report instance.

So, let's say that we have a report that can be used on company A and B. I am on company A and I add a note. This note will be visible only if I display the report from company A (without company B). If I add a note while having company A and B selected, this note will be displayed on the report only if I have company A and B selected.

"kpi_id": kpi_id,
"subkpi_id": subkpi_id,
"note": note,
"annotation_context": self._get_annotation_context(instance_id),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"annotation_context": self._get_annotation_context(instance_id),
"annotation_context": json.dumps(instance_id._get_annotation_context()),

It's simpler.

But is the json.dumps necessary? I'd think we can provide the dict to the json field.

Comment on lines +968 to +970
"""
Return context of annotation linked to this instance
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""
Return context of annotation linked to this instance
"""
"""Return the context used to filter annotation linked to this instance."""

Also, nit: https://peps.python.org/pep-0257/

Copy link
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are a few remarks about ergonomy:

  • Now the cells where there is no drill down are underlined on hover. It is important that this underline appears only as visual cue that a drilldown is possible, as before.
  • After adding an annotation I had to refresh to see it. Is that intended?
  • Removing an annotation leaves a weird display, with the little call out still present until I refresh

image

I think it's important that the annotation changes appear correctly immediately, and without requiring a full recompute.

Tested with firefox on the demo report on runboat.

eval="[Command.link(ref('mis_builder.group_read_annotation'))]"
/>
</record>
</odoo>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically assign these new groups to the admin user? I think there is a pattern for that throughout Odoo.

t-if="cell.drilldown_arg"
role="menuitem"
>
Explore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drill down instead of Explore ? not sure.

But can we keep the immediate drill down when we click on the value, and have the menu appear only when we click on the little down arrow ?

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="res.groups" id="group_read_annotation">
<field name="name">Mis report: read annotation</field>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<field name="name">Mis report: read annotation</field>
<field name="name">MIS Report: view annotations</field>

<field name="name">Mis report: read annotation</field>
</record>
<record model="res.groups" id="group_edit_annotation">
<field name="name">Mis report: edit annotation</field>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<field name="name">Mis report: edit annotation</field>
<field name="name">MIS report: add annotations</field>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants