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.
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
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 :-)
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!
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 !
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
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 :-)
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.
Thank you!
Oh you are right, I was misreading the documentation. So your way seems the best, tested and approved !