from odoo import models, fields, api class AppNotification(models.Model): _name = 'mapan.app.notification' _description = 'Mobile App Promotional Notification' _order = 'create_date desc' title = fields.Char(string='Notification Title', required=True) body = fields.Text(string='Notification Body', required=True) # Optional promotional image — Odoo auto-generates image_128 thumbnail image = fields.Image( string='Notification Image', max_width=1920, max_height=1920, help='Optional image shown in the notification detail screen.' ) image_128 = fields.Image( string='Thumbnail', related='image', max_width=128, max_height=128, store=True, readonly=True, ) # If no partner_ids are selected, it is broadcast to everyone logically partner_ids = fields.Many2many( 'res.partner', string='Selected Customers', help='Leave empty to broadcast to all app users.' ) is_global = fields.Boolean( string='Broadcast to All?', compute='_compute_is_global', store=True ) @api.depends('partner_ids') def _compute_is_global(self): for rec in self: rec.is_global = not bool(rec.partner_ids)