Allow negative currency values for "extra" line items (#3311)

This commit is contained in:
Oliver 2022-07-08 15:43:33 +10:00 committed by GitHub
parent 8f10bbb7e1
commit 78264868e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -63,10 +63,15 @@ class InvenTreeModelMoneyField(ModelMoneyField):
# Set a minimum value validator
validators = kwargs.get('validators', [])
allow_negative = kwargs.pop('allow_negative', False)
# If no validators are provided, add some "standard" ones
if len(validators) == 0:
validators.append(
MinMoneyValidator(0),
)
if not allow_negative:
validators.append(
MinMoneyValidator(0),
)
kwargs['validators'] = validators

View File

@ -957,6 +957,7 @@ class OrderExtraLine(OrderLineItem):
max_digits=19,
decimal_places=4,
null=True, blank=True,
allow_negative=True,
verbose_name=_('Price'),
help_text=_('Unit price'),
)