diff --git a/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js b/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js index 9d146cec..ef8d5da1 100644 --- a/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js +++ b/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js @@ -14,11 +14,16 @@ export default { required: 1, getFilters(_, doc) { let items = doc.parentdoc.items.map((d) => d.item).filter(Boolean); - if (items.length > 0) { - return { - name: ['not in', items], - }; + + const baseFilter = { for: ['not in', ['sales']] }; + if (items.length <= 0) { + return baseFilter; } + + return { + name: ['not in', items], + ...baseFilter, + }; }, }, { diff --git a/models/doctype/SalesInvoiceItem/SalesInvoiceItem.js b/models/doctype/SalesInvoiceItem/SalesInvoiceItem.js index 0cc16535..bc548f9d 100644 --- a/models/doctype/SalesInvoiceItem/SalesInvoiceItem.js +++ b/models/doctype/SalesInvoiceItem/SalesInvoiceItem.js @@ -15,11 +15,16 @@ export default { required: 1, getFilters(_, doc) { let items = doc.parentdoc.items.map((d) => d.item).filter(Boolean); - if (items.length > 0) { - return { - name: ['not in', items], - }; + + const baseFilter = { for: ['not in', ['purchases']] }; + if (items.length <= 0) { + return baseFilter; } + + return { + name: ['not in', items], + ...baseFilter, + }; }, }, {