Conversation
40c214e to
3b83a55
Compare
3b83a55 to
9395b7d
Compare
marcos-mendez
left a comment
There was a problem hiding this comment.
Automated Review -- Tests Failed
1. Root Cause
The test failure occurs because the ir.mail_server model's build_email method is being overridden, but the super() call does not properly pass all arguments due to an incorrect signature mismatch in the method definition.
2. Suggested Fix
In mail_external_cleaner/models/ir_mail_server.py, line 32, the method signature should match the parent class exactly. Specifically, the parameter subtype_alternative is missing from the method definition. Correct the method signature to include all parameters expected by super().build_email().
def build_email(
self,
email_from,
email_to,
subject,
body,
email_cc=None,
email_bcc=None,
reply_to=False,
attachments=None,
message_id=None,
references=None,
object_id=False,
subtype="plain",
headers=None,
body_alternative=None,
subtype_alternative="plain", # <-- Add this line
):3. Additional Code Issues
- In
mail_mail.py: The_get_image_attachmentmethod does not handle exceptions when decoding base64 data or fetching attachments, which could cause runtime errors if invalid data is encountered. - In
mail_mail.py: The regex patternIMAGE_REGEXis not robust enough to handle all possible image URLs and may miss edge cases; it's better to use a more flexible approach or validate URL structure more strictly.
4. Test Improvements
Add tests using TransactionCase to cover:
- Sending emails with inline images using data URIs.
- Ensuring that
build_emailcorrectly processes HTML content and replaces data URIs with inline attachments. - Testing
_embed_imageswith various image sources including local company logos and IR attachments. - Verifying that portal customer access is disabled in email notifications via
_notify_get_recipients_groups.
Use tagged tests for:
@tag('post_install')for integration tests.@tag('at_install')for tests that must run at module installation time.
Example test case:
def test_build_email_with_inline_images(self):
server = self.env['ir.mail_server'].create({})
body = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==">'
msg = server.build_email('test@example.com', 'to@example.com', 'Subject', body, subtype='html')
self.assertIn('Content-ID', msg.get_payload(0).get_headers())This ensures proper handling of inline images and correct attachment processing during email sending.
⏰ PR Aging Alert
This PR by @etobella has been open for 130 days (4 months).
💤 No activity for 94 days. Has this PR been forgotten?
Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)
Reciprocal Review Request
Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):
My open PRs across OCA:
- server-tools#3554 [MIG] datetime_formatter: Migration to 18.0
- server-tools#3548 [18.0][MIG] base_kanban_stage: Migration to 18.0
- hr-attendance#262 [16.0][ADD] Hr_attendance_idsecure: iDSecure (ControliD) attendance integration
- stock-logistics-workflow#2276 [16.0][ADD] stock_move_line_devaluation
- stock-logistics-workflow#2275 [16.0][ADD] Stock move line analytic account
- stock-logistics-workflow#2268 [16.0][ADD] stock_move_line_picking_partner
- purchase-workflow#2694 [16.0][IMP]Purchase workflow added to review state & exception fix
Reviewing each other's work helps the whole community move forward. Thank you!
Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b

Clean up email content by removing unnecessary external resources.
Makes sense for isolated environments with emails.
TODO: