#158 Sets a step of 1 for the quantity field of InvoiceDetail

Fusionné
jocelyn a fusionné 1 commits à partir de rezemika/fix-90 vers FFDN/master il y a 6 ans
rezemika a commenté il y a 6 ans

The quantity field had a step of 0.01, which was quite inadequate. To ensure an easy update, this PR does not modify the model to change quantity fields by an IntegerField or something, but just changes the step of the corresponding field in the admin interface.

Ticket: #90

The quantity field had a step of 0.01, which was quite inadequate. To ensure an easy update, this PR does not modify the model to change quantity fields by an IntegerField or something, but just changes the step of the corresponding field in the admin interface. Ticket: #90
jocelyn a commenté il y a 6 ans
Propriétaire

Thanks again !

If I'm not mistaken, I think there is a way with far less code to do that same thing.

No obligation at all, your way is perfectly fine. Let me know what you prefer. I'd be happy either way :-)

Thanks again ! If I'm not mistaken, I think there is [a way with far less code](https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_overrides) to do that same thing. No obligation at all, your way is perfectly fine. Let me know what you prefer. I'd be happy either way :-)
rezemika a commenté il y a 6 ans
Publier

Oh, you're right, I did'nt know this method.

However, I just tested and it seems it also affects "amount" and "tax" fields (all DecimalFields, in fact). Do you know a workaround for this?

Here is the current code.

class InvoiceDetailInline(LimitedAdminInlineMixin, admin.StackedInline):
    model = InvoiceDetail
    extra = 0
    fields = (('label', 'amount', 'quantity', 'tax'),
              ('offersubscription', 'period_from', 'period_to'))
    formfield_overrides = {
        models.DecimalField: {'widget': forms.NumberInput(attrs={'step': 1})}
    }

Thank you!

Oh, you're right, I did'nt know this method. However, I just tested and it seems it also affects "amount" and "tax" fields (all DecimalFields, in fact). Do you know a workaround for this? Here is the current code. ```python class InvoiceDetailInline(LimitedAdminInlineMixin, admin.StackedInline): model = InvoiceDetail extra = 0 fields = (('label', 'amount', 'quantity', 'tax'), ('offersubscription', 'period_from', 'period_to')) formfield_overrides = { models.DecimalField: {'widget': forms.NumberInput(attrs={'step': 1})} } ``` Thank you!
jocelyn a commenté il y a 6 ans
Propriétaire

However, I just tested and it seems it also affects "amount" and "tax" fields (all DecimalFields, in fact). Do you know a workaround for this?

Oh you are right, I was misreading the documentation. So your way seems the best, tested and approved !

> However, I just tested and it seems it also affects "amount" and "tax" fields (all DecimalFields, in fact). Do you know a workaround for this? Oh you are right, I was misreading the documentation. So your way seems the best, tested and approved !
Cette Pull Request a été fusionnée avec succès !
Connectez-vous pour rejoindre cette conversation.
Aucun jalon
Pas d'assignataire
2 Participants
Chargement…
Annuler
Enregistrer
Il n'existe pas encore de contenu.