Fix how "current" price is set for Product importer
This commit is contained in:
parent
ee970bde95
commit
c8a0519c9f
|
@ -1860,7 +1860,8 @@ class ProductImporter(ToRattail):
|
|||
delete = False
|
||||
if self.fields_active(self.tpr_price_fields):
|
||||
delete = True
|
||||
create = any([data.get(f) is not None for f in self.tpr_price_fields])
|
||||
true_fields = set(self.tpr_price_fields) - set(['tpr_price_current'])
|
||||
create = any([data.get(f) is not None for f in true_fields])
|
||||
if create:
|
||||
price = product.tpr_price
|
||||
if not price:
|
||||
|
@ -1888,13 +1889,16 @@ class ProductImporter(ToRattail):
|
|||
if data['tpr_price_current'] and product.current_price is not price:
|
||||
product.current_price = price
|
||||
elif delete and product.tpr_price:
|
||||
if product.current_price is product.tpr_price:
|
||||
product.current_price = None
|
||||
product.tpr_price = None
|
||||
|
||||
create = False
|
||||
delete = False
|
||||
if self.fields_active(self.sale_price_fields):
|
||||
delete = True
|
||||
create = any([data.get(f) is not None for f in self.sale_price_fields])
|
||||
true_fields = set(self.sale_price_fields) - set(['sale_price_current'])
|
||||
create = any([data.get(f) is not None for f in true_fields])
|
||||
if create:
|
||||
price = product.sale_price
|
||||
if not price:
|
||||
|
@ -1922,6 +1926,8 @@ class ProductImporter(ToRattail):
|
|||
if data['sale_price_current'] and product.current_price is not price:
|
||||
product.current_price = price
|
||||
elif delete and product.sale_price:
|
||||
if product.current_price is product.sale_price:
|
||||
product.current_price = None
|
||||
product.sale_price = None
|
||||
|
||||
if 'vendor_id' in self.fields:
|
||||
|
|
Loading…
Reference in a new issue