diff --git a/plugins/warranty/api/routes.py b/plugins/warranty/api/routes.py index 890e322..fa51ae0 100644 --- a/plugins/warranty/api/routes.py +++ b/plugins/warranty/api/routes.py @@ -286,10 +286,22 @@ def sync_dell(): existing = None for link in WarrantyAsset.query.filter_by(assetid=assetid).all(): candidate = db.session.get(Warranty, link.warrantyid) - if candidate and candidate.provider == 'dell': + # Reuse a warranty that is Dell by ANY signal, not just + # provider: a manually-added or imported Dell warranty carries + # provider 'manual' (create default) but the same service tag or + # a "Dell" vendor. Matching only provider=='dell' made re-check + # duplicate every one of those instead of updating it. + if candidate and ( + candidate.provider == 'dell' + or (candidate.servicetag or '').strip().upper() == tag + or (candidate.vendor or '').strip().lower() == 'dell'): existing = candidate break if existing: + # Canonicalize to Dell so later re-checks match by provider and + # never fall through to a duplicate. + existing.provider = 'dell' + existing.vendor = existing.vendor or 'Dell' existing.servicelevel = found.get('servicelevel') existing.startdate = _parse_date(found.get('startdate')) existing.enddate = _parse_date(found.get('enddate'))