Commit Graph
66 Commits
Author SHA1 Message Date
Thibault Delavallée 10804f1e4b [FIX] (website_)rating: synchronize rating feedback with message body
Purpose is to set review message on both message and rating so that reviews
are correctly displayed in eLearning backend as well as correctly displayed
in chatter frontend.

Task ID 2058595
PR #36281
2019-08-30 15:06:00 +00:00
Thibault Delavallée a6a6795305 [FIX] rating: allow rating deletion
Purpose of this commit is to

  * delete rating when deleting message. Otherwise rating coming from
    frontend portal review chatter are lost in the void;
  * allow system users to delete ratings;

Task ID 2058595
PR #36281
2019-08-30 15:06:00 +00:00
Raphael Collet 9920f20e4c [IMP] models: ORM speedup
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-20 12:43:59 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
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-17 14:13:12 +02:00
Adrian Torres 9e71d57d11 [REM] *: remove calls to api.one and adapt code
Adapt all code that was using `api.one` to recordset-style method and
remove any and all calls to `api.one` in preparation for its removal.
2019-07-05 09:04:45 +00:00
Xavier-Do 2fcb3c658d [REF] mail: rename notif_layout to email_layout_xmlid on message model
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 13:34:32 +00:00
Xavier-Do 581a74143e [REF] mail: simplify notification code
Purpose of this commit is to clean notification process: calls, methods
API, method name, variable propagation.

Contains notably

  * simplify API of methods used to group recipients when sending notification
    emails;
  * improve and rename methods used in email notification process;
  * move some methods on model itself as non mail thread records could be
    mass-mailed and _notify_email_headers could be called on other records;

Related to task 1943901
Linked to PR #32404
2019-05-29 13:34:32 +00:00
Christophe Simonis 8c29df10e0 [MERGE] forward port branch saas-12.1 up to 93d736e905 2019-02-11 17:00:35 +01:00
Christophe Simonis 87924cb5ad [MERGE] forward port branch 12.0 up to a46138cb01 2019-02-07 13:14:02 +01:00
Nans Lefebvre 9d1b07f97b [FIX] project, rating: use rating last update to compute satisfaction percentage
The function _compute_parent_rating_percentage_satisfaction used the creation
date of the rating to compute the percentage.
However when a client give a new rating, it updates the old one.
As a result it doesn't give the recent satisfaction percentage,
but the satisfaction percentage of recently created tickets.
In other words recently angry clients from old projects would not appear.

Similarly this method is somewhat reimplemented directly in SQL in the rating
route, which happens to be in the project controller.

opw 1921486

closes odoo/odoo#30752
2019-02-01 09:01:27 +00:00
Christophe Simonis f927c68ddb [MERGE] forward port branch 12.0 up to cb8fefa899 2019-01-31 16:59:58 +01:00
jem-odoo 8c840f7539 [IMP] rating: add rating average on mixin
This commit provides 1 more field on the rating mixin: the average of
the ratings of the document. Before that, the only way to get the
average was to call `rating_get_stats` record per record.
As we are on a mixin, this new field is not stored to avoid recomputation
each time a rating is added. To improve performance, we decided to
compute `rating_count` and `rating_avg` in one `read_group`.

This commit also set an extendable method to get the domain of the
rating to include in those statistics computation, called `_rating_domain`.
This way, each model inheriting the rating.mixin can define the subset of
pertinent ratings.

As consequence, this commit uniformized the way average is displayed:
instead of taking the closer value to the 0.5 value, it only round it
at 2 digits.

Task-1902304
2019-02-06 09:55:13 +00:00
Christophe Simonis c8ace043e5 [MERGE] forward port branch saas-11.3 up to 387d5cff90
closes odoo/odoo#30566
2019-01-25 17:29:34 +00:00
Nans Lefebvre cb9466cf9c [FIX] rating: add search method on non-stored rating attribute
Commit f727e9d9b6 made the rating field
of mail.message non-stored for performance reasons.
When the rating is activated on the website, it adds the possibility to filter
product reviews by rating (1 to 5 stars).
It does so by searching the messages that have a given rating value.
However the osv complains that you can't search on a non-stored field.
As a result, instead of displaying messages filtered by ratings,
it would always display all of them.

We add a search='_search_rating_value' on the field to allow that field to be
searched anyway.

opw 1931038

closes odoo/odoo#30499
2019-01-24 07:09:00 +00:00
Denis Ledoux fba844c732 [FIX] project, rating: project percentage satisfaction compute performance
This is basically a backport of revision
47479401cb
to gain the performance on the project
percentage satisaction computation

