Skip to content

[IMP] web_field_company_dependent_flag: Better icon rendering - #1053

Open
legalsylvain wants to merge 2 commits into
OCA:16.0from
grap:16.0-FIX-company_dependent_flag-SLG
Open

legalsylvain wants to merge 2 commits into
OCA:16.0from
grap:16.0-FIX-company_dependent_flag-SLG

Conversation

@legalsylvain

@legalsylvain legalsylvain commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Otherwise the icon is shown within the value space of the field and also influences the font used.

  1. backport of 8c18c5b done by @SirPyTech in the migration (and rename of web_field_company_dependent_flag) company_dependent_flag module

  2. also apply some simplification, overloading fields_get instead of _get_view.
    It makes the code more easy.
    This implementation is based on the web_field_tooltip implementation. See : https://github.com/OCA/web/blob/16.0/web_field_tooltip/models/base.py#L28

  3. apply same display as in odoo core.

  • put a margin to avoid to join text and building icon.
  • add test to avoid to display the buidling icon, if user is not member of multicompany group
  • add fa-lg as in odoo core

Before

image

After

image

Otherwise the icon is shown within the value space of the field and also
influences the font used.

@SirPyTech SirPyTech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please keep the cherry-picked commit as similar as possible to the original commit 8c18c5b (now e6f1f66).

praise: Using fields_get instead of _get_view feels less clunky 👍

issue: Any idea why I can't see the icon in runboat?
Image
http://oca-multi-company-16-0-pr1053-296ccad38c86.runboat.odoo-community.org/web?debug=assets#id=23&cids=1&menu_id=111&action=249&model=product.template&view_type=form

Comment on lines -11 to +12
def _get_view(self, view_id=None, view_type="form", **options):
arch, view = super()._get_view(view_id, view_type, **options)
if view_type == "form":
self._update_company_dependent_css(arch)
return arch, view

def _update_company_dependent_css(self, arch):
cpny_dep_fields = [
def fields_get(self, allfields=None, attributes=None):
result = super().fields_get(allfields=allfields, attributes=attributes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

chore: Moving from _get_view to fields_get should be in another commit, otherwise this is very different from my original commit 8c18c5b (now e6f1f66)

"depends": [
"base",
],
"depends": ["web"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

question: Is this really needed? If so, should I have it in #1052 too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think if this change is necessary but the module does'nt work without web installed : https://github.com/grap/multi-company/blob/16.0-FIX-company_dependent_flag-SLG/company_dependent_flag/static/src/form_label.esm.js#L6-L7

If so, should I have it in #1052 too?

Yes, ideally.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 added

I don't think I have ever seen an installation without web though

Comment thread company_dependent_flag/models/base.py Outdated
"""Inherit to apply your own class"""

return ["fa", "fa-building-o", "d-flex", "flex-row"]
return ["fa", "fa-lg", "fa-building-o", "company_dependent_field_icon"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: fa-lg is increasing the height of the whole row, that does not look good, can we drop it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't saw ! thanks for the review. I removed fa-lg.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread company_dependent_flag/models/base.py Outdated
"""Inherit to apply your own class"""

return ["fa", "fa-building-o", "d-flex", "flex-row"]
return ["fa", "fa-lg", "fa-building-o", "company_dependent_field_icon"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

praise: The dedicated class will help when we want to further customize the element 👏

@legalsylvain

Copy link
Copy Markdown
Contributor Author

issue: Any idea why I can't see the icon in runboat?

image

is a good reason !

I don't know why, but since some days, I have to manually install modules on OCA runboat...

- put a margin to avoid to join text and building icon.
- add test to avoid to display the buidling icon, if user is not member of multicompany group
- add fa-lg as in odoo core
@legalsylvain
legalsylvain force-pushed the 16.0-FIX-company_dependent_flag-SLG branch from 296ccad to 1cadf16 Compare September 8, 2026 08:07
@legalsylvain

Copy link
Copy Markdown
Contributor Author

Please keep the cherry-picked commit as similar as possible to the original commit 8c18c5b (now e6f1f66).

Hum. sorry, I don't know exactly how to split a commit in two commit, when there are other commit on top of this one. Is a blocking problem, as this branch is not the "head" one, and this "problem" will be forgotten in more recent version ?

@SirPyTech SirPyTech left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: Any idea why I can't see the icon in runboat?

image

is a good reason !

I don't know why, but since some days, I have to manually install modules on OCA runboat...

🤦‍♂️ I should have checked, sorry for the noise, I confirm it works correctly when the module is installed: Image
you can use this image for the README so it comes from 16.0 and shows the tooltip 😉
For your info, no module is installed in runboat when there are rebel modules, that is the case for this repository:

rebel_module_groups:
- product_category_company
- partner_multi_company
.

Please keep the cherry-picked commit as similar as possible to the original commit 8c18c5b (now e6f1f66).

Hum. sorry, I don't know exactly how to split a commit in two commit, when there are other commit on top of this one. Is a blocking problem, as this branch is not the "head" one, and this "problem" will be forgotten in more recent version ?

I'm sorry but I'd like the commit I authored to be accurate with what I did so for me it's blocking.
A small change is fine but switching from _get_view to fields_get was not the purpose of that commit.

You can add yourself as a co-author and keep it as-is, or you can cherry-pick it again, and then apply your commits on top of it: in case of conflicts just accept your code.
For your info, the right way to split the commit in two is: git rebase, choose edit for that commit, create the new commits as you like, continue the rebase.

Comment thread company_dependent_flag/models/base.py Outdated
"""Inherit to apply your own class"""

return ["fa", "fa-building-o", "d-flex", "flex-row"]
return ["fa", "fa-lg", "fa-building-o", "company_dependent_field_icon"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:company_dependent_flag Module company_dependent_flag series:16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants