fix: exclude off-shelf products from dispatch calendar options.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-10-29 16:58:12 +08:00
1 parent 677f1b4c5a
commit 13570a2aee
5 files changed
+18045 -21641

No files matched your search

@@ -139,6 +139,22 @@ def test_options_full_library_types_search_pagination(db):
assert svc.list_products(db, 't1', user(), q='%')['total'] == 0
def test_off_shelf_products_excluded_from_options_and_create(db):
_, _, _, svc = modules()
db.add(CrmProduct(id='p-off', product_no='POFF', product_name='下架液碱',
tenant_no='t1', create_by='u1', status='off'))
db.commit()
ids = {row['id'] for row in svc.list_products(db, 't1', user())['list']}
assert 'p-off' not in ids
assert 'p1' in ids and 'p2' in ids
assert svc.list_products(db, 't1', user(), q='下架')['total'] == 0
with pytest.raises(HTTPException) as exc:
create(db, productId='p-off')
assert exc.value.status_code == 422
assert '下架' in exc.value.detail
assert svc.list_records(db, 't1', user(), month='2026-10')['total'] == 0
@pytest.mark.parametrize('field,value', [('vehicleId', 'v3'), ('vehicleId', 'v4'), ('vehicleId', 'missing'), ('productId', 'p3'), ('productId', 'p4'), ('productId', 'missing')])
def test_invalid_cross_tenant_and_deleted_relations_rejected(db, field, value):
_, _, _, svc = modules()