but without introducing the new parent mixin,
which would not be a stable change.

closes odoo/odoo#29354
2018-12-10 15:59:44 +00:00
jem-odoo f098c787c0 [IMP] rating: don't call compute method directly
The correct way to trigger a recomputation of a field is not
to call directly the compute method. The ORM offers mecanism
to do it: we have to flag the field as "recompute to do" and
then call `recompute` method (availble on every models). This
one will call the recompute method of all fields marked as
"to recompute".

This will optimize the performance by doing recomputation in
batch.

Task-1903565
2018-12-10 15:59:44 +00:00
jem-odoo 37293f4644 [MOV] rating: extract mixin in new file
This commit simply move code for both rating.mixin
and rating.parent.mixin in their own file to ease
the reading of code, and fit the guidelines.

Task-1903565
2018-12-04 13:28:19 +00:00
jem-odoo adc25752f3 [REF] rating,*: make some methods private
Impacted modules: im_livechat, project and rating

This commit restricts the access to some method of the rating API. Indeed,
some of them are internal business and should not be called from anywhere
to avoid breaking the rating flow.
This commit also rename some method to fit guidelines. This should not
bring any functionnal changes.

Task-1903565
2018-12-04 12:48:20 +00:00
jem-odoo 9be23c2f63 [IMP] rating: don't call compute method directly
The correct way to trigger a recomputation of a field is not
to call directly the compute method. The ORM offers mecanism
to do it: we have to flag the field as "recompute to do" and
then call `recompute` method (availble on every models). This
one will call the recompute method of all fields marked as
"to recompute".

This will optimize the performance by doing recomputation in
batch.

Task-1903565
2018-12-04 12:48:19 +00:00
jem-odoo 47479401cb [IMP] rating: introduce the parent mixin
When creating a task, the satisfaction of the project is recomputed even
if the task has not rating. This can lead to performance issue:
concurrency error in Postgresql can happen if a task is created when
somebody else tries to update the project.
The satisfaction recomputation will give and concurrency error whereas
it will return the same satisfaction percentage, since the task has no
rating.  The same problem will happens in every modules implementing
the rating feature: project, helpdesk and livechat.

This problem leads us to create the rating.parent.mixin in order to
retrigger the computation only when a new rating appears on the
parent object. We also unstore the field to make its computation lazy.
Maybe in a near future, this field will be computed in SQL directly.
The parent mixin allow us to standardize the behavior to all parent
rating models.
These optimizations should reduce the number of computation and speed
up the task creation.

opw-1902502
Task-1903565
2018-12-04 12:48:13 +00:00
Adrian Torres 3f4f77fd9d [REF] *: adapt code to new related default behaviour
This commit adapts the business code to changes introduced by
the parent commit in order to keep the same behaviour as before.

All readonly=False fields will have to be checked afterwards to confirm
that the business case requires write access to the source field.
2018-09-27 12:10:23 +02:00
Yannick Tivisse eb11665bfc [FIX] rating: Send rating if no override of rating_get_parent
Purpose
=======

Currently if the method rating_get_parent is not overriden, then
sending a rating on a record of the model leads to a traceback.
2018-09-14 11:43:15 +02:00
Yannick Tivisse 4f9cc90c73 [FIX] rating: Send rating if no override of rating_get_parent
Purpose
=======

Currently if the method rating_get_parent is not overriden, then
sending a rating on a record of the model leads to a traceback.
2018-09-14 11:09:08 +02:00
Raphael Collet 5701d93624 [FIX] *: decorator returns on message_post 2018-08-23 17:01:22 +02:00
Pratima Gupta 9eb89131f3 [REF] rating, project: sending request is now a classic message post
This allows to better control the posting process, notably using custom
layout to encapsulate emails. Previously to this commit a simple email was
send using a template. Now this template is used to post a message on the
record asking for customer request.

New parameters are added on the request send method

 * a subtype, allowing some custom behavior with followers; by default the
   behavior is to log a note with the customer being in the recipients list;
 * composition_mode can be given and propagated to message_post_with_template
   allowing a comment or mass mailing mode;

