Merge pull request #5340 from expsa/improve_logging

[IMP] odex_mobile: log record name & model, send notifications based …
This commit is contained in:
abdurrahman-saber 2025-11-11 16:47:34 +02:00 committed by GitHub
commit 381d21b39c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class PushNotificationMixin(models.AbstractModel):
return credentials.token return credentials.token
for rec in self: for rec in self:
if not rec.fcm_token: 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: if not self.env.user.company_id.service_account:
raise UserError(_("Firebase Service Account file is required")) 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) notification = self.env['firebase.notification'].sudo().create(notification_data)
if all_device: 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: for reg in self.firebase_registration_ids:
reg.with_context(lang=self.lang).send_message( reg.with_context(lang=self.lang).send_message(
message_title, message_title,