diff --git a/corepos/api.py b/corepos/api.py index 3a8b624..b6ee1ed 100644 --- a/corepos/api.py +++ b/corepos/api.py @@ -2,7 +2,7 @@ ################################################################################ # # pyCOREPOS -- Python Interface to CORE POS -# Copyright © 2018-2020 Lance Edgar +# Copyright © 2018-2021 Lance Edgar # # This file is part of pyCOREPOS. # @@ -487,3 +487,26 @@ class CoreWebAPI(object): if len(result) > 1: log.warning("CORE API returned %s VendorItem results", len(result)) return json.loads(result[0]) + + def set_vendor_item(self, sku, vendorID, **columns): + """ + Update an existing VendorItem record in CORE. + + :returns: Boolean indicating success of the operation. + + .. note:: + Currently this is being used to create a *new* product also. CORE's + ``vendorItems`` table does not use auto-increment for its PK, which + means we must provide one even when creating; therefore this method + may be used for that. + """ + columns['sku'] = sku + columns['vendorID'] = vendorID + params = { + 'entity': 'VendorItems', + 'submethod': 'set', + 'columns': columns, + } + response = self.post(params) + result = self.parse_response(response) + return json.loads(result)