This commit is related to task 51122 (and PR #24052).
2018-06-08 15:20:04 +02:00
XavierDo 6c381a3a16 [IMP] im_livechat, mail: replace emoji with unicode.
Remove the support to replace emojis by images. Most browser
now support colored emoji or at least black and white emojis.
The emojis list have been updated to ensure a correct support
for most os/browser.
Users have the possibility to install fonts localy if their os does not
have one of the default emoji font installed.
After default os emoji font, one of twemoji, emojione or noto color
will be selected.
The emoji list is now hardcoded in js in order to reduce the number of
records in shortcodes.

Also include a small fix for livechat to display message field when rating
is bad.

Task #36898
PR #23689
2018-04-09 17:19:29 +02:00
Thibault Delavallée f727e9d9b6 [REF] rating: avoid storing rating_value on mail.message
Currently the rating value coming from the rating application is stored
on the message it belongs to. However storing it is not necessary as
there is no direct search using it. Having a computed field is sufficient
for all use cases we currently have in Odoo.

Removing the store allow to gain queries. Indeed the field is not
computed anymore after each message creation meaning we save queries
by not having to check existing ratings. It allows to gain a lot of
computation as mail.message is a critical model.

On the whole community runbot when installing all modules this leads to
a gain of more than 14K queries on 585K which means 2.4% of performances
increase. Considering the code size of this optimization this is quite an
interesting result.

Looking at test_mail performance tests we gain several queries (2/3) for
each new message which is coherent with the model change.

Finally it allows to lessen the performance difference between tests done
with test mail only and tests done with other modules already installed.
This is especially simple mail thread-enable records.

Related to task ID 51523. #Closes #23294. Done with blessing of @jem-odoo .
2018-02-26 16:58:35 +01:00
RomainLibert 12b580c953 [IMP] rating: Parent document name update
For objects inherting from rating.mixin, when their parent model change
(e.i.: task from a project to another), the "Parent document name" does
not change. The rating is still considered belonging to the old parent
object (rating stat of project is not correct).

Change the rating API. In rating mixin, instead of having 2 methods
returning parent id and parent model (rating_get_parent_id and
rating_get_parent_model_name), we should have one method returning the
'parent relation field' (inevitably m2o field). Then we can deduce its
parent_res_id/parent_res_model, and check this parent field is in values
of write to trigger the recompute of parent_res_name.

Also, add "ondelete=cascade" on parent_res_model_id

Impacted modules: project, rating, helpdesk, livechat
2018-02-23 16:13:03 +01:00
RomainLibert ffbee8882e [FIX] rating: Fix minor bug in write method
It shouldn't happen, but if we change the name of multiple rating_mixin
inheriting models, we can run into an error, because write doesn't
support multiple values.
2018-02-23 16:13:03 +01:00
Fabien Pinckaers b341b5ca73 [IMP] Remove duplicate fields names 2018-01-07 19:28:03 +01:00
Thibault Delavallée d7c24089ee [FIX][IMP] mail, rating, website_forum: inherit message_post using kwargs
Several addons inherit from message_post method. Instead of redefining
the long list of parameters let us just use kwargs and propagate them to
the super call. Only really used parameters are set as explicit.

Purpose is to lessen issues when changing some parameters default value
or when having some API change.
2018-01-05 10:32:25 +01:00
Kinjal Mehta 3000e61d69 [IMP] rating: changed duplicate field label in the same model 2018-01-04 17:56:56 +05:30
Hardik Patel a8f1adc29a [FIX] rating: correctly encode base64 image
Fixed a typo from commit 3824b5dcc1
2017-09-18 16:51:18 +02:00
Rohan Patel 8c1f6a7cc6 [IMP] mail,*: replace emojis by unicode in chat messages
*im_livechat,rating.

Emojis are now encoded in unicode characters in messages. This
allows to copy/paste messages including emojis, ensures that
emojis are properly displayed in mail interfaces (at least those
that support unicode, e.g. GMAIL, counter-example: outlook), and
allows the user to directly use emojis of its smartphone in mobile.

This commit also adds several new emojis.

PR #11095
2017-09-11 12:20:49 +02:00
Olivier Dony 695716efb0 [FIX] P3: remove pycompat.{keys,items,values} helpers
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.
2017-08-20 23:25:54 +02:00
Xavier Morel 3824b5dcc1 [FIX] P3: fix base64 and StringIO uses
* StringIO removed from stdlib, replace with io
* try to correctly handle BytesIO/StringIO (one is for bytes the other
  is for text)
* fix base64: Python 3 removed bytes-encoding and bytes-bytes
  codecs (via #encode) so replace all calls to str.encode('base64'),
  also b64encode is a bytes->bytes conversion so attempt to properly
  handle that

issue #8530
2017-08-20 23:25:54 +02:00
dbh f784c26cf9 [IMP] rating: add groupby on rating_text
This commit change field rating_text into
selection computed field.

In customer satifaction, we want to be able
to group by note, but not use the rating value
itself. So a label representing provide 3 satisfaction
levels : 'Dissatisfied' (1-3 points), 'Not satisfied'
(4-7 points) and 'Satisfied' (8-10 points).
2017-07-10 08:46:27 +02:00
dbh 798c1da440 [IMP] rating: parenting model mecanism
This commit provide a parenting system for rated
record, such as mail alias.
For instance, 'project.project' is the parent of
task and issue objects.

This will allow to have a global view of customer
statisfaction on 'parent' objects (project and
livechat channel for now).

To do so, the rating
mixin provides 2 methods that need to be
overriden: `rating_get_parent_model_name` and
`rating_get_parent_id`.
2017-07-10 08:46:27 +02:00
Jérome Maes f447e9679f [IMP] rating: message_post with rating value
rating module provide now post a message with a
rating value, though `message_post` method.
'mail.message' also has now a `rating_value` field
to ease searching and filtering.

This will help the ecommerce (and other website modules)
to post a comment associate with a rating.
2017-06-30 11:06:32 +02:00
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
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
2017-05-10 09:39:55 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Xavier Morel 76852a2fad [#8530] fix uses of `reduce` builtin
Demoted to library in Python 3, see if uses can be replaced by more
specific construct, just import functools.reduce otherwise.

Futurize fixers:
* lib2to3.fixes.fix_reduce
2017-04-12 13:48:42 +02:00
Christophe Simonis 68176d80ad [MERGE] forward port branch saas-14 up to eddefc9948 2017-03-01 16:49:15 +01:00
Christophe Simonis 85368d7f86 [MERGE] forward port branch 10.0 up to 387b2acfcb 2017-02-23 20:15:38 +01:00
Denis Ledoux 731a21e5b4 [FIX] rating: security issue to the last_value related field depends
The `rating_last_value` field was a related on the One2many
field `rating_ids`, on which the domain
`[('res_model', '=', self._name)]` is applied.

The problem is that this domain is not taken into account
when retrieving the records for which this value must be recomputed

Therefore, when computing the `rating_last_value` of a record,
if there was a record with the same `res_id` but another
`res_model`, the `rating_last_value` of this other record
is recomputed as well.

And, if you did not have the write access rights on this other
record, it raised a security exception.

There is at the moment no way in the ORM to filter the
depends on a specific subset of records for which
a computed field must be recomputed. Therefore,
we have no other choices to make the recomputation
of the records value as sudo. It will
recompute the value of other records which have nothing
to do with the one on which this value must be recomputed
(nothing to do except the id of the records which is common),
but at least it will succeed.

opw-709349
2017-02-23 13:57:31 +01:00
Goffin Simon f63fb28579 [FIX] rating: Typo error
When record.id was not in the dictionary result, it raised a error.

opw:709072
2017-02-20 11:40:19 +01:00
Jérome Maes 8e10f6adf9 [IMP] rating: delete rating when needed
Automatically deleting a rating was not implemented
yet. We find 2 cases :
- when uninstalling a module, the same mecanism as
mail.follower is used, via a res_model_id field
pointing on ir.model. When this model does not
exist anymore, remove all related rating.
- when deleting a record, its rating should be
deleted too.
2017-01-09 16:33:21 +01:00
Jigar Patel f7379b1c7f [IMP] rating_*: cleaning and improvements
In rating module
- provide list and form view for rating
- better kanban view (remove js code, ellispsis
for long name, better feedback display, ...)
- provide more field on the mixin to cover
more case
- update res_name of rating when the ressource name
is changed (for consistency)
- make the rating web page, a correct html page (by
using web.layout template)
- some guidelines compliance

In rating_project and rating_project_issue:
- add filter for rated document
- some guidelines compliance
2017-01-09 16:19:25 +01:00
Nicolas Martinelli 3653661235 [FIX] rating, rating_{*}: translations
Several translation issues are faced with the rating module:
- the feedback page is always displayed in the admin language
- the feedback emails are always sent in the user's language

One would expect these to be in the partner language.

opw-694718
2016-12-01 15:50:11 +01:00
Christophe Simonis 298e2032ea [MERGE] forward port branch saas-12 up to 9f28139 2016-09-09 18:13:31 +02:00