[IMP] odex_mobile: log record name & model, send notifications based on employee

This commit is contained in:
Abdurrahman Saber 2025-11-11 16:46:48 +02:00
parent c7481fa464
commit 435c8ee0dd
2 changed files with 4 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class PushNotificationMixin(models.AbstractModel):
return credentials.token
for rec in self:
if not rec.fcm_token:
raise UserError(_("FCM Token is required"))
raise UserError(_("FCM Token is required for record %s:%s") % (rec._name, rec.name))
if not self.env.user.company_id.service_account:
raise UserError(_("Firebase Service Account file is required"))

View File

@ -25,7 +25,9 @@ class Partner(models.Model):
notification = self.env['firebase.notification'].sudo().create(notification_data)
if all_device:
notification.partner_ids.send_push_notification(str(message_title), str(message_body))
emp = self.env['hr.employee'].sudo().search([('user_id', 'in', notification.partner_ids.user_ids.ids)])
if emp.user_id.partner_id:
emp.send_push_notification(str(message_title), str(message_body))
for reg in self.firebase_registration_ids:
reg.with_context(lang=self.lang).send_message(
message_title,