Fix 'size' and push 'unitofmeasure' when exporting to CORE Products

This commit is contained in:
Lance Edgar 2021-01-21 18:16:56 -06:00
parent ca14884c46
commit 59abc4995e

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -31,7 +31,7 @@ from sqlalchemy import orm
from rattail import importing from rattail import importing
from rattail.db import model from rattail.db import model
from rattail.db.util import short_session from rattail.db.util import short_session
from rattail.util import OrderedDict from rattail.util import OrderedDict, pretty_quantity
from rattail_corepos.corepos import importing as corepos_importing from rattail_corepos.corepos import importing as corepos_importing
from rattail_corepos.corepos.util import get_max_existing_vendor_id from rattail_corepos.corepos.util import get_max_existing_vendor_id
@ -280,6 +280,7 @@ class ProductImporter(FromRattail, corepos_importing.model.ProductImporter):
'brand', 'brand',
'description', 'description',
'size', 'size',
'unitofmeasure',
'department', 'department',
'normal_price', 'normal_price',
'foodstamp', 'foodstamp',
@ -300,7 +301,8 @@ class ProductImporter(FromRattail, corepos_importing.model.ProductImporter):
'upc': upc, 'upc': upc,
'brand': product.brand.name if product.brand else '', 'brand': product.brand.name if product.brand else '',
'description': product.description or '', 'description': product.description or '',
'size': product.size or '', 'size': pretty_quantity(product.unit_size),
'unitofmeasure': product.uom_abbreviation,
'department': str(product.department.number) if product.department else None, 'department': str(product.department.number) if product.department else None,
'normal_price': '{:0.2f}'.format(product.regular_price.price) if product.regular_price else None, 'normal_price': '{:0.2f}'.format(product.regular_price.price) if product.regular_price else None,
'foodstamp': '1' if product.food_stampable else '0', 'foodstamp': '1' if product.food_stampable else '0',