Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MERGE] base, misc : Default profile picture for new users. #41356

Closed

Conversation

@tivisse
Copy link
Contributor

tivisse commented Dec 4, 2019

=======
Purpose

When you go in project (or any other module) and nobody is assigned to a task, the default 'missing image' is displayed.
Because of that, there is no way of telling if the user is missing a profile picture or if nobody is assigned to the task.

===========
Specifications

  • Set a default image for new users
  • Each user should have a distinct backgroung color
  • If the record is unassigned display user-slash icon and unassigned on hover

TaskID: 2060206

@tivisse tivisse changed the title Master base default profile picture xbo [MERGE] Insert Commit Message Dec 4, 2019
@C3POdoo C3POdoo added the RD label Dec 4, 2019
@xavierbol xavierbol force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from d85406d to 21ff5ee Dec 5, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Dec 5, 2019
@xavierbol xavierbol force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from 21ff5ee to 5fd81f6 Dec 11, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Dec 11, 2019
@xavierbol xavierbol force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from 5fd81f6 to 8fcf047 Dec 11, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Dec 11, 2019
@xavierbol xavierbol force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from 8fcf047 to 7992e91 Dec 13, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Dec 13, 2019
@jdoutreloux jdoutreloux force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from 7992e91 to cdab506 Dec 27, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Dec 27, 2019
@jdoutreloux jdoutreloux force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from cdab506 to 8bed99e Dec 30, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Dec 30, 2019
@jdoutreloux jdoutreloux force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from 8bed99e to cff26ed Jan 8, 2020
@robodoo robodoo removed the CI 🤖 label Jan 8, 2020
@jdoutreloux jdoutreloux force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from cff26ed to 0b23b77 Jan 8, 2020
@robodoo robodoo added the CI 🤖 label Jan 8, 2020
@@ -1445,6 +1445,11 @@ def _content_image(self, xmlid=None, model='ir.attachment', id=None, field='data
if status in [301, 304] or (status != 200 and download):
return request.env['ir.http']._response_by_status(status, headers, image_base64)
if not image_base64:
if placeholder == 'placeholder.png' and model in request.env:

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 14, 2020

Author Contributor

model in request.env seems louche, it shouldn't be needed.

Copy link
Contributor Author

tivisse left a comment

Some cleaning to make, otherwise it looks good (on the principle).

Thanks.

@@ -1445,6 +1445,11 @@ def _content_image(self, xmlid=None, model='ir.attachment', id=None, field='data
if status in [301, 304] or (status != 200 and download):
return request.env['ir.http']._response_by_status(status, headers, image_base64)
if not image_base64:
if placeholder == 'placeholder.png' and model in request.env:
placeholder = request.env[model]._get_placeholder_filename()
status = 200

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 14, 2020

Author Contributor

Why do we set status here at 200. It shouldn't be needed too IMO.

if placeholder == 'placeholder.png' and model in request.env:
placeholder = request.env[model]._get_placeholder_filename()
status = 200
if model == 'res.users' and id == '-1':

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 14, 2020

Author Contributor

We should remove this bidouille id == '-1' over here. @jdoutreloux could you check why it's needed and how to get rid of it ?

placeholder = request.env[model]._get_placeholder_filename()
status = 200
if model == 'res.users' and id == '-1':
placeholder = 'user-slash.png'

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 14, 2020

Author Contributor

If _get_placeholder_filename is overwritten on the res.users model, it would be handled for this specific use case.

@@ -929,6 +929,16 @@ def _on_login_cooldown(self, failures, previous):
def _register_hook(self):
if hasattr(self, 'check_credentials'):
_logger.warning("The check_credentials method of res.users has been renamed _check_credentials. One of your installed modules defines one, but it will not be called anymore.")

# def _get_placeholder_filename(self):

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 14, 2020

Author Contributor

Commented code, to be reintroduced IMO.

@@ -1895,7 +1895,7 @@ def _read_group_fill_temporal(self, data, groupby, aggregated_fields, annotated_
def _read_group_prepare(self, orderby, aggregated_fields, annotated_groupbys, query):
"""
Prepares the GROUP BY and ORDER BY terms for the read_group method. Adds the missing JOIN clause
to the query if order should be computed against m2o field.
to the query if order should be computed against m2o field.

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 14, 2020

Author Contributor

Useless diff, could you remove it, to keep a clean history on models.py ?

It's important to avoid noise on the basic files.

@jdoutreloux jdoutreloux force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from 0b23b77 to 493e994 Jan 14, 2020
@robodoo robodoo removed the CI 🤖 label Jan 14, 2020
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Jan 16, 2020
@tivisse tivisse force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from e5f8157 to 09cd365 Jan 17, 2020
@robodoo robodoo removed the CI 🤖 label Jan 17, 2020
@tivisse tivisse force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch 5 times, most recently from 56389bf to 8e010e6 Jan 17, 2020
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Jan 17, 2020
@rco-odoo

This comment has been minimized.

Copy link
Member

rco-odoo commented Jan 20, 2020

That's a pretty cool feature ❤️

@robodoo robodoo added the CI 🤖 label Jan 20, 2020
@tivisse tivisse force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from 3473fc7 to 0dfedb8 Jan 20, 2020
@robodoo robodoo removed the CI 🤖 label Jan 20, 2020
@tivisse tivisse force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch 2 times, most recently from d98306f to 3f3fd26 Jan 20, 2020
1/ When the new database is created without demo data, the admin has a
   'silhouette' as a default picture. When a new user is created without
   picture given by the current user, the new user will have a 'silhouette'
   as a default profile picture.

2/ web: image for fa-user-slash. This image will be used when a record is
   unassigned.

3/ web, *: Change placeholder by default when record is unassigned.
   We want to have a fa-user-slash icon when a record is unassigned instead
   of 'placeholder.png'. A method is created in the BaseModel to have a
   generic method to change easily the placeholder for other models.

4/ Adapt kanban test to keep the same behaviour. Attention the behaviour is
   a bit different. Because, now the default image is given by the server to
   change easily the default image when a record doesn't have an image.
   Thus, we don't say if it's the default placeholder, but we can say it's
   not the same image of the record (in this test, the record, it's the
   partner).

5/ misc: display 'Unassigned' in the hover on kanban cards if record is unassigned

Co-authored-by: jdoutreloux <jud@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>

TaskID: 2060206
@tivisse tivisse force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from 3f3fd26 to 48fdc58 Jan 21, 2020
@tivisse

This comment has been minimized.

Copy link
Contributor Author

tivisse commented Jan 21, 2020

@robodoo

This comment has been minimized.

Copy link
Contributor

robodoo commented Jan 21, 2020

Linked pull request(s) odoo/enterprise#7758 not ready. Linked PRs are not staged until all of them are ready.

robodoo pushed a commit that referenced this pull request Jan 21, 2020
1/ When the new database is created without demo data, the admin has a
   'silhouette' as a default picture. When a new user is created without
   picture given by the current user, the new user will have a 'silhouette'
   as a default profile picture.

2/ web: image for fa-user-slash. This image will be used when a record is
   unassigned.

3/ web, *: Change placeholder by default when record is unassigned.
   We want to have a fa-user-slash icon when a record is unassigned instead
   of 'placeholder.png'. A method is created in the BaseModel to have a
   generic method to change easily the placeholder for other models.

4/ Adapt kanban test to keep the same behaviour. Attention the behaviour is
   a bit different. Because, now the default image is given by the server to
   change easily the default image when a record doesn't have an image.
   Thus, we don't say if it's the default placeholder, but we can say it's
   not the same image of the record (in this test, the record, it's the
   partner).

5/ misc: display 'Unassigned' in the hover on kanban cards if record is unassigned

closes #41356

Taskid: 2060206
Related: odoo/enterprise#7758
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: jdoutreloux <jud@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
@robodoo robodoo closed this Jan 21, 2020
@robodoo robodoo deployed to merge Jan 21, 2020 Active
@tivisse tivisse deleted the odoo-dev:master-base-default-profile-picture-xbo branch Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.