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

@ -2,16 +2,14 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class ServerActions(models.Model):
class IrActionsServer(models.Model):
""" Add SMS option in server actions. """
_name = 'ir.actions.server'
_inherit = ['ir.actions.server']
_inherit = 'ir.actions.server'
state = fields.Selection(selection_add=[
('sms', 'Send SMS Text Message'),
('sms', 'Send SMS'), ('followers',),
], ondelete={'sms': 'cascade'})
# SMS
sms_template_id = fields.Many2one(
@ -21,11 +19,28 @@ class ServerActions(models.Model):
domain="[('model_id', '=', model_id)]",
)
sms_method = fields.Selection(
selection=[('sms', 'SMS'), ('comment', 'Post as Message'), ('note', 'Post as Note')],
string='Send as (SMS)',
selection=[('sms', 'SMS (without note)'), ('comment', 'SMS (with note)'), ('note', 'Note only')],
string='Send SMS As',
compute='_compute_sms_method',
readonly=False, store=True,
help='Choose method for SMS sending:\nSMS: mass SMS\nPost as Message: log on document\nPost as Note: mass SMS with archives')
readonly=False, store=True)
def _name_depends(self):
return [*super()._name_depends(), "sms_template_id"]
def _generate_action_name(self):
self.ensure_one()
if self.state == 'sms' and self.sms_template_id:
return _('Send %(template_name)s', template_name=self.sms_template_id.name)
return super()._generate_action_name()
@api.depends('state')
def _compute_available_model_ids(self):
mail_thread_based = self.filtered(lambda action: action.state == 'sms')
if mail_thread_based:
mail_models = self.env['ir.model'].search([('is_mail_thread', '=', True), ('transient', '=', False)])
for action in mail_thread_based:
action.available_model_ids = mail_models.ids
super(IrActionsServer, self - mail_thread_based)._compute_available_model_ids()
@api.depends('model_id', 'state')
def _compute_sms_template_id(self):
@ -45,11 +60,30 @@ class ServerActions(models.Model):
if other:
other.sms_method = 'sms'
def _check_model_coherency(self):
super()._check_model_coherency()
for action in self:
if action.state == 'sms' and (action.model_id.transient or not action.model_id.is_mail_thread):
raise ValidationError(_("Sending SMS can only be done on a not transient mail.thread model"))
@api.model
def _warning_depends(self):
return super()._warning_depends() + [
'model_id',
'state',
'sms_template_id',
]
def _get_warning_messages(self):
self.ensure_one()
warnings = super()._get_warning_messages()
if self.state == 'sms':
if self.model_id.transient or not self.model_id.is_mail_thread:
warnings.append(_("Sending SMS can only be done on a not transient mail.thread model"))
if self.sms_template_id and self.sms_template_id.model_id != self.model_id:
warnings.append(
_('SMS template model of %(action_name)s does not match action model.',
action_name=self.name
)
)
return warnings
def _run_action_sms_multi(self, eval_context=None):
# TDE CLEANME: when going to new api with server action, remove action