diff --git a/loko/stock/forms.py b/loko/stock/forms.py index b7af5bb..897d03a 100644 --- a/loko/stock/forms.py +++ b/loko/stock/forms.py @@ -485,6 +485,17 @@ class ProductForm(forms.ModelForm): self.fields["authorized_locations"].required = False self.fields["authorized_locations"].help_text = _("Si vide, le produit est autorisé dans tous les emplacements.") + def clean_is_serialized(self): + from django.utils.translation import gettext_lazy as _ + is_serialized = self.cleaned_data.get("is_serialized", False) + if self.instance and self.instance.pk: + if self.instance.is_serialized and not is_serialized: + if self.instance.serialized_items.filter(is_active=True).exists(): + raise forms.ValidationError( + _("Impossible de désactiver le suivi par numéro de série : ce produit possède des articles tracés actifs.") + ) + return is_serialized + class ProductAtLocationForm(ProductForm): quantity = forms.IntegerField( diff --git a/loko/stock/locale/en/LC_MESSAGES/django.mo b/loko/stock/locale/en/LC_MESSAGES/django.mo index baf3aa4..0ecdc19 100644 Binary files a/loko/stock/locale/en/LC_MESSAGES/django.mo and b/loko/stock/locale/en/LC_MESSAGES/django.mo differ diff --git a/loko/stock/locale/en/LC_MESSAGES/django.po b/loko/stock/locale/en/LC_MESSAGES/django.po index e2044c4..ac1fe52 100644 --- a/loko/stock/locale/en/LC_MESSAGES/django.po +++ b/loko/stock/locale/en/LC_MESSAGES/django.po @@ -6572,3 +6572,47 @@ msgstr "Please check at least one item line to include in the order." #~ msgid "Rafraîchir la page" #~ msgstr "Refresh page" + +msgid "Vous n'avez pas la permission de modifier cet article." +msgstr "You do not have permission to edit this item." + +#, python-format +msgid "Numéro de série modifié : %(old)s → %(new)s" +msgstr "Serial number changed: %(old)s → %(new)s" + +#, python-format +msgid "Article tracé %(sn)s mis à jour avec succès." +msgstr "Serialized item %(sn)s successfully updated." + +msgid "Impossible de désactiver le suivi par numéro de série : ce produit possède des articles tracés actifs." +msgstr "Cannot disable serial tracking: this product has active serialized items." + +msgid "Une fois ce produit enregistré, vous pourrez lui ajouter ses numéros de série et les gérer individuellement." +msgstr "Once this product is saved, you will be able to add its serial numbers and manage them individually." + +msgid "En cochant cette option et en enregistrant, vous pourrez ajouter des numéros de série à ce produit." +msgstr "By checking this option and saving, you will be able to add serial numbers to this product." + +msgid "Numéros de série associés" +msgstr "Associated serial numbers" + +msgid "Ajouter un numéro de série" +msgstr "Add a serial number" + +msgid "Chaque unité physique de ce produit est identifiée par un numéro de série unique. Vous pouvez modifier directement un numéro de série ci-dessous." +msgstr "Each physical unit of this product is identified by a unique serial number. You can edit a serial number directly below." + +msgid "Modifier le numéro de série" +msgstr "Edit serial number" + +msgid "Consulter la fiche" +msgstr "View details" + +msgid "Aucun numéro de série n'a encore été enregistré pour ce produit." +msgstr "No serial number has been registered for this product yet." + +msgid "Enregistrer un numéro de série" +msgstr "Register a serial number" + +msgid "Modifier l'article tracé" +msgstr "Edit serialized item" diff --git a/loko/stock/locale/fr/LC_MESSAGES/django.mo b/loko/stock/locale/fr/LC_MESSAGES/django.mo index 4dcb8d5..7e7b1c5 100644 Binary files a/loko/stock/locale/fr/LC_MESSAGES/django.mo and b/loko/stock/locale/fr/LC_MESSAGES/django.mo differ diff --git a/loko/stock/locale/fr/LC_MESSAGES/django.po b/loko/stock/locale/fr/LC_MESSAGES/django.po index 8bc0e3c..a9eeaf6 100644 --- a/loko/stock/locale/fr/LC_MESSAGES/django.po +++ b/loko/stock/locale/fr/LC_MESSAGES/django.po @@ -6626,3 +6626,47 @@ msgstr "" #~ msgid "Rafraîchir la page" #~ msgstr "Rafraîchir la page" + +msgid "Vous n'avez pas la permission de modifier cet article." +msgstr "Vous n'avez pas la permission de modifier cet article." + +#, python-format +msgid "Numéro de série modifié : %(old)s → %(new)s" +msgstr "Numéro de série modifié : %(old)s → %(new)s" + +#, python-format +msgid "Article tracé %(sn)s mis à jour avec succès." +msgstr "Article tracé %(sn)s mis à jour avec succès." + +msgid "Impossible de désactiver le suivi par numéro de série : ce produit possède des articles tracés actifs." +msgstr "Impossible de désactiver le suivi par numéro de série : ce produit possède des articles tracés actifs." + +msgid "Une fois ce produit enregistré, vous pourrez lui ajouter ses numéros de série et les gérer individuellement." +msgstr "Une fois ce produit enregistré, vous pourrez lui ajouter ses numéros de série et les gérer individuellement." + +msgid "En cochant cette option et en enregistrant, vous pourrez ajouter des numéros de série à ce produit." +msgstr "En cochant cette option et en enregistrant, vous pourrez ajouter des numéros de série à ce produit." + +msgid "Numéros de série associés" +msgstr "Numéros de série associés" + +msgid "Ajouter un numéro de série" +msgstr "Ajouter un numéro de série" + +msgid "Chaque unité physique de ce produit est identifiée par un numéro de série unique. Vous pouvez modifier directement un numéro de série ci-dessous." +msgstr "Chaque unité physique de ce produit est identifiée par un numéro de série unique. Vous pouvez modifier directement un numéro de série ci-dessous." + +msgid "Modifier le numéro de série" +msgstr "Modifier le numéro de série" + +msgid "Consulter la fiche" +msgstr "Consulter la fiche" + +msgid "Aucun numéro de série n'a encore été enregistré pour ce produit." +msgstr "Aucun numéro de série n'a encore été enregistré pour ce produit." + +msgid "Enregistrer un numéro de série" +msgstr "Enregistrer un numéro de série" + +msgid "Modifier l'article tracé" +msgstr "Modifier l'article tracé" diff --git a/loko/stock/locale/nl/LC_MESSAGES/django.mo b/loko/stock/locale/nl/LC_MESSAGES/django.mo index f3b1d00..f8a9a6a 100644 Binary files a/loko/stock/locale/nl/LC_MESSAGES/django.mo and b/loko/stock/locale/nl/LC_MESSAGES/django.mo differ diff --git a/loko/stock/locale/nl/LC_MESSAGES/django.po b/loko/stock/locale/nl/LC_MESSAGES/django.po index 2bb4a6f..76dbec3 100644 --- a/loko/stock/locale/nl/LC_MESSAGES/django.po +++ b/loko/stock/locale/nl/LC_MESSAGES/django.po @@ -6614,3 +6614,47 @@ msgstr "Vink minimaal één artikelregel aan om op te nemen in de bestelling." #~ msgid "Rafraîchir la page" #~ msgstr "Pagina vernieuwen" + +msgid "Vous n'avez pas la permission de modifier cet article." +msgstr "U hebt geen toestemming om dit artikel te bewerken." + +#, python-format +msgid "Numéro de série modifié : %(old)s → %(new)s" +msgstr "Serienummer gewijzigd: %(old)s → %(new)s" + +#, python-format +msgid "Article tracé %(sn)s mis à jour avec succès." +msgstr "Getraceerd artikel %(sn)s succesvol bijgewerkt." + +msgid "Impossible de désactiver le suivi par numéro de série : ce produit possède des articles tracés actifs." +msgstr "Kan serienummertracking niet uitschakelen: dit product heeft actieve getraceerde artikelen." + +msgid "Une fois ce produit enregistré, vous pourrez lui ajouter ses numéros de série et les gérer individuellement." +msgstr "Zodra dit product is opgeslagen, kunt u serienummers toevoegen en deze afzonderlijk beheren." + +msgid "En cochant cette option et en enregistrant, vous pourrez ajouter des numéros de série à ce produit." +msgstr "Door deze optie aan te vinken en op te slaan, kunt u serienummers aan dit product toevoegen." + +msgid "Numéros de série associés" +msgstr "Gekoppelde serienummers" + +msgid "Ajouter un numéro de série" +msgstr "Een serienummer toevoegen" + +msgid "Chaque unité physique de ce produit est identifiée par un numéro de série unique. Vous pouvez modifier directement un numéro de série ci-dessous." +msgstr "Elke fysieke eenheid van dit product wordt geïdentificeerd door een uniek serienummer. U kunt hieronder rechtstreeks een serienummer bewerken." + +msgid "Modifier le numéro de série" +msgstr "Serienummer bewerken" + +msgid "Consulter la fiche" +msgstr "Fiche bekijken" + +msgid "Aucun numéro de série n'a encore été enregistré pour ce produit." +msgstr "Er is nog geen serienummer geregistreerd voor dit product." + +msgid "Enregistrer un numéro de série" +msgstr "Een serienummer registreren" + +msgid "Modifier l'article tracé" +msgstr "Getraceerd artikel bewerken" diff --git a/loko/stock/templates/stock/mobile/serialized_item_detail_mobile.html b/loko/stock/templates/stock/mobile/serialized_item_detail_mobile.html index a1b57b2..e62c1d8 100644 --- a/loko/stock/templates/stock/mobile/serialized_item_detail_mobile.html +++ b/loko/stock/templates/stock/mobile/serialized_item_detail_mobile.html @@ -78,6 +78,15 @@
{% translate "Numéro de série" %}
{{ item.serial_number }}
+ {% if can_manage and item.is_active %} +
+ +
+ {% endif %}
{{ item.product.name }} @@ -288,6 +297,52 @@ {% if item.created_by %}{% translate "par" %} {{ item.created_by.get_full_name|default:item.created_by.username }}{% endif %}
+{% if can_manage and item.is_active %} + + +{% endif %} + {% endblock content %} {% block extra_scripts %} diff --git a/loko/stock/templates/stock/product_detail.html b/loko/stock/templates/stock/product_detail.html index 163e1df..efc3242 100644 --- a/loko/stock/templates/stock/product_detail.html +++ b/loko/stock/templates/stock/product_detail.html @@ -631,8 +631,17 @@ {% if si.current_location %}{{ si.current_location.warehouse.name }} — {{ si.current_location.name }}{% else %}—{% endif %} - - + + {% if is_stock_manager and si.is_active %} + + + + {% endif %} + diff --git a/loko/stock/templates/stock/product_form.html b/loko/stock/templates/stock/product_form.html index 1e3eadb..b89d2d3 100644 --- a/loko/stock/templates/stock/product_form.html +++ b/loko/stock/templates/stock/product_form.html @@ -134,6 +134,112 @@ {% if form.is_serialized.errors %}
{{ form.is_serialized.errors }}
{% endif %} + + {% if action == 'create' %} +
+ + {% translate "Une fois ce produit enregistré, vous pourrez lui ajouter ses numéros de série et les gérer individuellement." %} +
+ {% elif not product.is_serialized %} +
+ + {% translate "En cochant cette option et en enregistrant, vous pourrez ajouter des numéros de série à ce produit." %} +
+ {% endif %} + + {% if action == 'edit' and product.is_serialized %} +
+
+
+ + + {% translate "Numéros de série associés" %} + + {{ serialized_items|length }} +
+ + {% translate "Ajouter un numéro de série" %} + +
+ +

+ {% translate "Chaque unité physique de ce produit est identifiée par un numéro de série unique. Vous pouvez modifier directement un numéro de série ci-dessous." %} +

+ + {% if serialized_items %} +
+ + + + + + + + + + + + {% for si in serialized_items %} + + + + + + + + {% endfor %} + +
{% translate "Numéro de série" %}{% translate "Statut" %}{% translate "Détenteur" %}{% translate "Emplacement" %}{% translate "Actions" %}
+ + {{ si.serial_number }} + + + {% if si.status == 'available' %} + {{ si.get_status_display }} + {% elif si.status == 'assigned' %} + {{ si.get_status_display }} + {% elif si.status == 'lost' %} + {{ si.get_status_display }} + {% else %} + {{ si.get_status_display }} + {% endif %} + {% if not si.is_active %} + {% translate "Inactif" %} + {% endif %} + {{ si.current_holder.name|default:"—" }} + {% if si.current_location %} + {{ si.current_location.warehouse.name }} — {{ si.current_location.name }} + {% else %}—{% endif %} + + + + + +
+
+ {% else %} +
+ + + {% translate "Aucun numéro de série n'a encore été enregistré pour ce produit." %} + + + {% translate "Enregistrer un numéro de série" %} + +
+ {% endif %} +
+ {% endif %}
@@ -276,6 +382,52 @@ + + {% if product.is_serialized %} + {% for si in serialized_items %} + + + {% endfor %} + {% endif %} {% endif %} @@ -289,6 +441,16 @@ document.addEventListener('DOMContentLoaded', function () { tooltipTriggerList.forEach(function (el) { new bootstrap.Tooltip(el); }); + + const isSerializedCheckbox = document.getElementById("{{ form.is_serialized.id_for_label }}"); + if (isSerializedCheckbox) { + const helpCreate = document.getElementById("serialized-help-create"); + const helpEdit = document.getElementById("serialized-help-edit"); + isSerializedCheckbox.addEventListener("change", function() { + if (helpCreate) helpCreate.style.display = this.checked ? "block" : "none"; + if (helpEdit) helpEdit.style.display = this.checked ? "block" : "none"; + }); + } }); {% if action == 'create' %} diff --git a/loko/stock/templates/stock/serialized_item_detail.html b/loko/stock/templates/stock/serialized_item_detail.html index c900dc1..fe7e312 100644 --- a/loko/stock/templates/stock/serialized_item_detail.html +++ b/loko/stock/templates/stock/serialized_item_detail.html @@ -15,6 +15,10 @@
{% if can_manage and item.is_active %} +
+ {% if can_manage and item.is_active %} + + + {% endif %} + {% if can_manage and item.is_active %}