From 26a5e02c517e5c0775a836b2657f30334656b439 Mon Sep 17 00:00:00 2001 From: AbleKSaju <126228406+AbleKSaju@users.noreply.github.com> Date: Thu, 2 Jan 2025 13:06:22 +0530 Subject: [PATCH] fix: prevent adding items via barcode if not tracked in inventory --- src/components/Controls/WeightEnabledBarcode.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/Controls/WeightEnabledBarcode.vue b/src/components/Controls/WeightEnabledBarcode.vue index 7ef3a69c..7bde8d46 100644 --- a/src/components/Controls/WeightEnabledBarcode.vue +++ b/src/components/Controls/WeightEnabledBarcode.vue @@ -92,11 +92,19 @@ export default defineComponent({ barcode: barcode.slice(checkDigits, checkDigits + itemCodeDigits), } : { barcode }; - const fields = isWeightEnabled ? ['name', 'unit'] : ['name']; + const fields = isWeightEnabled + ? ['name', 'unit', 'trackItem'] + : ['name', 'trackItem']; const items = (await this.fyo.db.getAll('Item', { filters, fields })) || []; - const { name, unit } = items[0] || {}; + const { name, unit, trackItem } = items[0] || {}; + + if (!trackItem) { + return this.error( + this.t`Item ${name as string} is not an Inventory Item.` + ); + } if (!name) { return this.error(this.t`Item with barcode ${barcode} not found.`);