diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-05-31 09:46:00 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-05-31 09:46:00 +0700 |
| commit | 479924f6dbabb55f777194f80cf278a909452e95 (patch) | |
| tree | baef6d830c05197642ef3743e748a4426f9b36a7 /fixco_custom | |
| parent | acd06377bb5c4b375fadf3ad37a7ad5853ed79b3 (diff) | |
push
Diffstat (limited to 'fixco_custom')
| -rwxr-xr-x | fixco_custom/models/detail_order.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py index 04e8256..5c61e75 100755 --- a/fixco_custom/models/detail_order.py +++ b/fixco_custom/models/detail_order.py @@ -122,10 +122,22 @@ class DetailOrder(models.Model): raise UserError(_("Error extracting order ID: %s") % str(e)) def process_queue_item_detail(self, limit=100): - domain = [('execute_status', '=', 'detail_order')] - records = self.search(domain, order='create_date asc', limit=limit) - for rec in records: - rec.execute_queue_detail() + domain = [ + ('execute_status', '=', 'detail_order'), + ('detail_order', 'not like', '"orderStatus": "PENDING_PAYMENT"') + ] + records = self.search(domain, order='create_date desc', limit=limit) + + for i, rec in enumerate(records, 1): + try: + rec.execute_queue_detail() + if i % 10 == 0: + self.env.cr.commit() + except Exception as e: + _logger.error("Failed to process record %s: %s", rec.id, str(e)) + self.env.cr.rollback() + + self.env.cr.commit() def prepare_data_so(self, json_data): data = { |
