Merge pull request #6201 from expsa/samir_aladawi_fix_state_sponsorship

[FIX] odex_takaful
This commit is contained in:
SamirLADOUI-sa 2026-01-13 22:19:32 +01:00 committed by GitHub
commit 308b426b5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 0 deletions

View File

@ -2,6 +2,7 @@
from . import _cart_change from . import _cart_change
from . import report_api from . import report_api
from . import takaful_api from . import takaful_api
from . import mail_controller

View File

@ -0,0 +1,30 @@
from odoo import http
from odoo.http import request
from odoo.addons.mail.controllers.main import MailController
class MailControllerPatch(MailController):
@http.route('/mail/thread/data', methods=['POST'], type='json', auth='user')
def mail_thread_data(self, thread_model, thread_id, request_list, **kwargs):
if thread_model != 'res.partner':
return super(MailControllerPatch, self).mail_thread_data(thread_model, thread_id, request_list, **kwargs)
res = {}
thread = request.env[thread_model].with_context(active_test=False).search([('id', '=', thread_id)])
# --- PATCH: Force Singleton ---
# We have patched the search method in res.partner model in path /odex_takaful/models/res_partner.py
# It triggers a singlton error
# We need to get the thread_id of res.partner only
thread = thread.filtered(lambda r: r.id == thread_id)
# ------------------------------
if 'attachments' in request_list:
res['attachments'] = thread.env['ir.attachment'].search([
('res_id', '=', thread.id),
('res_model', '=', thread._name)
], order='id desc')._attachment_format(commands=True)
return res