OCA / hr

Odoo Human Resources Addons
GNU Affero General Public License v3.0
217 stars 670 forks source link

Perfs issue with hr_attendance_report_theoretical_time #558

Closed jgrandguillaume closed 5 years ago

jgrandguillaume commented 5 years ago

Hi,

Using hr_attendance_report_theoretical_time on v12 with 130 employees and ~160 attendances "only" the table takes around 2 minutes to display when I open "Theoretical vs Attended Time Analysis" with HR manager access right . I only display current year, meaning 2 months..

I'm worried that this reports won't handle a real use cases here..

Regards

Joël

shartenfels commented 5 years ago

Hi @jgrandguillaume, just a comment from my side based on today's testing with "real" data on the INT.

  1. If the user has just "manual attendance" as access right, the report is quite fast and prefiltered to "my attendance"
  2. Performance starts to get down as soon as you are a "officer" on the attendance. Therefore I agreed your proposal to have an initial filter based on "My attendance"
  3. I would suggest to leave the default pre-filters like they are "Previous Month or Current Month" and only to change as soon as it is "clear" what I would like to see in real. But for a standard user this should be sufficient, because he/she will always see the overall total.

Thanks and regards, Stefan

pedrobaeza commented 5 years ago

The problem is not having 160 attendances, but the contrary: not having a lot of missing attendances, as in that case, the theoretical hours should be computed on the fly. On this case, you have about 40 working days, but only attendances for basically 1 day, so 39 130 4 (this is due to the subtotal and total cells) = 20280 computations should be done on the fly, which is the reason why 2 minutes are needed.

I don't think this is a real use case, or at least, it should be a case for a full year, where all the employees have taken all their leaves (and even in that case, the number of missing attendances should be lower).

You can tweak this by setting the "Theoretical Hours Start Date` field in each employee, starting from the real date where you are going to start the attendances. Try this, and for sure the performance will be better.

How can we improve more the performance?

Other thing that I was going to comment is what @shartenfels has already commented meanwhile I was writing this: all employees are shown only in case of HR officers or managers, that indeed is intended for a full picture. If you don't want this, simply save a favorite as default with only your attendances.

jgrandguillaume commented 5 years ago

Hi,

Thanks for the quick answer @pedrobaeza ! Let's leave this as it is and see when we do have more data then. Can I suggest to implement this default filter for all users:

My attendances
Current year

That would ease the performance issue and be also more convenient for most of the use cases -> you want to check your own attendances most of the time. And the yearly picture is also required most of the time because if you look at the 2 months only (current and previous one), then the total difference is wrong. I mean it is computed properly, but as you report overdue hours on a yearly basis, then you do not have the proper total (e.g. +10 hour in january, 0 in February, 0 in March, you are in April, then the difference will be 0).

What do you say ?

Regards,

Joël

pedrobaeza commented 5 years ago

Hi, @jgrandguillaume, about the default filters:

jgrandguillaume commented 5 years ago

I was suggesting this as it seems to be the defaut people wants (having 2 month doesn't provide the good sum as it is managed yearly). But OK for me I close the issue.