[ADD] attachment_pdfa - #651
Open
baimont wants to merge 1 commit into
Open
Conversation
baimont
force-pushed
the
bai_pdf_to_pdfa
branch
2 times, most recently
from
August 4, 2026 15:03
10ec074 to
e778a80
Compare
baimont
force-pushed
the
bai_pdf_to_pdfa
branch
from
August 4, 2026 15:23
e778a80 to
7d31322
Compare
Author
AnizR
reviewed
Aug 4, 2026
| """Check if attachment creation dictionary qualifies for conversion.""" | ||
| mimetype = vals.get("mimetype", "") | ||
| name = vals.get("name", "") | ||
| if not (mimetype == "application/pdf" or name.lower().endswith(".pdf")): |
There was a problem hiding this comment.
Suggested change
| if not (mimetype == "application/pdf" or name.lower().endswith(".pdf")): | |
| if not (mimetype == "application/pdf" or not name.lower().endswith(".pdf")): |
| _logger.exception(msg) | ||
| return raw_content, False, msg | ||
|
|
||
| def _should_convert_to_pdfa(self, vals): |
| ) | ||
|
|
||
| @api.model_create_multi | ||
| def create(self, vals_list): |
There was a problem hiding this comment.
What about the write function?
Odoo has some workflows where they create the attachment then do a write to link to a record. IMO, in this case, the conversion should also be applied.
Comment on lines
+36
to
+41
| ps_content = re.sub( | ||
| r"/ICCProfile \((.+)\)", | ||
| f"/ICCProfile ({rgb_profile})", | ||
| ps_content, | ||
| ) | ||
| try: |
There was a problem hiding this comment.
Is it really necessary modify the icc_profile_ps each time?
If not, I am wondering if the 'temp_ps' below is still needed
lmignon
reviewed
Aug 5, 2026
Comment on lines
+28
to
+34
| data_dir = Path(__file__).parent.parent / "data" | ||
| icc_profile_ps = data_dir / "pdfa_def.ps" | ||
| rgb_profile = data_dir / "iccprofiles_default_rgb.icc" | ||
| if not icc_profile_ps.is_file() or not rgb_profile.is_file(): | ||
| msg = "Ghostscript ICC Profile or PDF/A definition file not found." | ||
| _logger.error(msg) | ||
| return raw_content, False, msg |
Contributor
There was a problem hiding this comment.
These paths should be initialized and checked when the module is imported. (at the top of the file).
lmignon
reviewed
Aug 5, 2026
| if not (res_model and res_id): | ||
| return False | ||
| model_obj = self.env.get(res_model) | ||
| if model_obj is None or not hasattr(model_obj, "_attachment_must_be_pdfa"): |
Contributor
There was a problem hiding this comment.
This check should be put into a dedicated method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here's a proposal for a new module that will allow to convert PDF attachments to PDF/A.
It does nothing on itself.
Developer has to implement which models must opt-in by inheriting
attachment.pdfa.mixinand override_attachment_must_be_pdfa().