str for detail product
This commit is contained in:
@@ -4,6 +4,7 @@ from account.models import User
|
||||
from django.urls import reverse
|
||||
import requests
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
class MainCategoryModel(models.Model):
|
||||
name = models.CharField(max_length=50, verbose_name='نام دسته بندی')
|
||||
@@ -218,8 +219,8 @@ class ProductDetailModel(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'جزیات محصول'
|
||||
verbose_name_plural = 'جزیات محصول ها'
|
||||
# def __str__(self):
|
||||
# return f'جزيیات محصول {self.product}'
|
||||
def __str__(self):
|
||||
return f'جزيیات محصول {self.detail_category.title} - {self.detail.title}'
|
||||
|
||||
class ProductVariant(models.Model):
|
||||
product = models.ForeignKey(ProductModel, on_delete=models.CASCADE, related_name='variants', verbose_name='محصول')
|
||||
@@ -272,21 +273,3 @@ class ProductVariant(models.Model):
|
||||
def save(self, *args, **kwargs):
|
||||
self.set_or_update_price()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def get_toman_price_after_discount(self):
|
||||
return self.price * ((100 - self.discount) / 100)
|
||||
|
||||
@classmethod
|
||||
def update_all_prices(cls):
|
||||
print('calling the update all prices ')
|
||||
dollor_object, _ = DollorModel.objects.get_or_create(unique_filed='unique')
|
||||
print(dollor_object.price)
|
||||
dollor_object.update_price()
|
||||
dollor_object.save()
|
||||
dollor_price = dollor_object.price
|
||||
print(dollor_object.price)
|
||||
print('classmethod dollor price update ')
|
||||
products = cls.objects.all()
|
||||
for product in products:
|
||||
product.set_or_update_price(dollor_price=dollor_price)
|
||||
product.save()
|
||||
Reference in New Issue
Block a user