Add support for importing product unit cost
This commit is contained in:
parent
86bc7da798
commit
a36f6bdc94
|
@ -1105,6 +1105,7 @@ class ProductImporter(ToRattail):
|
||||||
'vendor_id',
|
'vendor_id',
|
||||||
'vendor_item_code',
|
'vendor_item_code',
|
||||||
'vendor_case_cost',
|
'vendor_case_cost',
|
||||||
|
'vendor_unit_cost',
|
||||||
]
|
]
|
||||||
|
|
||||||
extension_attr = None
|
extension_attr = None
|
||||||
|
@ -1262,6 +1263,8 @@ class ProductImporter(ToRattail):
|
||||||
data['vendor_item_code'] = cost.code if cost else None
|
data['vendor_item_code'] = cost.code if cost else None
|
||||||
if 'vendor_case_cost' in self.fields:
|
if 'vendor_case_cost' in self.fields:
|
||||||
data['vendor_case_cost'] = cost.case_cost if cost else None
|
data['vendor_case_cost'] = cost.case_cost if cost else None
|
||||||
|
if 'vendor_unit_cost' in self.fields:
|
||||||
|
data['vendor_unit_cost'] = cost.unit_cost if cost else None
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -1579,6 +1582,14 @@ class ProductImporter(ToRattail):
|
||||||
else:
|
else:
|
||||||
log.warning("product has no cost, so can't set vendor_case_cost: {}".format(product))
|
log.warning("product has no cost, so can't set vendor_case_cost: {}".format(product))
|
||||||
|
|
||||||
|
if 'vendor_unit_cost' in self.fields:
|
||||||
|
cost = data['vendor_unit_cost']
|
||||||
|
if data.get('vendor_id'):
|
||||||
|
if product.cost:
|
||||||
|
product.cost.unit_cost = cost
|
||||||
|
else:
|
||||||
|
log.warning("product has no cost, so can't set vendor_case_cost: {}".format(product))
|
||||||
|
|
||||||
return product
|
return product
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue