feat: add cron jobs, sync engine scaffolding, log cleanup, and email templates
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from odoo import fields, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class WooSyncLog(models.Model):
|
||||
@@ -28,3 +28,14 @@ class WooSyncLog(models.Model):
|
||||
company_id = fields.Many2one(
|
||||
'res.company', default=lambda self: self.env.company,
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _cron_cleanup_logs(self):
|
||||
"""Purge sync logs older than 90 days (180 for errors)."""
|
||||
cutoff_success = fields.Datetime.subtract(fields.Datetime.now(), hours=90 * 24)
|
||||
cutoff_error = fields.Datetime.subtract(fields.Datetime.now(), hours=180 * 24)
|
||||
self.search([
|
||||
'|',
|
||||
'&', ('state', '!=', 'failed'), ('create_date', '<', cutoff_success),
|
||||
'&', ('state', '=', 'failed'), ('create_date', '<', cutoff_error),
|
||||
]).unlink()
|
||||
|
||||
Reference in New Issue
Block a user