55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
from django.db import models
|
|
from django.db.models.base import Model
|
|
import django.utils.timezone as timezone
|
|
from django.db.models.query import QuerySet
|
|
from apps.system.models import CommonAModel, CommonBModel, Organization, User, Dict, File
|
|
from utils.model import SoftModel, BaseModel
|
|
from simple_history.models import HistoricalRecords
|
|
from apps.mtm.models import Material, Step, RecordForm
|
|
|
|
class Product(CommonAModel):
|
|
"""
|
|
产品(所有生产过程中出现过的)
|
|
"""
|
|
act_state_choices=(
|
|
(0, '待执行'),
|
|
(1, '进行中'),
|
|
(2, '已完成')
|
|
)
|
|
number = models.CharField('物品编号', primary_key=True, null=True, blank=True, max_length=50)
|
|
m_state = models.ForeignKey(Material, verbose_name='所属物料状态', on_delete=models.CASCADE)
|
|
p_state = models.ForeignKey(Step, verbose_name='所在步骤', on_delete=models.CASCADE, null=True, blank=True)
|
|
act_state = models.IntegerField('进行状态', default=0)
|
|
remark = models.CharField('备注', max_length=200, null=True, blank=True)
|
|
|
|
class ProductForm(CommonAModel):
|
|
"""
|
|
记录表格
|
|
"""
|
|
record_form = models.ForeignKey(RecordForm, verbose_name='所用表格', on_delete=models.CASCADE)
|
|
data = models.JSONField('记录的数据', default=dict, blank=True)
|
|
|
|
|
|
class ProductFlow(BaseModel):
|
|
"""
|
|
产品流转日志
|
|
"""
|
|
product = models.ForeignKey(Product, verbose_name='产品', on_delete=models.CASCADE)
|
|
|
|
|
|
class Vendor(CommonAModel):
|
|
"""
|
|
供应商信息
|
|
"""
|
|
name = models.CharField('供应商名称', max_length=50, unique=True)
|
|
contact = models.CharField('联系人', max_length=20)
|
|
contact_phone = models.CharField('联系电话', max_length=11, unique=True)
|
|
address = models.CharField('地址', max_length=200, null=True, blank=True)
|
|
description = models.CharField('描述', max_length=200, blank=True, null=True)
|
|
material = models.CharField('供应的物料', max_length=200, blank=True, null=True)
|
|
class Meta:
|
|
verbose_name = '供应商信息'
|
|
verbose_name_plural = verbose_name
|
|
|
|
def __str__(self):
|
|
return self.name |