from django.conf import settings from django.db import models from fwApp.models import FW002HModel class ApprovalBaseModel(models.Model): fw_list = models.ForeignKey(FW002HModel, null=True, blank=True, to_field='fw_list', on_delete=models.PROTECT, related_name='%(class)s_fw_list', verbose_name="審批單號") status = models.BooleanField(default=0, verbose_name='是否核准') rgs_user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=True, blank=True, to_field='username', related_name='%(class)s_rgs_user', verbose_name='稽核賬號') rgs_time = models.DateTimeField(null=True, editable=False, blank=True, verbose_name="稽核時間") class Meta:
abstract = True
from django.utils.timezone import now
class AuditBaseModel(models.Model):
created_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=True, blank=True,
to_field='username', related_name='%(class)s_created_by', verbose_name='建立賬號')
created_at = models.DateTimeField(auto_now_add=True, verbose_name="建立時間")
updated_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=True, blank=True,
to_field='username', related_name='%(class)s_updated_by', verbose_name='更新賬號')
updated_at = models.DateTimeField(auto_now=True, verbose_name="更新時間")
class Meta:
abstract = True
class CU005HModel(ApprovalBaseModel, AuditBaseModel): """ 銷售訂單特結單表頭 Close 尚未出貨或者部分出貨時,終結此筆單據,出多少算多少 """ cl_no = models.CharField(unique=True, max_length=20, editable=False, verbose_name="銷售訂單特結單號") cl_date = models.DateField(default=date.today, editable=False, verbose_name="特結日期") fa_no = models.ForeignKey(BS001HModel, on_delete=models.PROTECT, related_name='cu005h_fa_no', to_field='fa_no', verbose_name="廠別") cu_no = models.ForeignKey(CU001HModel, on_delete=models.PROTECT, related_name='cu005h_cu_no', to_field='cu_no', verbose_name="客戶") pa_no = models.ForeignKey(PA003HModel, on_delete=models.PROTECT, related_name='cu005h_pa_no', to_field='pa_no', verbose_name="經辦人") reason = models.CharField(null=True, blank=True, max_length=100, verbose_name="特結原因") confirm = models.BooleanField(default=False, verbose_name="是否確認") rgc_user = models.CharField(max_length=20, editable=False, null=True, blank=True, verbose_name="確認賬號") rgc_time = models.DateTimeField(null=True, editable=False, blank=True, verbose_name="確認時間") class Meta: db_table = 'cu005h' verbose_name = '銷售訂單特結單表頭' verbose_name_plural = verbose_name