Skip to content

[16.0][IMP] lighting_export_xlsx: group attachment columns by type#101

Open
deeniiz wants to merge 2 commits into
16.0from
16.0-imp-lighting_export_xlsx-group_attachments_by_type
Open

[16.0][IMP] lighting_export_xlsx: group attachment columns by type#101
deeniiz wants to merge 2 commits into
16.0from
16.0-imp-lighting_export_xlsx-group_attachments_by_type

Conversation

@deeniiz
Copy link
Copy Markdown
Collaborator

@deeniiz deeniiz commented May 18, 2026

No description provided.

deeniiz added 2 commits May 18, 2026 12:21
Replace the position-based attachment columns (Adjuntos1/Tipo,
Adjuntos1/URL, Adjuntos2/Tipo, ...) with type-based columns where each
attachment type is its own column ("Foto producto (F) 1", "Foto de
aplicacion (FA) 1", "Foto de aplicacion (FA) 2", ...). The Tipo column
is eliminated; the type becomes the column header itself.

LightingAttachment.export_xlsx now returns an OrderedDict (one entry per
attachment, keyed by "<type display_name> <N>") instead of a list of
{Tipo, URL} dicts. The counter is per type and per product, starting at
1.

The report gains a new _set_flat_columns helper plus an
isinstance(datum, dict) branch in _generate_products so that this new
flat return shape is expanded directly into obj_d and meta["subfields"]
without the "FieldNameJ/" prefix that _get_meta_num applies. The
existing list[OrderedDict] path used by other one2many fields
(suppliers, sources, ...) is untouched.
After processing all products, sort the accumulated meta["subfields"] of
flat-mode fields (attachments) according to the template's
attachment_ids.sequence, grouping duplicates of the same type
contiguously (FA 1, FA 2, FA 3, ...).

Without this sort, the column order was insertion-order during product
iteration: a type only present in a later-processed product ended up at
the right of the spreadsheet even if the template defined it earlier.

The sort key is built from a type display_name -> sequence map derived
from template_id.attachment_ids, parsing each subfield with rsplit to
extract (type, counter). Only fields flagged with _flat_mode are sorted,
so the existing position-based one2many fields (suppliers, sources, ...)
are not affected.
@deeniiz deeniiz added the to review Must be reviewed label May 18, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

❌ Patch coverage is 8.33333% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.77%. Comparing base (2bf6baa) to head (5a088f8).

Files with missing lines Patch % Lines
lighting_export_xlsx/report/export_product_xlsx.py 7.40% 25 Missing ⚠️
lighting_export_xlsx/models/product_attachment.py 11.11% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             16.0     #101      +/-   ##
==========================================
- Coverage   43.91%   43.77%   -0.15%     
==========================================
  Files         285      285              
  Lines        8149     8181      +32     
  Branches     1566     1576      +10     
==========================================
+ Hits         3579     3581       +2     
- Misses       4475     4505      +30     
  Partials       95       95              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@deeniiz deeniiz requested a review from eantones May 18, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

to review Must be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant