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

[IMP] web: inconsistencies between custom button icons in Form views and List View buttons #13983

Closed
wants to merge 2 commits into from

Conversation

danidee10
Copy link
Contributor

@danidee10 danidee10 commented Oct 26, 2016

Description of the issue/feature this PR addresses:
This PR aims to fix inconsistencies between custom button icons in form views and list views, There is no condition in base.xml to check if the button icon is from an external source or a custom module.

For a better description of what this PR aims to solve please read my answer to this Stackoverflow question

Current behavior before PR:
In a form view we can add a custom icon to a button by specifying the full path to the icon. e.g

<button name="do_stuff" type="object" icon="/my_module/static/src/img/icons/icon.png" />

This is not the same behaviour for List View icons, even if we specify the full path to the icon, Odoo still appends the default icon location path (/web/static/src/img/icons) and .png to the icon location. so we end up with a path like this

<img src="{hostname:port}/web/static/src/img/icons//my_module/static/src/img/icons/icon.png.png" />

To overcome this, you have to use sleazy hacks like this:

<button name="do_stuff" icon="../../../../../my_module/static/src/img/icons/icon" type="object"/>

this would obviously break, because it's a relative link

Note: This problem is also present in 9.0

Desired behavior after PR is merged:
Custom ListView button icons can now be declared the same way you would declare a custom icon for a button in a form view.

I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@danidee10 danidee10 changed the title 8.0 imp [web]: Fix inconsistencies between custom button icons in Form views and List View buttons Oct 26, 2016
@danidee10 danidee10 changed the title imp [web]: Fix inconsistencies between custom button icons in Form views and List View buttons [IMP] web: inconsistencies between custom button icons in Form views and List View buttons Oct 26, 2016
@danidee10
Copy link
Contributor Author

@ged-odoo any observation or thoughts on this?

@MouTio
Copy link
Contributor

MouTio commented Oct 30, 2016

Awesome!
The same fix worked for me in Odoo 9.

@danidee10
Copy link
Contributor Author

danidee10 commented Nov 4, 2016

Hello @xmo-odoo and @ged-odoo what do you think about this? please review

@ged-odoo
Copy link
Contributor

ged-odoo commented Nov 4, 2016

@danidee10

Thank you for your suggestion. Here are a few thoughts:

  • I agree on the spirit of this PR, that is, form and list view should behave in the same way
  • this is not really a bug fix (debatable, I know), I don't think it should go in a stable release (I know that it is not really risky, still, the point is that improvements should go in master)
  • In my opinion, the correct solution is to never add the prefix to the path. So, every view, form or list, should directly use the widget.icon string, such as "/my_module/static/src/img/icons/cat.png". For this to work, we need to update all templates that uses icons in the web addon and replace 'some-icon.png' by '/web/static/src/img/icons/some-icon.png'.

So, I'll be open to merge a PR doing this in master. In the meantime, I'll close this one.

@ged-odoo ged-odoo closed this Nov 4, 2016
@danidee10
Copy link
Contributor Author

In my opinion, that's going to be "really risky" and disruptive because they're a lot of OCA modules that depend on the prefix functionality, so if the prefix is removed, the authors of these community modules would also have to update all the icon paths in their modules too.

Thanks for responding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants