Proposition V1

This commit is contained in:
MarrhieuHR authored and MatthieuHR committed 2026-11-09 09:19:41 +01:00
1 parent bfa5fa45b8
commit fc961f6511
36 files changed
+1984

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
from core.views.widgets.ajax_select import AutoCompleteSelect
class StockItemSelect(AutoCompleteSelect):
def get_context(self, name, value, attrs):
self._quantities = {
str(item.pk): item.quantity
for item in self.choices.queryset.only("pk", "quantity", "item__name")
}
return super().get_context(name, value, attrs)
def create_option(
self, name, value, label, selected, index, subindex=None, attrs=None
):
option = super().create_option(
name, value, label, selected, index, subindex=subindex, attrs=attrs
)
quantity = self._quantities.get(str(value))
if quantity is not None:
option["attrs"]["data-quantity"] = str(quantity)
return option