first push message
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from odoo import models, fields, api
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class SubscriptionCron(models.Model):
|
||||
_inherit = 'user.subscription'
|
||||
|
||||
@api.model
|
||||
def check_expired_trials(self):
|
||||
"""Cron job to check and expire trials"""
|
||||
subscriptions = self.search([('state', '=', 'trial')])
|
||||
expired_count = 0
|
||||
|
||||
for sub in subscriptions:
|
||||
if sub.check_trial_expired():
|
||||
expired_count += 1
|
||||
# Send notification email
|
||||
sub.message_post(
|
||||
body='Your trial period has expired. Please subscribe to continue.',
|
||||
message_type='notification'
|
||||
)
|
||||
|
||||
return f"Checked {len(subscriptions)} subscriptions, {expired_count} expired"
|
||||
Reference in New Issue
Block a user