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:
gsinghpal
2026-03-31 20:41:04 -04:00
parent 0ce599c4ac
commit 116c0b03bf
5 changed files with 201 additions and 1 deletions

View File

@@ -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()