I'm doing an inventory of tools, and I want to have a way to create a tool cart where I can add repeated tools. Example (Add to the cart two cutters of the same type).
I have a table called Item This table contains all the common fields of all the tools (description, quantity_existing, minimum quantity, unit price, etc.) and a table for each type of tool ( clamps, cutters, screwdrivers, screws, etc.) the tables for the tools inherit from the Item table.
I also have a table called Carts and Employees . In the table Carritos I seek to make the union of Items and Employees . I do not plan to generate a view since I want to control the creation of carts and the assignment of employees from the Admin page, for the moment I can select different tools in the cart, what I can not do is put more of the same type or manually put the amount of that type of tool that the cart has
models.py
# =========================================================================== #
# MODELO PARA CREAR CARRITOS
# =========================================================================== #
class Carritos(models.Model):
no_carrito = models.CharField(max_length=3, unique=True)
empleado = models.ForeignKey(Empleados, on_delete=models.CASCADE)
herramienta = models.ManyToManyField(Item)
# cantidad = models.PositiveIntegerField()
f_creacion = models.DateTimeField(auto_now_add=True)
f_actualizacion = models.DateTimeField(auto_now=True)
activo = models.BooleanField(default=True)
class Meta:
verbose_name_plural = "Carritos"
def __str__(self):
return self.no_carrito
I would really appreciate your help