forked from erp-dev/erp
feat: added n-to-1 relation between sales_order_item and printing_job model
This commit is contained in:
@@ -226,6 +226,18 @@ def pick_product(fields: dict) -> Product:
|
||||
从字段字典中提取产品信息
|
||||
"""
|
||||
data = {k: fields.get(v, '') for k, v in product_type_map.items()}
|
||||
|
||||
def _to_int(value):
|
||||
if value in ('', None):
|
||||
return None
|
||||
try:
|
||||
return int(value)
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
data['pieces'] = _to_int(data.get('pieces'))
|
||||
data['segment_size'] = _to_int(data.get('segment_size'))
|
||||
|
||||
return Product(**data)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user