Allow adding filament without an article number
This commit is contained in:
1 parent
c6da58060d
commit
fbb7a5fc49
2 files changed
+18
-1
No files matched your search
+3
-1
@@ -48,8 +48,10 @@ class QuantityForm(forms.Form):
|
||||
|
||||
|
||||
class ArticleLookupForm(forms.Form):
|
||||
use_required_attribute = False
|
||||
|
||||
article_number = forms.CharField(
|
||||
label="Artikelnummer",
|
||||
label="Artikelnummer (optional)",
|
||||
max_length=Variant._meta.get_field("manufacturer_color_code").max_length,
|
||||
error_messages={"required": "Bitte gib eine Artikelnummer ein."},
|
||||
widget=forms.TextInput(
|
||||
|
||||
@@ -133,6 +133,21 @@ class CatalogTests(CatalogTestCase):
|
||||
self.client.post(url, data).context["form"]["spool_type"].value(), "spool"
|
||||
)
|
||||
|
||||
def test_article_number_is_optional_when_using_dropdowns(self):
|
||||
for path, model in (("bestand", InventoryItem), ("bestellung", OrderItem)):
|
||||
with self.subTest(path=path):
|
||||
url = f"/{path}/hinzufuegen/"
|
||||
response = self.client.get(url)
|
||||
article_input = response.context["lookup"]["article_number"].as_widget()
|
||||
self.assertIn('name="article_number"', article_input)
|
||||
self.assertNotIn("required", article_input)
|
||||
self.assertRedirects(
|
||||
self.client.post(url, self.selection() | {"article_number": ""}), f"/{path}/"
|
||||
)
|
||||
self.assertEqual(model.objects.get(variant=self.spool).quantity, 1)
|
||||
response = self.client.post(url, {"action": "lookup", "article_number": ""})
|
||||
self.assertContains(response, "Bitte gib eine Artikelnummer ein.")
|
||||
|
||||
def test_article_lookup_prefills_both_forms_and_preserves_quantity(self):
|
||||
self.refill.manufacturer_color_code = "PLA-RD-01"
|
||||
self.refill.save(update_fields=["manufacturer_color_code"])
|
||||
|
||||
Reference in new issue
Block a user