Skip to content

[ADD] UI: odoo spreadsheets svg icons #13386

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

Closed
wants to merge 1 commit into from

Conversation

samueljlieber
Copy link
Contributor

@samueljlieber samueljlieber commented May 15, 2025

Task: #4792034

This PR proposes introducing the o-spreadsheet icons into the Odoo documentation.


How this works

The Spreadsheet library in Odoo contains two QWeb template files for SVG icons:

These were used to generate an SVG sprite file (extensions/odoo_theme/static/img/odoo-spreadsheet-icons.svg), which can then be utilized by the SVG <use>element to call nodes by ID in the sprite.

This SVG sprite file is then included in the main page layout (extensions/odoo_theme/layout.html)

The RST :icon: role was updated to accomodate an os-* icon specifier.

The SVG sprite file can be generated automatically via a simple script outlined in this gist:
https://gist.github.com/samueljlieber/5ae7648a5ca08e0bfc8455861825e2ff


Why?

This PR attempts to scale an earlier method I used, the RST raw-html(raw) role includes the <svg> markup directly in the Global Filters doc (see this diff).

This was/is not scalable, is not usable throughout multiple docs, and will decay over time as the o-spreadsheet library is updated. This PR attempts to find a solution for using o-spreadsheet icons in documentation.

os-icons-versions

Example

With this implementation, o-spreadsheet icons can be used like so:

This is the :icon:`os-global-filters` :guilabel:`(global filters)` icon!

@samueljlieber samueljlieber self-assigned this May 15, 2025
@robodoo
Copy link
Collaborator

robodoo commented May 15, 2025

Pull request status dashboard

@samueljlieber samueljlieber added the technical improvement Technically improve the documentation site label May 15, 2025
@AntoineVDV AntoineVDV requested a review from rugo-odoo May 19, 2025 08:58
Copy link

@rugo-odoo rugo-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 little details and we should be good to go 😎

@@ -125,7 +126,12 @@ def icon_role(name, rawtext, text, lineno, inliner, options=None, content=None):
icon_html = f'<i class="oi {text}"></i>'
elif text.startswith('fa-'):
icon_html = f'<i class="fa {text}"></i>'
elif text.startswith('os-'):
icon_html = (
f'<svg class="os-icon" aria-hidden="true" role="img">'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f'<svg class="os-icon" aria-hidden="true" role="img">'
'<svg class="os-icon" aria-hidden="true" role="img">'

elif text.startswith('os-'):
icon_html = (
f'<svg class="os-icon" aria-hidden="true" role="img">'
f' <use href="#{text[3:]}" />'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little comment about why text[3:] and not just text will be nice.

@samueljlieber samueljlieber force-pushed the master-ui-icons-spreadsheet-sali branch from 5447d56 to a682396 Compare May 21, 2025 19:20
@samueljlieber samueljlieber marked this pull request as ready for review May 21, 2025 19:22
@C3POdoo C3POdoo requested review from a team May 21, 2025 19:24
@samueljlieber
Copy link
Contributor Author

Hi @rugo-odoo! Thank you for your review 😄 I implemented your helpful suggestions and opened this PR up from draft.

I figured I could manually backport to 18.0 once merged, WDYT? :)

@samueljlieber samueljlieber requested a review from rugo-odoo May 21, 2025 19:39
Copy link
Collaborator

@AntoineVDV AntoineVDV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured I could manually backport to 18.0 once merged, WDYT? :)

You should rather re-target this PR and let the automatic forward-port handle master after.


Follow the icon with its name as a :ref:`contributing/rst/guilabel` in brackets as a descriptor.

.. spoiler:: View supported Odoo Spreadsheets icons
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be hosted at the same place as Odoo UI icons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it can be, I wasn't sure of the best place to list the Odoo Spreadsheet (os-*) icons, since they are not part of the Odoo UI (oi-*) font-family.

Adding them to the developer/reference/user_interface/icons page in the same format would be a convenient and logical place. I'll add a header for Odoo Spreadsheet icons :)

@@ -113,6 +113,7 @@
{%- else %}
<article id="o_content" class="doc-body">
<div role="main"> {# Beacon used by the Sphinx search to know where to look for a string #}
{% include "static/img/odoo-spreadsheets-icons.svg" %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why here in particular? Shouldn't this go in another, assets-dedicated block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included the svg sprite file here because I wanted it to be contained within main document body, however, looking at it again there is a better spot– as well the opportunity to create an "assets.html" layout_template to include this and future assets as well :)

@samueljlieber samueljlieber force-pushed the master-ui-icons-spreadsheet-sali branch from a682396 to 9f9eea4 Compare May 22, 2025 20:37
@samueljlieber samueljlieber changed the base branch from master to 18.0 May 22, 2025 20:37
@C3POdoo C3POdoo requested a review from a team May 22, 2025 20:39
@samueljlieber
Copy link
Contributor Author

Thank you @AntoineVDV for your helpful comments!

Changes in 9f9eea4:

  • re-targeted this PR to 18.0 in prep for FWP to master
  • Updated the odoo-spreadsheet-icons.svg sprite to 18.0 Odoo Spreadsheet
  • Created an assets-specific block in extensions/odoo_theme/layout.html to conditionally include the sprite file to address this comment
  • Added the Spreadsheet icons to the Developer UI icons doc to addresses this comment
  • Updated the RST guidelines :icon: markup to include these changes

Ready for another look, thanks all! :)

Copy link
Collaborator

@AntoineVDV AntoineVDV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robodoo delegate+

@samueljlieber
Copy link
Contributor Author

@robodoo r+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical improvement Technically improve the documentation site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants