Changeset 1226 in main


Ignore:
Timestamp:
06/15/12 07:44:03 (7 years ago)
Author:
pcosquer
Message:

forms: create: allows an empty reference if auto is checked

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/forms.py

    r1225 r1226  
    144144        if issubclass(cls, m.PLMObject): 
    145145            Form.base_fields.insert(1,'auto',BooleanField(required=False,initial=True, help_text=_("Checking this case, you allow OpenPLM to set the reference of the object."))) 
     146            Form.base_fields["reference"].required = False 
    146147            Form.clean_reference = _clean_reference 
    147148            Form.clean_revision = _clean_revision 
     
    151152                rev = cleaned_data.get("revision", "") 
    152153                auto = cleaned_data.get("auto", False) 
     154                if auto and not ref: 
     155                    cleaned_data["reference"] = ref = get_new_reference(cls, start) 
     156                if not auto and not ref: 
     157                    self.errors["reference"] = _("The reference is required.")                     
    153158                if cls.objects.filter(type=cls.__name__, revision=rev, reference=ref).exists(): 
    154159                    if not auto: 
Note: See TracChangeset for help on using the changeset viewer.