Skip to content

[19.0][IMP] mail_attach_existing_attachment: foldable attachment sections - #243

Open
cliffkujala wants to merge 3 commits into
OCA:19.0from
purekarting:19.0-mail_attach_existing_attachment-foldable-sections
Open

[19.0][IMP] mail_attach_existing_attachment: foldable attachment sections#243
cliffkujala wants to merge 3 commits into
OCA:19.0from
purekarting:19.0-mail_attach_existing_attachment-foldable-sections

Conversation

@cliffkujala

Copy link
Copy Markdown

What

The composer lists every attachment already on the record as one long column of checkboxes. On a record with any mail history that column pushes the Send button off screen, and the filenames a mail thread accumulates (image001.png, image002.png, ...) are impossible to tell apart.

This groups the composer's attachments under two foldable headers, using the same hr/caret header core already uses for Planned Activities:

  • Available Attachments is the existing picker. It starts folded, its header counts what is on offer (or what is ticked, once folded back), and unfolded it lays the checkboxes out in as many columns as the composer is wide enough for. The grid is repeat(auto-fill, minmax(min(15rem, 100%), 1fr)), so the column count follows the dialog's own width rather than the viewport's.
  • New Attachments shows the files added to this mail as the same cards the chatter uses (AttachmentList), instead of the plain list of links Odoo 19 renders. It only appears once there is at least one file.

The picker also loads its choices with search_read rather than name_search, whose default limit of 100 silently dropped the oldest attachments of a busy record, and shows each file's size.

Only the comment-mode composer is touched. Mass mail keeps the stock widget, which is consistent with can_attach_attachment already being False there.

Two notes for reviewers:

  • Both widgets set --fieldWidget-display: block, as core's mail_composer_attachment_list does. Without it the field wrapper is inline-block, the header rules have nothing to grow into and the grid cannot get past one column.
  • The min() in the grid template is interpolated (#{"min(15rem, 100%)"}), because libsass otherwise evaluates it as a Sass function and fails on comparing rem with %.

Test plan

  • Existing Python tests pass.
  • Verified in a browser: Available Attachments folded with its count, unfolding into a grid that reflows 3/2/1 as the dialog is resized; New Attachments showing cards and hidden while empty.
  • web.assets_backend compiles with the new SCSS.

The composer listed every attachment already on the record as one long
column of checkboxes, which pushes Send off screen on a record with any
mail history.

Group the composer's attachments under two foldable headers instead.
"Available Attachments" holds the picker, starts folded, and lays its
checkboxes out in as many columns as the composer is wide enough for.
"New Attachments" shows the files added to this mail as the same cards
the chatter uses, and only appears once there is one.

The picker also loads its choices with search_read rather than
name_search, whose default limit of 100 silently dropped the oldest
attachments, and shows each file's size to tell apart the images a mail
thread accumulates under names like image001.png.
@pedrobaeza

Copy link
Copy Markdown
Member

Please put screenshots. Is this AI assisted? You should indicate it if so. Another thing: this seems more [IMP] than [FIX].

@cliffkujala

Copy link
Copy Markdown
Author

I agree this is more [IMP] than fix. Screen shots below. Is there really much code being created these days that isn't AI assisted?
Screenshot 2026-08-10 at 06 08 42
Screenshot 2026-08-10 at 06 09 14
Screenshot 2026-08-10 at 06 09 48
Screenshot 2026-08-10 at 06 10 14
Screenshot 2026-08-10 at 06 14 58

In a column narrow enough to matter, the size label gave up space along
with the filename and wrapped ("12.67" over "Kb"), making that one entry
two lines tall and knocking the rest of its grid row out of alignment.

Pin the size at its natural width and let the name be the only part that
shrinks, so it truncates and the row stays one line. Both spans get a
class of their own rather than being matched by position, since an
attachment with no recorded size has no second span at all.
…ew on hover

Odoo sizes .o-checkbox with width: fit-content. The name is nowrap, so
its min-content width is the whole filename and fit-content resolved to
that: rows sized themselves to their text and spilled across the next
column's checkbox instead of truncating. min-width: 0 cannot override an
explicit width, so stretch the row to its grid track.

Truncating hides information, so give it back on hover. The tooltip
service already renders a template from data-tooltip-info, which costs
one delegated listener for the page however many attachments the record
has. It shows the full name, the size, and a preview: the image itself,
or the thumbnail Odoo generated for a PDF. Other file types get no
picture, since /web/image would only serve back a mimetype placeholder.
@cliffkujala
cliffkujala force-pushed the 19.0-mail_attach_existing_attachment-foldable-sections branch from 02ab09b to 7860c44 Compare August 10, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:mail_attach_existing_attachment Module mail_attach_existing_attachment series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants