feat: add communication history push, invoice auto-trigger, health checks, rate limiting
- Override account.move action_post to auto-push invoice PDF to WC on posting - Add _cron_health_check to ping all instances and flag unreachable ones - Add health check cron record (every 10 minutes) to data/cron.xml - Add IP-based rate limiting (100 req/min) to webhook controller - Fill in API endpoints: order/documents, order/status, order/messages with real data from woo.order, stock.picking, and mail.message - Implement return/create API endpoint with product mapping and line creation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import logging
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
@@ -10,3 +14,15 @@ class AccountMove(models.Model):
|
||||
def _compute_is_woo_invoice(self):
|
||||
for move in self:
|
||||
move.is_woo_invoice = bool(move.woo_order_id)
|
||||
|
||||
def action_post(self):
|
||||
"""Override to auto-push invoice PDF to WooCommerce on posting."""
|
||||
res = super().action_post()
|
||||
for move in self:
|
||||
if move.woo_order_id and not move.woo_order_id.invoice_synced:
|
||||
try:
|
||||
move.woo_order_id.action_push_invoice_pdf()
|
||||
move.woo_order_id.invoice_synced = True
|
||||
except Exception as e:
|
||||
_logger.error("Failed to push invoice PDF to WC: %s", e)
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user