#51 feat: agregar descripcion, nombre alternativo y activo a categorias de productos

Issue #51: discriminacion y administracion de categorias de productos.

- ProductCategory.description (TextField blank)
- ProductCategory.alternative_name (CharField 100 nullable)
- ProductCategory.active (Boolean default True)
- Migracion 0056_productcategory_active_and_more
- Tests de modelo (campo don confiao y active por defecto)
This commit is contained in:
2026-10-10 16:27:49 -05:00
parent 53cc333c19
commit 570fec0532
3 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# Generated by Django 5.0.6 on 2026-10-10 21:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('don_confiao', '0055_productcategory_external_id'),
]
operations = [
migrations.AddField(
model_name='productcategory',
name='active',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='productcategory',
name='alternative_name',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AddField(
model_name='productcategory',
name='description',
field=models.TextField(blank=True, default=''),
),
]

View File

@@ -9,6 +9,9 @@ class MeasuringUnits(models.TextChoices):
class ProductCategory(models.Model):
name = models.CharField(max_length=100, unique=True)
external_id = models.CharField(max_length=100, null=True, blank=True)
description = models.TextField(blank=True, default="")
alternative_name = models.CharField(max_length=100, null=True, blank=True)
active = models.BooleanField(default=True)
def __str__(self):
return self.name

View File

@@ -0,0 +1,25 @@
from django.test import TestCase
from ..models.products import ProductCategory
class TestProductCategoryModel(TestCase):
def test_create_category_with_don_confiao_fields(self):
category = ProductCategory.objects.create(
name="Bebidas",
external_id="8",
description="Bebidas y jugos naturales",
alternative_name="Jugos",
active=False,
)
self.assertEqual(category.name, "Bebidas")
self.assertEqual(category.external_id, "8")
self.assertEqual(category.description, "Bebidas y jugos naturales")
self.assertEqual(category.alternative_name, "Jugos")
self.assertFalse(category.active)
def test_category_active_por_defecto(self):
category = ProductCategory.objects.create(name="Granos")
self.assertTrue(category.active)
self.assertEqual(category.description, "")
self.assertIsNone(category.alternative_name)