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

Merged
jocelyn merged 1 commits from rezemika/fix-90 into FFDN/master 6 years ago
rezemika commented 6 years ago

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 commented 6 years ago
Owner

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 commented 6 years ago
Poster

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 commented 6 years ago
Owner

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 !
This pull request has been merged successfully!
Sign in to join this conversation.
No Milestone
No assignee
2 Participants
Loading...
Cancel
Save
There is no content yet.