[15.0][FIX] mail_activity_done: KeyError user_activites[model.model]
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!
The failed tests "with Odoo, OCB" ain't related with the change of this PR.
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?
It also raises the question if we can keep the previous improvement and fix the KeyError there.
Some interesting things to keep in mind:
- I no longer use the
mail_activity_donemodule. - 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 addact.done = Falseto 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_donemodule in 16.0 is “incorrect” because it redoes thesystray_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_teammodule in 16.0 is “incorrect” because it redoes thesystray_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).
Excellent insights @victoralmau, thank you!
@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!
@StefanRijnhart, @victoralmau I just (force) pushed the change. Please review.
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.
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.