修复出库时候找不到名称等问题
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
# app/models/inbound/semi.py
|
||||
from app.extensions import db
|
||||
import json
|
||||
|
||||
from app.models.base import MaterialBase
|
||||
|
||||
class StockSemi(db.Model):
|
||||
"""
|
||||
@ -55,8 +55,8 @@ class StockSemi(db.Model):
|
||||
# [新增] 全局打印流水号
|
||||
global_print_id = db.Column(db.Integer)
|
||||
|
||||
# 关系定义
|
||||
material = db.relationship('MaterialBase', back_populates='stock_semis')
|
||||
# 关系定义 [已修改]
|
||||
base = db.relationship('MaterialBase', back_populates='stock_semis')
|
||||
|
||||
def to_dict(self):
|
||||
raw_val = float(self.raw_material_cost or 0)
|
||||
@ -78,11 +78,12 @@ class StockSemi(db.Model):
|
||||
return {
|
||||
'id': self.id,
|
||||
'base_id': self.base_id,
|
||||
'material_name': self.material.name if self.material else '',
|
||||
'spec_model': self.material.spec_model if self.material else '',
|
||||
'category': self.material.category if self.material else '',
|
||||
'unit': self.material.unit if self.material else '',
|
||||
'material_type': self.material.material_type if self.material else '',
|
||||
# [已修改] 使用 self.base
|
||||
'material_name': self.base.name if self.base else '',
|
||||
'spec_model': self.base.spec_model if self.base else '',
|
||||
'category': self.base.category if self.base else '',
|
||||
'unit': self.base.unit if self.base else '',
|
||||
'material_type': self.base.material_type if self.base else '',
|
||||
|
||||
'sku': self.sku,
|
||||
'inbound_date': self.production_date.strftime('%Y-%m-%d') if self.production_date else '',
|
||||
|
||||
Reference in New Issue
Block a user