[FIX] odex_takaful
This commit is contained in:
parent
cfa4265b01
commit
04a7fbb9c6
|
|
@ -2,6 +2,7 @@
|
|||
from . import _cart_change
|
||||
from . import report_api
|
||||
from . import takaful_api
|
||||
from . import mail_controller
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in New Issue