From 1f3ab43e9152811135feec2cd2c4893b362be401 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 8 Jan 2022 19:51:31 -0600 Subject: [PATCH] Avoid error if CORE product data is missing some fields --- rattail_corepos/importing/corepos/api.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rattail_corepos/importing/corepos/api.py b/rattail_corepos/importing/corepos/api.py index f84fb8e..003fbb9 100644 --- a/rattail_corepos/importing/corepos/api.py +++ b/rattail_corepos/importing/corepos/api.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2021 Lance Edgar +# Copyright © 2010-2022 Lance Edgar # # This file is part of Rattail. # @@ -574,8 +574,8 @@ class ProductImporter(FromCOREPOSAPI, corepos_importing.model.ProductImporter): 'department_number': department_number, 'subdepartment_number': subdepartment_number, - 'weighed': product['scale'] == '1', - 'food_stampable': product['foodstamp'] == '1', + 'weighed': product.get('scale') == '1', + 'food_stampable': None, # 'tax1': product['tax'] == '1', # TODO: is this right? # 'tax2': product['tax'] == '2', # TODO: is this right? @@ -584,6 +584,9 @@ class ProductImporter(FromCOREPOSAPI, corepos_importing.model.ProductImporter): 'regular_price_type': self.enum.PRICE_TYPE_REGULAR if price is not None else None, } + if 'foodstamp' in product: + data['food_stampable'] = product['foodstamp'] == '1' + if self.fields_active(self.size_fields): size_info = self.normalize_size_info(product) data.update({