HimoolERP/extensions/models.py

28 lines
1.2 KiB
Python
Raw Normal View History

2021-11-04 17:35:34 +08:00
from django.db.models import CharField, DateField, DateTimeField, JSONField, FileField, ImageField
from django.db.models import BooleanField, IntegerField, FloatField, DecimalField
2021-12-26 23:00:08 +08:00
from django.db.models import Sum, Count, Min, Avg, Max, Value, F, Q, Prefetch
2021-11-04 17:35:34 +08:00
from django.db.models.deletion import CASCADE, SET_NULL, SET_DEFAULT, PROTECT
from django.db.models import OneToOneField, ForeignKey, ManyToManyField
from django.db.models import Model, IntegerChoices, TextChoices
from django.db.models.functions import Coalesce
2021-12-12 15:44:39 +08:00
from django.db import connection
2021-11-04 17:35:34 +08:00
class AmountField(DecimalField):
"""金额字段"""
def __init__(self, verbose_name=None, name=None, **kwargs):
kwargs['max_digits'], kwargs['decimal_places'] = 16, 2
super().__init__(verbose_name, name, **kwargs)
__all__ = [
2021-11-08 17:27:57 +08:00
'Model', 'IntegerChoices', 'TextChoices',
2021-11-04 17:35:34 +08:00
'CASCADE', 'SET_NULL', 'SET_DEFAULT', 'PROTECT',
'OneToOneField', 'ForeignKey', 'ManyToManyField',
2021-12-12 15:44:39 +08:00
'BooleanField', 'IntegerField', 'FloatField', 'AmountField',
2021-11-04 17:35:34 +08:00
'CharField', 'DateField', 'DateTimeField', 'JSONField', 'FileField', 'ImageField',
2021-12-26 23:00:08 +08:00
'Sum', 'Count', 'Min', 'Avg', 'Max', 'Value',
'F', 'Q', 'Prefetch', 'Coalesce', 'connection',
2021-11-04 17:35:34 +08:00
]