27 lines
825 B
Python
27 lines
825 B
Python
from odoo import models, fields
|
|
|
|
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)
|
|
|
|
# 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
|
|
)
|
|
|
|
def _compute_is_global(self):
|
|
for rec in self:
|
|
rec.is_global = not bool(rec.partner_ids)
|