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

Open
wants to merge 1 commit into
base: master
from

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
@jdoutreloux jdoutreloux force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from fc18b39 to b8a44c4 Jan 15, 2020
@robodoo robodoo removed the CI 🤖 label Jan 15, 2020
@jdoutreloux jdoutreloux force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from b8a44c4 to 453b8c1 Jan 15, 2020
@robodoo robodoo added the CI 🤖 label Jan 15, 2020
Copy link
Contributor Author

tivisse left a comment

Small review. Thanks.

@@ -59,7 +59,7 @@
<div t-attf-class="oe_kanban_card oe_kanban_global_click">
<div>
<strong><span><field name="analytic_id"/></span></strong>
<img t-att-src="kanban_image('res.users', 'image_128', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" class="oe_kanban_avatar o_image_24_cover float-right"/>
<img t-att-src="kanban_image('res.users', 'image_128', record.user_id.raw_value)" t-att-title="record.user_id.value || 'Unassigned'" t-att-alt="record.user_id.value" class="oe_kanban_avatar o_image_24_cover float-right"/>

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 15, 2020

Author Contributor

Check translation. ;)

if not self.id:
return 'user-slash.png'
else:
return 'placeholder.png'

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 15, 2020

Author Contributor

return super()

* override method
method used into _content_image in odoo/addons/web/controllers/main.py
"""
if not self.id:

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 15, 2020

Author Contributor

Add comment to explain that ;)

@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 15, 2020

Author Contributor

Why not setting the image as a default value ?

@@ -293,6 +293,10 @@ def _get_record_and_check(self, xmlid=None, model=None, id=None, field='datas',
if xmlid:
record = self._xmlid_to_obj(self.env, xmlid)
elif id and model in self.env:
# try:

This comment has been minimized.

Copy link
@tivisse

tivisse Jan 15, 2020

Author Contributor

Commented code :)

@jdoutreloux jdoutreloux force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from 453b8c1 to c519d23 Jan 16, 2020
@robodoo robodoo removed the CI 🤖 label Jan 16, 2020
@jdoutreloux jdoutreloux force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch 3 times, most recently from dfdf1a5 to 50f88f1 Jan 16, 2020
@robodoo robodoo added the CI 🤖 label Jan 16, 2020
@jdoutreloux jdoutreloux changed the title [MERGE] Insert Commit Message [MERGE] base, misc : Default profile picture for new users. Jan 16, 2020
@jdoutreloux jdoutreloux force-pushed the odoo-dev:master-base-default-profile-picture-xbo branch from 50f88f1 to e5f8157 Jan 16, 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
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 0dfedb8 to d98306f Jan 20, 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.