19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:39 +01:00
parent 5df8c07b59
commit daa394e8b0
2114 changed files with 564841 additions and 299642 deletions

View file

@ -1,11 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from collections import defaultdict
from operator import itemgetter
from odoo import exceptions, fields, models
from odoo.tools import groupby
from odoo import fields, models
class MailMessage(models.Model):
@ -14,9 +9,9 @@ class MailMessage(models.Model):
gateway. """
_inherit = 'mail.message'
message_type = fields.Selection(selection_add=[
('sms', 'SMS')
], ondelete={'sms': lambda recs: recs.write({'message_type': 'email'})})
message_type = fields.Selection(
selection_add=[('sms', 'SMS')],
ondelete={'sms': lambda recs: recs.write({'message_type': 'comment'})})
has_sms_error = fields.Boolean(
'Has SMS error', compute='_compute_has_sms_error', search='_search_has_sms_error')
@ -29,26 +24,9 @@ class MailMessage(models.Model):
message.has_sms_error = message in sms_error_from_notification
def _search_has_sms_error(self, operator, operand):
if operator == '=' and operand:
return ['&', ('notification_ids.notification_status', '=', 'exception'), ('notification_ids.notification_type', '=', 'sms')]
raise NotImplementedError()
def message_format(self, format_reply=True):
""" Override in order to retrieves data about SMS (recipient name and
SMS status)
TDE FIXME: clean the overall message_format thingy
"""
message_values = super(MailMessage, self).message_format(format_reply=format_reply)
all_sms_notifications = self.env['mail.notification'].sudo().search([
('mail_message_id', 'in', [r['id'] for r in message_values]),
('notification_type', '=', 'sms')
])
msgid_to_notif = defaultdict(lambda: self.env['mail.notification'].sudo())
for notif in all_sms_notifications:
msgid_to_notif[notif.mail_message_id.id] += notif
for message in message_values:
customer_sms_data = [(notif.id, notif.res_partner_id.display_name or notif.sms_number, notif.notification_status) for notif in msgid_to_notif.get(message['id'], [])]
message['sms_ids'] = customer_sms_data
return message_values
if operator != 'in':
return NotImplemented
return [('notification_ids', 'any', [
('notification_status', '=', 'exception'),
('notification_type', '=', 'sms'),
])]