Now that we're closer to switching to P3 for good, these helpers have
outlived their usefulness, and mostly add noise.
All remaining dict.iter*() or dict.view*() must be converted to the
normal keys(), values() or items() calls.
Whenever the result is likely to be used for more than the scope of a
loop, or when the dict needs to be modified during iteration, the calls
must be wrapped in a ``list()``, to protect the new P3 semantics.
Those cases are very exceptional.
Also removed some dead code or improved the API to remove unnecessary
conversions.
In the curent behaviour, the users of the challenge are ordered
regardless of the goal definition (higher wins or lower wins).
This impacts the report email with the podium of users and always puts higher on top.
This fix changes the ordering depending on the goal definition type.
In Python 3:
* various builtins and dict methods were changed to return
view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
removed altogether
This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).
Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.
issue #8530
The field user_domain allow to get the list of users for which a
challenge is applied. The javascript framework for a char_domain widget
sends a JSON list to the server, but the server saved it as a string in
a Char field.
Hence we can have a list (in values received by write or create) or a
string (when getting the field value of a record).
Since 0c649644db this caused an error when user_domain was not empty.
This commit solves it by having _get_challenger_users always receiving a
string.
opw-708177
Give some details about the badge: its description, its image, who granted
it, ... Otherwise it is quite complicated to understand the email content.
Thanks to @mart-e who reviewed and tested.
If render_template get list and not id, a dict is returned.
Force the param to be a int, allow to don't use the multimode from render_template.
Avoid to get message like:
<p>{1: u'\n </p><p>Congratulation, you have received the badge <strong>Autobiographer</strong> !\n </p>\n\n'}
<p>{2: u'\n </p><p>Congratulation, you have received the badge <strong>Autobiographer</strong> !\n </p>\n\n'}
<p>{3: u'\n </p><p>Congratulation, you have received the badge <strong>Student</strong> !\n </p>\n\n'}
<p>{4: u'\n </p><p>Congratulation, you have received the badge <strong>Supporter</strong> !\n </p>\n\n'}
When attempting to define a goal
using a model that does not have any `inherits`
- which happens most the time-,
it was not possible to choose the
`Field to Sum` and the `Date Field`,
due to the domain set in the view
which is no longer working in 9.0.
The domain is no longer working because:
- The onchange result for a one2many for which
the value is set to `[(6, 0, [])]` is now `[]`,
while, in 8.0, the tuple with the command `6` and the empty
list was preserved
- the empty list `model_inherited_model_ids` is considered as `True` by py.js,
and therefore it fallbacks to `model_inherited_model_ids[0]`, but
as this is an empty list, it crashes.
The solution proposed in this revision solves the issue, while
making the domain applied on these fields less fragile.
opw-658892
Writing frequently to master data, and particularly to res.users
records is dangerous because it can temporarily delay/abort
concurrent transactions due to FK locking/serializability
heuristics. (Even with PostgreSQL 9.3+)
The `login_date` field updated when a user is authentiocated
is still useful but better handled in a separate table that
exclusively receives independent INSERTs (no UPDATE/DELETE).
This minimizes the chances of transactional conflicts.
This commit moves the login_date info into a separate
`res.users.log` table for this purpose, replacing it
with a related field. The user and login date info are
automatically handled by the magical fields (create_uid,
create_date) in `res.users.log`.
The related field must not be stored because that would
create the same problems as the original field.
In order to cleanup redundant entries in res.users.log
the 'auto-vacuum' cron job used for TransientModels was
extended to be a generic "internal data vacuum cleaner",
and now takes care of this as well.
The code for updating last login and vacuuming was split
up into smaller methods to make extensions easier.
Fixes#8585Fixes#8590