social icon indicating copy to clipboard operation
social copied to clipboard

[15.0][FIX] mail_activity_done: KeyError user_activites[model.model]

Open bobslee opened this issue 1 year ago • 8 comments

A KeyError occurs for a missing model in the user_activities, when updating the user_activites[model.model] dict.

The fix to initialize the activity data wasn't straightforward. However just backporting (copied) the code from 16.0 seems to work!

bobslee avatar Aug 20 '24 15:08 bobslee

The failed tests "with Odoo, OCB" ain't related with the change of this PR.

bobslee avatar Aug 20 '24 15:08 bobslee

That's not a backport from 16, that's a revert of https://github.com/OCA/social/pull/1222 by @victoralmau that never made it into 16!

Would it be possible to add a test that reproduces the issue, so that we can be sure that the problem is not going to resurface after a future refactoring?

StefanRijnhart avatar Aug 20 '24 19:08 StefanRijnhart

It also raises the question if we can keep the previous improvement and fix the KeyError there.

StefanRijnhart avatar Aug 20 '24 19:08 StefanRijnhart

Some interesting things to keep in mind:

  • I no longer use the mail_activity_done module.
  • Created https://github.com/odoo/odoo/pull/137070 to add some hooks in odoo and simplify everything, avoiding redoing the systray_get_activities() method completely (only to add act.done = False to sql).
  • We did not FWP to 16.0 from https://github.com/OCA/social/pull/1222 because it was not necessary, i.e. the https://github.com/odoo/odoo/blob/16.0/addons/mail/models/res_users.py#L201 method does not use sql.
  • The mail_activity_done module in 16.0 is “incorrect” because it redoes the systray_get_activities() method completely and it is no longer necessary to do anything in that method, the activities you want to “skip” will be archived.
  • The mail_activity_team module in 16.0 is “incorrect” because it redoes the systray_get_activities() method completely and it is no longer necessary to do almost nothing in this method, only filtering by the activities of the corresponding team (without doing it by sql).

victoralmau avatar Aug 21 '24 06:08 victoralmau

Excellent insights @victoralmau, thank you!

StefanRijnhart avatar Aug 21 '24 06:08 StefanRijnhart

@StefanRijnhart , @victoralmau Thanks for your remarks and I agree! It didn't appeared to me Victor's change was an improvement to reintroduce the super call again. I shall revert and check whether I can add a fix for the original v15 implementation. Keep you posted!

bobslee avatar Aug 21 '24 09:08 bobslee

@StefanRijnhart, @victoralmau I just (force) pushed the change. Please review.

bobslee avatar Aug 21 '24 11:08 bobslee

No test, so you really made me think hard about what might cause the issue 🥲 but if I understand correctly you might be able to simplify.

Indeed, I know about the lack of the unit test. Unfortunately no time (budget) left to write a unittest.

bobslee avatar Aug 22 '24 09:08 bobslee

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

github-actions[bot] avatar Jan 19 '25 12:01 github-actions[bot]