change bug of permissions list
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from django.db import models
|
||||
from apps.core.models import BaseModel
|
||||
from apps.authorization.models import UserRelations
|
||||
|
||||
|
||||
# Create your models here.
|
||||
@@ -56,8 +57,13 @@ class Attribute(BaseModel):
|
||||
null=True
|
||||
)
|
||||
name = models.CharField(max_length=100, default='empty')
|
||||
type_choices = (
|
||||
('K', 'Per Kilo'),
|
||||
('', ''),
|
||||
)
|
||||
type = models.CharField(
|
||||
max_length=255,
|
||||
max_length=10,
|
||||
choices=type_choices,
|
||||
default='empty',
|
||||
help_text='type of attribute like: calculate product by kilogram'
|
||||
)
|
||||
@@ -83,7 +89,8 @@ class AttributeValue(BaseModel):
|
||||
attribute = models.ForeignKey(
|
||||
Attribute,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='attribute_value'
|
||||
related_name='attribute_value',
|
||||
null=True
|
||||
)
|
||||
value = models.IntegerField(default=0)
|
||||
|
||||
@@ -94,16 +101,56 @@ class AttributeValue(BaseModel):
|
||||
return super(AttributeValue, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class Broker(BaseModel):
|
||||
""" Broker for product """
|
||||
|
||||
reference_product = models.ForeignKey(
|
||||
ReferenceProduct,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='product_broker',
|
||||
null=True
|
||||
)
|
||||
organization_relations = models.ForeignKey(
|
||||
UserRelations,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='product_organization',
|
||||
null=True
|
||||
)
|
||||
calculation_choices = (
|
||||
('K', 'Per Kilo'),
|
||||
('', ''),
|
||||
)
|
||||
calculation_strategy = models.CharField(
|
||||
max_length=3,
|
||||
choices=calculation_choices,
|
||||
default='empty'
|
||||
)
|
||||
required = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.organization_relations.organization.name} - {self.reference_product.name}'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
return super(Broker, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class SaleUnit(BaseModel):
|
||||
product = models.ForeignKey(
|
||||
""" Units of product for sale """
|
||||
|
||||
reference_product = models.ForeignKey(
|
||||
ReferenceProduct,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='sale_unit',
|
||||
null=True
|
||||
)
|
||||
unit = models.CharField(max_length=255, null=True)
|
||||
variation_coefficient = models.CharField(max_length=255, null=True)
|
||||
unit_choices = (
|
||||
('10P', '10KG Package'),
|
||||
('50P', '50KG Package'),
|
||||
('', ''),
|
||||
)
|
||||
unit = models.CharField(max_length=10, choices=unit_choices, null=True)
|
||||
variation_coefficient = models.IntegerField(default=0)
|
||||
required = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.product} - {self.unit} - {self.variation_coefficient}'
|
||||
return f'{self.reference_product} - {self.unit} - {self.variation_coefficient}'
|
||||
|
||||
Reference in New Issue
Block a user