From d7bcaf99172fab48b2cedf49d5329571d7667a58 Mon Sep 17 00:00:00 2001 From: Westech Admin Date: Sun, 17 May 2026 14:55:54 +0000 Subject: [PATCH] fix: use Item.brand for eBay pricing match --- .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 188 bytes westech_r2/__pycache__/hooks.cpython-312.pyc | Bin 0 -> 769 bytes westech_r2/api/ebay_pricing.py | 35 ++++++++---------- 3 files changed, 15 insertions(+), 20 deletions(-) create mode 100644 westech_r2/__pycache__/__init__.cpython-312.pyc create mode 100644 westech_r2/__pycache__/hooks.cpython-312.pyc diff --git a/westech_r2/__pycache__/__init__.cpython-312.pyc b/westech_r2/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0b2fbe3d184f24793d3a5fa0ea62ab65216276c5 GIT binary patch literal 188 zcmX@j%ge<81UtWSWQhUk#~=<2FhUuhIe?7m3@Hpz43&(UOjWD~dIoxiewvK8xZ~r? zQj3Z+^Yh~4S2BDCssH7upOK%Ns-ISrSWu9vpITIqms(Mxo0OWDoS_dCD%LMgEiOq- z&WJBELT1LtXXa&=#K-FuRQ}?y$<0qG%}KQ@Vgs58az-)8l^>WH85wWzi8gWiRM D@hu)iSHOu;0iq)zw z$@No1K3c?zEMiACsYNy7L=LG(b+Q(%U09^?#f}=Jd0|IQ;u4SA2K@?K2HT&V$ejhf zj`rVyRDj2^80P-ymWRhf-CXkg@$oP`6$npgauJ?$5&kU#Ji`ox)RuN$JwNT$b@Lg= zr?V9D_CY2UpN5AN7|DYJMj=t*2^KU}+8c2(ktxEUn;_Bzu9R+_ftd}lM3;~c@6OaG z94j-ipCZOUtzKD5kTTUEC}MHKWxjt;kHljj83Pih6i>3W|NjS2v7(AWzI#tUOjETj0$rtvoE!8B8uVC1T4Q=*X0j# zvp*Q~DGbhqDS*K;pMj--`Fd<^LEF`&V!=$yRp`;74Bl)+IaM#RRjy)@-}~Ly;wN4Ze!tA XVr0b5N*o#yG=6pcPVK!fHjT?43NZo% literal 0 HcmV?d00001 diff --git a/westech_r2/api/ebay_pricing.py b/westech_r2/api/ebay_pricing.py index cdbd0f1..218136d 100644 --- a/westech_r2/api/ebay_pricing.py +++ b/westech_r2/api/ebay_pricing.py @@ -326,32 +326,25 @@ def _upsert_system_pricing(manufacturer, model, pricing): def _update_item_market_data(manufacturer, model, pricing): + clean_mfr = clean_manufacturer(manufacturer) + model_lower = model.lower() + + # Match by brand (exact) + item_name (contains model) items = frappe.get_all( "Item", filters={ "item_group": ["in", ["Laptop", "Desktop", "Tablet", "Phone", "Workstation"]], "disabled": 0, + "brand": clean_mfr, }, - fields=["name", "item_name", "brand"], + fields=["name", "item_name"], ) - clean_mfr = clean_manufacturer(manufacturer).lower() - model_lower = model.lower() matched = None for item in items: item_name_lower = (item.item_name or "").lower() - brand_lower = (item.brand or "").lower() if model_lower in item_name_lower: - if clean_mfr in brand_lower or brand_lower in clean_mfr or clean_mfr in item_name_lower: - matched = item.name - break - elif matched is None: - matched = item.name - if not matched: - for item in items: - item_name_lower = (item.item_name or "").lower() - if model_lower in item_name_lower: - matched = item.name - break + matched = item.name + break if not matched: return item_doc = frappe.get_doc("Item", matched) @@ -387,13 +380,15 @@ def _log_api_call(manufacturer, model, search_query, source, results_count, stat def run_batch(batch_size=10, source="auto", force=False): batch_size = int(batch_size) if batch_size != "all" else 999999 force = bool(force) + # Get unique models from Items that have serials models = frappe.db.sql( """ - SELECT DISTINCT manufacturer, model - FROM `tabSerial No` - WHERE manufacturer IS NOT NULL AND manufacturer != '' - AND model IS NOT NULL AND model != '' - ORDER BY creation DESC + SELECT DISTINCT i.brand as manufacturer, i.item_name as model + FROM `tabItem` i + INNER JOIN `tabSerial No` sn ON sn.item_code = i.name + WHERE i.brand IS NOT NULL AND i.brand != '' + AND i.disabled = 0 + ORDER BY i.modified DESC LIMIT %s """, (batch_size,),