Skip to content

[17.0][IMP+FIX] base_import_pdf_by_template_account: Suitable value of sort_weight in _unwrap_edi_attachments() method if applicable#1181

Open
victoralmau wants to merge 4 commits intoOCA:17.0from
Tecnativa:17.0-imp-base_import_pdf_by_template_account-TT56274
Open

[17.0][IMP+FIX] base_import_pdf_by_template_account: Suitable value of sort_weight in _unwrap_edi_attachments() method if applicable#1181
victoralmau wants to merge 4 commits intoOCA:17.0from
Tecnativa:17.0-imp-base_import_pdf_by_template_account-TT56274

Conversation

@victoralmau
Copy link
Member

Suitable value of sort_weight in _unwrap_edi_attachments() method if applicable

Example of use case:

  • Create a pdf template linked to invoices.
  • Define an email alias to automatically create the invoices and process the attachments
  • Send an email to the alias with 2 attachments: example.xml and example.pdf

Before:
The _unwrap_edi_attachments() method indirectly applied a lower sort_weight value (10) to the example.xml file than to the example.pdf file (20), which meant that the https://github.com/odoo/odoo/blob/399da69818d22860a808f5416829863f002ad38a/addons/account/models/account_move.py#L3202 condition was met for the example.pdf file and the pdf was not processed correctly (https://github.com/odoo/odoo/blob/399da69818d22860a808f5416829863f002ad38a/addons/account/models/account_move.py#L3215).

After:
The _unwrap_edi_attachments() method modifies the value of sort_weight in .pdf files if there is +1 file and if there is any pdf import template that applies to the corresponding record.

Future:
In v19 (master for now) the process has been improved using the account.document.import.mixin and https://github.com/odoo/odoo/blob/cf4e5b95c34357e5129adf9c78429f7c1a4ea33e/addons/account/models/account_document_import_mixin.py#L318 template.

@Tecnativa TT56274

@victoralmau victoralmau force-pushed the 17.0-imp-base_import_pdf_by_template_account-TT56274 branch 4 times, most recently from 4d0eb4e to aae2a51 Compare July 1, 2025 09:16
@victoralmau victoralmau changed the title [17.0][WIP] base_import_pdf_by_template_account: Suitable value of sort_weight in _unwrap_edi_attachments() method if applicable [17.0][IMP+FIX] base_import_pdf_by_template_account: Suitable value of sort_weight in _unwrap_edi_attachments() method if applicable Jul 1, 2025
@victoralmau victoralmau marked this pull request as ready for review July 1, 2025 09:59
@victoralmau victoralmau force-pushed the 17.0-imp-base_import_pdf_by_template_account-TT56274 branch from aae2a51 to 0b59513 Compare September 30, 2025 10:19
@victoralmau
Copy link
Member Author

Please @pedrobaeza and @sergio-teruel can you review it?

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Feb 1, 2026
…ght in _unwrap_edi_attachments() method if applicable

Example of use case:
- Create a pdf template linked to invoices.
- Define an email alias to automatically create the invoices and process the attachments
- Send an email to the alias with 2 attachments: example.xml and example.pdf

Before:
The _unwrap_edi_attachments() method indirectly applied a lower sort_weight value (10) to the example.xml file than to the example.pdf file (20), which meant that the https://github.com/odoo/odoo/blob/399da69818d22860a808f5416829863f002ad38a/addons/account/models/account_move.py#L3202 condition was met for the example.pdf file and the pdf was not processed correctly (https://github.com/odoo/odoo/blob/399da69818d22860a808f5416829863f002ad38a/addons/account/models/account_move.py#L3215).

After:
The _unwrap_edi_attachments() method modifies the value of sort_weight in .pdf files if there is +1 file and if there is any pdf import template that applies to the corresponding record.

Future:
In v19 (master for now) the process has been improved using the account.document.import.mixin and https://github.com/odoo/odoo/blob/cf4e5b95c34357e5129adf9c78429f7c1a4ea33e/addons/account/models/account_document_import_mixin.py#L318 template.

TT56274
…ontext value to avoid error when processing the record

TT56274
…d process

It is very important to have a log of the exception to better understand what is
happening (a badly formatted value or a field that does not exist in the view
by the user who is executing it).

TT56274
@victoralmau victoralmau force-pushed the 17.0-imp-base_import_pdf_by_template_account-TT56274 branch from 0b59513 to ef8bd2a Compare February 2, 2026 12:34
@victoralmau
Copy link
Member Author

Ping @pedrobaeza and @sergio-teruel

@pedrobaeza pedrobaeza added this to the 17.0 milestone Feb 2, 2026
@pedrobaeza pedrobaeza removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Feb 2, 2026
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.

2 participants