Overview
The products module contains models for managing the restaurant’s product catalog, including products, categories, brands, suppliers, stock tracking, and product images.Producto
Main product model representing items available for sale.Primary key for the product. Auto-generated.
Product name. Must be unique.
max_length: 50unique: True- Validation: Cannot be empty or contain only whitespace
Purchase price of the product.
max_digits: 10decimal_places: 2- Validation: Must be less than
precio_venta
Sale price of the product.
max_digits: 10decimal_places: 2- Validation: Must be greater than
precio_compra
Current stock quantity.
default: 0- Validation: Cannot be negative
- Note: Changes to this field automatically create a Stock record
Product description.
blank: True
Whether the product is active/available.
default: True
Reference to product category.
to: Categoriaon_delete: SET_NULLnull: Trueblank: True
Reference to product supplier.
to: Proveedoron_delete: SET_NULLnull: Trueblank: True
Reference to product brand.
to: Marcaon_delete: SET_NULLnull: Trueblank: True
Methods
Database
- Table name:
producto - Related names:
stocks(reverse relation from Stock),imagenes(reverse relation from ProductoImagen)
Categoria
Product category model.Primary key for the category.
Category name.
max_length: 50null: Trueblank: True
Category description.
null: Trueblank: True
Database
- Table name:
categoria - Verbose names: Categoría (singular), Categorías (plural)
Marca
Product brand model.Primary key for the brand.
Brand name.
max_length: 50
Brand description.
null: Trueblank: True
Database
- Table name:
marca - Verbose names: Marca (singular), Marcas (plural)
Proveedor
Supplier/vendor model.Primary key for the supplier.
Supplier name.
max_length: 50
Contact person name.
max_length: 50
Contact phone number.
null: Trueblank: True
Supplier address.
Database
- Table name:
proveedor - Verbose names: Proveedor (singular), Proveedores (plural)
Stock
Stock history tracking model. Records all stock changes for products.Primary key for the stock record.
Reference to the product.
to: Productoon_delete: SET_NULLnull: Trueblank: Truedb_column: ‘id_producto’related_name: ‘stocks’
Stock quantity at this point in time.
null: Trueblank: True
Timestamp when the stock record was created.
auto_now_add: True
Database
- Table name:
stock - Verbose names: Stock (singular), Stocks (plural)
Stock records are automatically created when a Producto’s stock field is modified. This provides a complete audit trail of inventory changes.
ProductoImagen
Product image model. Supports multiple images per product.Primary key for the image.
Reference to the product.
to: Productoon_delete: CASCADErelated_name: ‘imagenes’
Product image file.
upload_to: producto_image_path (custom function)- Images are stored in
media/productos/{product_id}/ - Automatically converted to WebP format
help_text: ‘Imagen del producto (se guardará en media/productos/)‘
Database
- Table name:
producto_imagen - Verbose names: Imagen del producto (singular), Imágenes de productos (plural)
