add new fields to rancher
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import datetime
|
||||
import random
|
||||
import string
|
||||
|
||||
from apps.authentication.models import Organization
|
||||
from apps.product.models import Product
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
from apps.authorization.models import UserRelations
|
||||
from apps.core.models import BaseModel
|
||||
@@ -55,7 +55,7 @@ class Device(BaseModel):
|
||||
|
||||
def generate_device_identity(self): # noqa
|
||||
""" generate identity for every device """
|
||||
prefix = "POS"
|
||||
# prefix = "POS"
|
||||
while True:
|
||||
number_part = ''.join(random.choices(string.digits, k=9))
|
||||
code = f"{number_part}"
|
||||
@@ -264,3 +264,32 @@ class StakeHolders(BaseModel):
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
return super(StakeHolders, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class POSFreeProducts(BaseModel):
|
||||
product = models.ForeignKey(
|
||||
Product,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='pos_free_products',
|
||||
null=True
|
||||
)
|
||||
organization = models.ForeignKey(
|
||||
Organization,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='free_products',
|
||||
null=True
|
||||
)
|
||||
device = models.ForeignKey(
|
||||
Device,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='free_products',
|
||||
null=True
|
||||
)
|
||||
balance = models.PositiveIntegerField(default=0)
|
||||
price = models.PositiveIntegerField(default=0)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.product.name}-{self.organization.name}'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
return super(POSFreeProducts, self).save(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user