Skip to content

Changing Quantity to decimal field  #569

Closed

Description

@Zenbiz

Issue: tests not passing when changing PositiveIntegerField to DecimalField on quantity variables within models.py.

Pretty new to Django here..Looks like you've been using this system for whole parts (ie you can buy a 1/2 a transistor). I tried changing the following quantity fields to decimals and I'm getting errors when I run tests. I'm wondering how difficult it would be to change the following:

Before:
quantity = models.PositiveIntegerField(default=1, validators=[MinValueValidator(1)])

After:
quantity = models.DecimalField(max_digits=11, decimal_places=8, validators=[MinValueValidator(0)], default=1.0)

image

Reason I ask is I'm buying some products by weight. So when using Inventree I can't convert oz<->grams and lbs<->liters without using decimals for the quantity variable.

Product is awesome though thanks for all the work! I'm using this for a lab setup potentially. I wouldn't mind working on this project and using it for my hobby lab and contributing to the documentation ;)

image

Activity

  1. SchrodingersGat commented on Nov 16, 2019

    @SchrodingersGat
    Member

    Hey @Zenbiz thanks for the feedback - I'm super excited that you like the project!

    I've just returned from holiday, sorry for the delay on responding to this.

    I would like to move to a DecimalField for the 'quantity' - up until now I have managed without 'partial' quantities but I can now see the need for it. I'll have a look at the unit testing issues, but there are also some other considerations that need to be made...

    I would absolutely love some contributions to the documentation if you have time - it's really lacking at the moment!

  2. added
    enhancement
    part
    on Nov 16, 2019
  3. SchrodingersGat commented on Nov 19, 2019

    @SchrodingersGat
    Member

    Hi @Zenbiz I have implemented this now. Please update to latest version and see if it is all working for you! (I may have missed an edge case in my testing).

    Also, I'd be very keen to hear back from you regarding the documentation side of things :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementpart

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions