diff options
| -rw-r--r-- | ishtar/furnitures/forms.py | 9 | ||||
| -rw-r--r-- | ishtar/furnitures/forms_items.py | 6 | ||||
| -rw-r--r-- | ishtar/furnitures/models.py | 2 | 
3 files changed, 13 insertions, 4 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py index 77e2c9b7e..3d663d089 100644 --- a/ishtar/furnitures/forms.py +++ b/ishtar/furnitures/forms.py @@ -70,6 +70,15 @@ regexp_name = re.compile(r'^[\w\- ]+$', re.UNICODE)  name_validator = validators.RegexValidator(regexp_name,  _(u"Enter a valid name consisting of letters, spaces and hyphens."), 'invalid') +class FloatField(forms.FloatField): +    """ +    Allow the use of comma for separating float fields +    """ +    def clean(self, value): +        if value: +            value = value.replace(',', '.').replace('%', '') +        return super(FloatField, self).clean(value) +  class FinalForm(forms.Form):      final = True      form_label = _("Confirm") diff --git a/ishtar/furnitures/forms_items.py b/ishtar/furnitures/forms_items.py index f229ec4f2..05aa07170 100644 --- a/ishtar/furnitures/forms_items.py +++ b/ishtar/furnitures/forms_items.py @@ -33,7 +33,7 @@ from ishtar import settings  import models  import widgets -from forms import Wizard, FinalForm, FormSet, SearchWizard, \ +from forms import Wizard, FinalForm, FormSet, SearchWizard, FloatField,\                    formset_factory, get_now, reverse_lazy  from forms_common import get_town_field  from forms_context_records import RecordFormSelection @@ -102,8 +102,8 @@ class ItemForm(forms.Form):                                           required=False)      material_type = forms.ChoiceField(label=_("Material type"),                                 choices=models.MaterialType.get_types()) -    volume = forms.IntegerField(label=_(u"Volume"), required=False) -    weight = forms.IntegerField(label=_(u"Weight"), required=False) +    volume = FloatField(label=_(u"Volume"), required=False) +    weight = FloatField(label=_(u"Weight"), required=False)      item_number = forms.IntegerField(label=_(u"Item number"), required=False)  class DateForm(forms.Form): diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py index 3d6e12536..437189464 100644 --- a/ishtar/furnitures/models.py +++ b/ishtar/furnitures/models.py @@ -924,7 +924,7 @@ class Item(BaseHistorizedItem, OwnPerms):      material_type = models.ForeignKey(MaterialType,                                verbose_name = _(u"Material type"))      volume = models.FloatField(_(u"Volume"), blank=True, null=True) -    weight = models.IntegerField(_(u"Weight"), blank=True, null=True) +    weight = models.FloatField(_(u"Weight"), blank=True, null=True)      item_number = models.IntegerField(_("Item number"), blank=True, null=True)      upstream_treatment = models.ForeignKey("Treatment", blank=True, null=True,        related_name='downstream_treatment', verbose_name=_("Upstream treatment"))  | 
