diff options
| author | Adrian Torres <adt@odoo.com> | 2020-02-20 13:43:00 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-03-30 13:42:04 +0000 |
| commit | 1daf8eb12735db5c697e4a0868b43fe44f6b2f6a (patch) | |
| tree | b02820d3679615e7e92a6258a6cc1d428db4c526 /addons/sms | |
| parent | f0481392c6501cae2c38359f526da1eefa451337 (diff) | |
[FIX] *: set ondelete policy of required Selection fields
With this commit, Selection fields with `required=True` which are
extended via `selection_add` are given proper ondelete policies to
ensure the cleanup of records containing these extended options during
uninstall of the extending module.
This commit also cleans up leftover uninstall hooks that were being used
to handle the same set of problems prior to the ondelete mechanism being
implemented for Selection fields.
closes odoo/odoo#46325
Related: odoo/enterprise#9117
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'addons/sms')
| -rw-r--r-- | addons/sms/models/ir_actions.py | 2 | ||||
| -rw-r--r-- | addons/sms/models/mail_message.py | 4 | ||||
| -rw-r--r-- | addons/sms/models/mail_notification.py | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/addons/sms/models/ir_actions.py b/addons/sms/models/ir_actions.py index 85869761e57..e5421d4546c 100644 --- a/addons/sms/models/ir_actions.py +++ b/addons/sms/models/ir_actions.py @@ -12,7 +12,7 @@ class ServerActions(models.Model): state = fields.Selection(selection_add=[ ('sms', 'Send SMS Text Message'), - ]) + ], ondelete={'sms': 'cascade'}) # SMS sms_template_id = fields.Many2one( 'sms.template', 'SMS Template', ondelete='set null', diff --git a/addons/sms/models/mail_message.py b/addons/sms/models/mail_message.py index 10e9ffab73b..dbc0a78cd75 100644 --- a/addons/sms/models/mail_message.py +++ b/addons/sms/models/mail_message.py @@ -14,7 +14,9 @@ class MailMessage(models.Model): gateway. """ _inherit = 'mail.message' - message_type = fields.Selection(selection_add=[('sms', 'SMS')]) + message_type = fields.Selection(selection_add=[ + ('sms', 'SMS') + ], ondelete={'sms': lambda recs: recs.write({'message_type': 'email'})}) has_sms_error = fields.Boolean( 'Has SMS error', compute='_compute_has_sms_error', search='_search_has_sms_error', help='Has error') diff --git a/addons/sms/models/mail_notification.py b/addons/sms/models/mail_notification.py index c45981ea0b0..3e00399fcc3 100644 --- a/addons/sms/models/mail_notification.py +++ b/addons/sms/models/mail_notification.py @@ -7,7 +7,9 @@ from odoo.tools.translate import _ class Notification(models.Model): _inherit = 'mail.notification' - notification_type = fields.Selection(selection_add=[('sms', 'SMS')]) + notification_type = fields.Selection(selection_add=[ + ('sms', 'SMS') + ], ondelete={'sms': 'set default'}) sms_id = fields.Many2one('sms.sms', string='SMS', index=True, ondelete='set null') sms_number = fields.Char('SMS Number') failure_type = fields.Selection(selection_add=[ |
