summaryrefslogtreecommitdiff
path: root/addons/gamification/models
AgeCommit message (Collapse)Author
2021-05-05[IMP] gamification: skip useless computationsNicolas Seinlet
- use real join - skip useless join on res_users and gamification_challenge - skip null end_date criteria to compute less reached goal closes odoo/odoo#69668 Signed-off-by: Christophe Simonis <chs@odoo.com>
2021-04-30[FIX] gamification: apply res.users ir rules when retrieving badge owner infoRémy Baranx (bar)
When retreiving the list of badge owners in `_get_owners_info()`, we should apply `res.users` ir rules to be sure to respect multi-company rules. upg-7081 closes odoo/odoo#69840 X-original-commit: 1190fc327e8efddd8d44c3fbd685bb97f472cd46 Signed-off-by: Christophe Simonis <chs@odoo.com>
2020-12-11[IMP] gamification,gamification_sale_crm: compute goals using batch modeBenoit Socias
Trying to improve the resources used by the challenge update cron operation. Before this commit some count-based goals and all sum-based goals were computed with one select count or sum per user. After this commit each count or sum based goal is computed in a single select for all users. The goal form now also allows to enable batch mode for sum computations. Other changes include: - adding an index on the challenge_id of goals after verifying the positive impact of such an index on high volumes on a staging server - introducing additional intermediary commits to allow massive crons to catch up over several attempts. task-internal closes odoo/odoo#63030 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-10-20[FIX] gamification: fix badge creationBenjamin Vray
Before this commit, we executed the request even when creating a new badge. And it thrown a traceback. After this commit, we return default values before executing the request if this is a new badge. task-2312878 closes odoo/odoo#60347 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-09-28[REM] *: ability to put raw modules in evaluation contextsDebauche Stéphane
Co-authored-by: Xavier Morel <xmo@odoo.com>
2020-09-07[FIX] *: typos and english incoherencesVictor Feyens
Mainly transifex issues but also some errors found through 'grep' checks. Fix typos and obscure english strings in xml contents, fields strings/helps, some docstrings, ... ensuring correct translations base (and fallback when translations isn't available). closes odoo/odoo#57206 Related: odoo/enterprise#13032 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-07-13[FIX] gamification: use right field on goal domainMartin Trigaux
There is no field 'ids' on a gamification.goal, but one called 'id' Without this commit, calling _get_serialized_challenge_lines (or indirectly, calling report_progress) with a non-empty subset_goals was failing due to an invalid domain. This is not supposed to happen on standard flow but can be triggered with manual modification of date fields and refreshing a challenge. Fixes odoo/odoo#25913 closes odoo/odoo#54387 X-original-commit: 1e3483d2fc99763940396936758cf99b14d0a118 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-07-14[FIX] *: handle null value for boolean in sql queriesJeremy Kersten
It has always been a best effort until the v13 to have false as default value for boolean field. Until v13: https://github.com/odoo/odoo/blob/12.0/odoo/models.py#L3645 During ORM refactoring in v13 it has been replaced by a default value in sql From v13: https://github.com/odoo/odoo/blob/13.0/odoo/tools/sql.py#L79 But with a typo since columntype for boolean is bool and not boolean. What's mean that in v13 we have a lot of null value for boolean (~=False) In all cases, we try to be aware and check Falsy boolean with 'null or False' (https://github.com/odoo/odoo/blob/13.0/odoo/osv/expression.py#L1230) So we should do the same when we write pure sql in method bypassing the ORM. closes odoo/odoo#53391 closes odoo/odoo#54458 Related: odoo/enterprise#11319 Related: odoo/enterprise#11838 X-original-commit: 118c9f6aafd423f415b2bbfcf8a9cfcd676d9b92 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-06-18[IMP] *: use named placeholders in translated messageMartin Trigaux
When more than one parameter is present in a message, it helps the translation to use named placeholder. This way, the order can be changed. It also helps the comprehension of the message.
2020-06-18[IMP] *: replace to new _() syntaxMartin Trigaux
Using a few regex like \((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\) ($1, $3)) Old syntax is still compatible but starts the migration to the new syntax that catches error.
2020-05-14[IMP] gamification: improve tree and form viewOkan SUMER (osu)
This commit improve the tree and form view of gamification.karma.rank and correct a bug on auto generated email when a user pass to the next rank. - Add a stat button in form view and column in tree view to know how many users have the current rank - Split Description and Motivational in 2 pages - Hide the line that mention the next rank the user can get when there is no more rank to get in email templates - Add a menu to access badges tree view Part of https://github.com/odoo/odoo/pull/46634 task-2201708
2020-04-07[FIX] *: invalid parameter 'tracking' on non-mail-thread modelsRaphael Collet
2020-03-24[REF] mail: clean code about rendering in mail_templateThibault Delavallée
PURPOSE Clean and rename code about language management and template rendering in mail template model. SPECIFICATIONS Clean method naming and try to make code easier to understand and call. Also add and/or clean docstrings of rendering methods. Notably * ``_classify_per_lang``: for each lang-contextualized template, give the list of record ids; * ``_render_template``: now working only on a valid list of IDs instead of allowing both int / list and having a return type depending on the input type. It allows to simplify code and delegate some processing to callers; Introduce new API method * ``_render_lang``: for each record id return the lang matching it; * ``_render_field``: render a field of mail.template, on given set of record ids. Usage: template._render_field('body_html', records.ids). Language computation is available for this method; Remove the "multi mode" support of rendering that either returned a rendered value, either a dict based on given ids. Now all methods always work in batch and caller have to fetch the correct result if necessary. LINKS Task ID 1963529 Community PR odoo/odoo#32397
2020-02-20[IMP] fields: log warning for ignored selectionmreficent
When a field is related, defining a selection or selection_add will have no effect and the paramater is ignored. Log a warning and fix all fields badly definied Closes odoo/odoo#45716 closes odoo/odoo#45832 Related: odoo/enterprise#8613 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-01-28[IMP] *: use ast.literal_evalMartin Trigaux
When simply need to parse a domain, it is easier Add .strip() on ir.ui.view as ast.literal_eval produces an syntax error if the node starts with spaces (as done in the xpath of hr_attendance.view_employee_form_inherit_hr_attendance) closes odoo/odoo#43831 Related: odoo/enterprise#7894 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-12-02[REF] mail, various: rename subtype parameter of message_post to subtype_xmlidThibault Delavallée
PURPOSE Clean posting process and improve mail.message definition and comprehension. SPECIFICATIONS In order to be more explicit subtype parameter is renamed to subtype_xmlid. It therefore clearly indicates it should be a valid subtype Xml ID. Support of ill formatted Xml IDs is removed because there is no reason to try to add some random prefix. Give something that exists or go to hell, punk ! LINKS Task ID 2071556 PR #38692
2019-11-27[FIX] gamification: remove dynamic domains on field_[date_]idXavier Morel
closes odoo/odoo#40951 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-11-22[FIX] gamification: prevent division by zero in percentage completeness ↵alt-odoo
computation We are initializing over the limit to make sure we will compute it at least once. If the target goal is set to 0, we are facing a division by zero error when displaying the gamification goal just after initialization. closes odoo/odoo#40735 X-original-commit: 24546e7c4cac61efea8d3f9e558518a55ef9acd2 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-11-22[REF] gamification, * : rename challenge.category into ↵David Beguin
challenge.challenge_category To ease grep in the code, especially that challenge is quite heavily used. Task ID : 1961053 PR #32594
2019-11-22[REF] gamification : rename stat_* fields into granted_* to ease understandingDavid Beguin
In this commit we rename stat_count into granted_count, and stat_count_distinct into granted_users_count to reflect more what are those variables, aka count of granted badges. Task ID: 1961053 PR #32594
2019-11-06[IMP] gamification: add sql constraint to force rank's min_karma > 0Aurélien Warnon
This commit adds a SQL constraint to force the min_karma of the gamification.karma.rank model to be above 0. A karma_min set to 0 (or lower) could create some frontend issues when displaying required karma. PR #39870 Task#2032649
2019-11-06[FIX] gamification: adapt _get_next_rank method to always return a recordsetAurélien Warnon
The return type of the _get_next_rank method on the 'res.users' model was inconsistent. It sometimes returned a recordset, sometimes False. This commit adapts the method to always return a recordset (which is empty for the previously 'False' case). This is a preliminary work for the level up animation on website_slides task. PR #39870 Task#2032649
2019-11-05[IMP] website_profile: handle both groupby and search in users pageThibault Delavallée
Purpose is to support both search term and karma gain group by in the URL, using keep_query. Clean some code and move karma computation to res.users model to avoid having sql in controllers. Also fix some display issues. LINKS Task ID 2003505 PR #34594
2019-11-05[IMP] gamification: track karma change on usersPatrick Hoste
PURPOSE Allow karma gain tracking enabling notably display of top users based on weekly / monthly gain in website profile. SPECIFCIATIONS Each time a user gains karma a record is created in the gamification karma tracking model. Scheduled activity runs to consolidate the records into monthly gain records to avoid having crowdy table and unnecessary noise in karma gain. This model is made private and only accessible through some dedicated compute methods / controllers used in website profile. In website profile module buttons are added to see users ranking based on their total karma (like before) but also by last week and last month gains (using the newly introduced tracking model). LINKS Task ID 2003505 PR #34594
2019-09-12[IMP] gamification, *: remove KarmaErrorfja-odoo
* = stock, test_website, web, website_forum, website_slides, base Replace KarmaError with AccessError and remove the related override made on crash_manager and ir_http. task-2069890 closes odoo/odoo#36655 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-09-13[MERGE] forward port branch saas-12.4 up to fe59754c520Christophe Simonis
closes odoo/odoo#36721 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-11[MERGE] forward port branch saas-12.3 up to 50e571acf7cChristophe Simonis
closes odoo/odoo#36491 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-08-26[FIX] gamification: tolerate invalid definitionsMartin Trigaux
If a goal definition with a target goal of 0 and "higher the better", instead of dividing by 0, set a progress of 0% (it is not possible to compute the progress) Task id: 2057898
2019-08-26[FIX] gamification: initialize goals at 0Martin Trigaux
If a manual goal has a target of 10, it should not start at 9 but 0 If it has a target of 0, it should start at -1 Task id: 2057898
2019-08-20[IMP] models: ORM speedupRaphael Collet
This branch is the combination of several optimizations in the ORM: * store field values once in the cache: the cache reflects more faithfully the database, only fields that explicitly depend on the context have an extra indirection in the cache; * delay recomputations by default: use method `recompute` to explicitly flush out pending recomputations; * delay updates in method `write`: updates are stored in a data structure that can be flushed efficiently to the database with method `flush` (which also flush out recomputations); * make method `modified` take advantage of inverse fields to inverse dependencies; * filter records by evaluating a domain on records in Python; * a computed field with `readonly=False` behaves like a normal field with an onchange method; * computed fields are computed in superuser mode by default. Work done by Toufik Ben Jaa, Raphael Collet, Denis Ledoux and Fabien Pinckaers. closes odoo/odoo#35659 Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
2019-08-02[IMP] *: use image.mixin when appropriateSébastien Theys
The following models are already using big images, or they might need big images in the future: - partner - hr employee - shop category - lunch product - gamification badge and karma rank PR: #34925
2019-08-02[IMP] *: rename image fieldsSébastien Theys
image_original => image_1920 (now resized to 1920) image_big => image_1024 image_large => image_256 image_medium => image_128 image_small => image_64 image replaced by image_1920 (when writing) or by image_1024 (when displaying what was previously the big size) + add new intermediate format: image_512 PR: #34925
2019-07-26[MERGE] forward port branch saas-12.3 up to 40e8b67179fChristophe Simonis
2019-07-24[FIX] gamification: perf on write karma_min on gamification.karma.rankJeremy Kersten
This commits avoid to call recompute when you write on the rank without touch the karma_min value. On write on karma_min, we have 2 cases: - Rank order are the same, just need to recompute the rank for the user that could be impacted. Eg. if karma_min changes from 45 to 50, we need to recheck for all user between 45 and 50 their new rank. - Rank order are not the same, we need to recompute for all users. (could be still improved if needed) When you recompute the rank on a list of users, depending of the number of users (bulk if more than 3 * number of rank) we check for each user what is the new rank, or for each rank whats is the new users. task-internal No way to edit a rank on the prod server. Lock sql -> crash server closes odoo/odoo#34835 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-07-12[MERGE] Forward port of saas-12.3 to saas-12.4 up to 87fc1554d6a1823Martin Trigaux
closes odoo/odoo#34820 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-06-28[FIX] gamification, website_{profile, slides}: correctly display next rankThibault Delavallée
This fix correctly displayed motivational of next rank to achieve depending on current karma. Indeed description_motivational field is not the motivational to reach next rank but to reach the current rank, taken from previous rank point of view. That way a given rank is configured by modifying only 1 data. When not having any karma points (newly created user) the next rank is computed as being the first available rank. Motivational phrases and badges are updated accordingly. This commit partially reverts 489c8623e2c4869ce1ed8be3d186e36cc1c47456. Result * new user with no karma: next rank is the first rank; * user with karma and next rank: as currently; * user being at final rank: next rank is just current rank with a 100% circle; Linked to task 2005840 Related to PR #34220
2019-06-06[MERGE] forward port branch saas-12.3 up to 409679866b2Christophe Simonis
2019-05-29[REF] mail: rename notif_layout to email_layout_xmlid on message modelXavier-Do
Purpose is to make field use more obvious by correctly stating in the name it should contain an xml id to a qweb layout used for email notifications. This renaming is propagated through various calls and addons. Related to task 1943901 Linked to PR #32404
2019-05-29[REF] mail: improve message_post and message_notify APIXavierDo
Message post should always be called on a record (ensure_one). That way we ensure posting a message is always done in a record's context with right values computed (reply_to, followers, ...) Message_notify can be called on record or on mail_thread and must have partner_ids. It is based on the recently modified user_notification mechanism and allow to notify a partner on a record or just to push him a message (aka, not linked to a record). Small performance improvement * browse recipients instead of search in _notify_email_recipients; * todo in future optimizations: mayybe be improve by searching on ids and is_blacklist immediately; Related to task 1943901 Linked to PR #32404
2019-05-29[REF] mail, various: apply light code cleaningXavier-Do
Purpose of this commit is to clean some bits of code, notably calls to message_post/log as well as notification methods. It will ease performance improvement work. Small optimization: account: read content after extension check Parameter cleaning * use message log with kwargs instead of args; * remove message post after hook useless parameters; * remove _notify_email_recipients useless message parameter; * remove message_notify useless send_after_commit parameters; * remove message post params matching default values; Other improvements * remove message_post commands support for partners and channels; * only calls message_post with ids list for channels and partners. We don't support mix of ids and command anymore to simplify code; * remove support of private discussion in mail.thread adding partners as recipients, as there is no use anymore; Related to task 1943901 Linked to PR #32404
2019-05-29[IMP] api.py: Rename company_id/company_ids into company/companiesYannick Tivisse
The goal is to be coherent with the user property. Actually, company_id and company_ids on the environment are no fields. Calling env.company_id returns a browse record, not an id.
2019-07-29[MERGE] forward port branch saas-12.4 up to cda4f3c308cChristophe Simonis
2019-07-23[IMP] gamification : remove karma_position fieldDavid Beguin
Since task Id 2000687 and PR #33475, karma position field is not necessary anymore as the karma position is computed directly in the website_profile controller. Task ID: 2001367 PR #35103 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-07-17[REM] *: calls to @api.multiAdrian Torres
Multi is the default api for methods, it is not necessary to explicitly decorate methods with it, adds clutter and most people use it because they see that the rest of the code uses it. Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-15[MERGE] Forward port of saas-12.4 to master up to 1f5a4649a67908Martin Trigaux
closes odoo/odoo#34850 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-04[REF] *: `record.env.user._is_XXX()` -> `record.env.is_XXX()`Raphael Collet
Superuser mode implies `record.env.is_XXX()`.
2019-07-04[FIX] *: sudo() -> with_user()Raphael Collet
2019-06-28[IMP] base, web, *: make KarmaError an except_ormfja-odoo
* = gamification, test_website, stock - KarmaError is now handled as a 400 exception. - test_website has been updated. - NO_POSTMORTEM is now clean it was referencing duplicates as most the exceptions inherit from except_orm. - serialize_exception from http.py has been moved to ir_http to take advantage of the odoo inheritance system. We can then extend ir_http serialize_exception method to add the KarmaError logic if and only if gamification is installed. Places where serialize_exception was previously used are updated. Part of https://github.com/odoo/odoo/pull/32132 task-1894820
2019-05-21[FIX] website_profile, gamification : compute rank for website_published ↵David Beguin
users only If a non website_published user was 2nd in karma position, the all users page was displaying in the top 3 a user with position 4 (in rank) as "normal users" cannot see non published users. The field karma_position is now deprecated and will be removed in master. Task ID : 2000687 PR #33475 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-04-08[FIX] gamification: set record name for goal titlesYenthe666
closes odoo/odoo#30628 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>