diff --git a/netsuitesdk/api/items.py b/netsuitesdk/api/items.py new file mode 100644 index 0000000..04f2b7e --- /dev/null +++ b/netsuitesdk/api/items.py @@ -0,0 +1,24 @@ +from .base import ApiBase +from netsuitesdk.internal.utils import PaginatedSearch +import logging + +logger = logging.getLogger(__name__) + +class Items(ApiBase): + + def __init__(self, ns_client): + ApiBase.__init__(self, ns_client=ns_client, type_name='Item') + + def get_all_generator(self, is_inactive=False): + # Get Only Active Items using SearchBooleanField + record_type_search_field = self.ns_client.SearchBooleanField(searchValue=is_inactive) + basic_search = self.ns_client.basic_search_factory('Item', isInactive=record_type_search_field) + + paginated_search = PaginatedSearch( + client=self.ns_client, + type_name='Item', + basic_search=basic_search, + pageSize=20 + ) + + return self._paginated_search_generator(paginated_search=paginated_search) diff --git a/netsuitesdk/connection.py b/netsuitesdk/connection.py index 9f2189e..6ba3d97 100644 --- a/netsuitesdk/connection.py +++ b/netsuitesdk/connection.py @@ -29,6 +29,7 @@ from .api.tax_items import TaxItems from .api.tax_groups import TaxGroups from .api.price_level import PriceLevel +from .api.items import Items from .internal.client import NetSuiteClient @@ -77,3 +78,4 @@ def __init__(self, account, consumer_key, consumer_secret, token_key, token_secr self.credit_memos = CreditMemos(ns_client) self.price_level = PriceLevel(ns_client) self.usages = Usage(ns_client) + self.items = Items(ns_client) diff --git a/netsuitesdk/internal/netsuite_types.py b/netsuitesdk/internal/netsuite_types.py index bb27c73..57322c8 100644 --- a/netsuitesdk/internal/netsuite_types.py +++ b/netsuitesdk/internal/netsuite_types.py @@ -20,6 +20,7 @@ 'SearchMultiSelectField', 'SearchDateField', 'SearchLongField', + 'SearchBooleanField', 'Status', 'StatusDetail', 'TokenPassport', diff --git a/setup.py b/setup.py index 7164bdd..afaf535 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='netsuitesdk', - version='2.16.6', + version='2.17.0', author='Siva Narayanan', author_email='siva@fyle.in', description='Python SDK for accessing the NetSuite SOAP webservice', diff --git a/test/integration/test_items.py b/test/integration/test_items.py new file mode 100644 index 0000000..885a4f4 --- /dev/null +++ b/test/integration/test_items.py @@ -0,0 +1,9 @@ +import logging +import pytest + +logger = logging.getLogger(__name__) + +def test_get(nc): + data = nc.items.get_all() + logger.debug('data = %s', data) + assert data, 'get all didnt work' diff --git a/test/internal/test_upsert.py b/test/internal/test_upsert.py index 0ba4c7a..effe6ef 100644 --- a/test/internal/test_upsert.py +++ b/test/internal/test_upsert.py @@ -29,7 +29,7 @@ def get_currency(ns): return ns.get(recordType='currency', internalId='1') def get_employee(ns): - return ns.get(recordType='employee', internalId='1648') + return ns.get(recordType='employee', internalId='3482') def test_upsert_vendor_bill(ns): vendor_ref = ns.RecordRef(type='vendor', internalId=get_vendor(ns).internalId) @@ -121,7 +121,7 @@ def test_upsert_journal_entry(ns): def test_upsert_expense_report(ns): employee_ref = ns.RecordRef(type='employee', internalId=get_employee(ns).internalId) bill_account_ref = ns.RecordRef(type='account', internalId=25) - cat_account_ref = ns.RecordRef(type='account', internalId='1') + cat_account_ref = ns.RecordRef(type='account', internalId='3') loc_ref = ns.RecordRef(type='location', internalId=get_location(ns).internalId) dep_ref = ns.RecordRef(type='department', internalId=get_department(ns).internalId) class_ref = ns.RecordRef(type='classification', internalId=get_department(ns).internalId)