Пример #1
0
class FormCreate(DBForm):
    name = "create"
    string = _('Create new database')
    action = '/database/do_create'
    submit_text = _('OK')
    strip_name = True
    form_attrs = {'onsubmit': 'return on_create()'}
    fields = [
        widgets.PasswordField(name='password',
                              label=_('Super admin password:'******'dbname',
                          label=_('New database name:'),
                          validator=validators.NotEmpty()),
        widgets.CheckBox(name='demo_data',
                         label=_('Load Demonstration data:'),
                         default=True,
                         validator=validators.Bool(if_empty=False)),
        widgets.SelectField(name='language',
                            options=get_lang_list,
                            validator=validators.String(),
                            label=_('Default Language:')),
        widgets.PasswordField(name='admin_password',
                              label=_('Administrator password:'******'confirm_password',
                              label=_('Confirm password:'),
                              validator=validators.NotEmpty())
    ]
    validator = validators.Schema(chained_validators=[
        validators.FieldsMatch("admin_password", "confirm_password")
    ])
class FormCreate(DBForm):
    name = "create"
    string = _('Create database')
    action = '/openerp/database/do_create'
    submit_text = _('Create')
    strip_name = True
    form_attrs = {'onsubmit': 'return on_create()'}
    fields = [
        openobject.widgets.PasswordField(
            name='password',
            label=_('Super admin password:'******'admin' after installation."
              )),
        openobject.widgets.TextField(
            name='dbname',
            label=_('New database name:'),
            validator=formencode.validators.NotEmpty(),
            help=
            _("Choose the name of the database that will be created. The name must not contain any special character. Exemple: 'terp'."
              )),
        openobject.widgets.CheckBox(
            name='demo_data',
            label=_('Load Demonstration data:'),
            default=True,
            validator=validators.Bool(if_empty=False),
            help=
            _("Check this box if you want demonstration data to be installed on your new database. These data will help you to understand OpenERP, with predefined products, partners, etc."
              )),
        openobject.widgets.SelectField(
            name='language',
            options=get_lang_list,
            validator=validators.String(),
            label=_('Default Language:'),
            help=
            _("Choose the default language that will be installed for this database. You will be able to install new languages after installation through the administration menu."
              )),
        openobject.widgets.PasswordField(
            name='admin_password',
            label=_('Administrator password:'******'admin' user that will be created in your new database."
              )),
        openobject.widgets.PasswordField(
            name='confirm_password',
            label=_('Confirm password:'******'admin' user that will be created in your new database. It has to be the same than the above field."
              ))
    ]
    validator = openobject.validators.Schema(chained_validators=[
        formencode.validators.FieldsMatch("admin_password", "confirm_password")
    ])
Пример #3
0
    def __getstate__(self):
        return self.__dict__

    def __setstate__(self, d):
        self.__dict__.update(d)

_VALIDATORS = {
    'date': lambda *a: validators.DateTime(kind="date"),
    'time': lambda *a: validators.DateTime(kind="time"),
    'datetime': lambda *a: validators.DateTime(kind="datetime"),
    'float_time': lambda *a: validators.FloatTime(),
    'float': lambda *a: validators.Float(),
    'integer': lambda *a: validators.Int(),
    'selection': lambda *a: validators.Selection(),
    'char': lambda *a: validators.String(),
    'boolean': lambda *a: validators.Bool(),
    'reference': lambda *a: validators.Reference(),
    'binary': lambda *a: validators.Binary(),
    'text': lambda *a: validators.String(),
    'text_tag': lambda *a: validators.String(),
    'many2many': lambda *a: validators.many2many(),
    'one2many': lambda *a: validators.one2many(),
    'many2one': lambda *a: validators.many2one(),
    'email' : lambda *a: validators.Email(),
    'url' : lambda *a: validators.URL(),
    'picture': lambda *a: validators.Binary(),
}

class TinyFormError(formencode.api.Invalid):
    def __init__(self, field, msg, value):
        formencode.api.Invalid.__init__(self, msg, value, state=None, error_list=None, error_dict=None)
Пример #4
0
 def __init__(self, **attrs):
     super(Boolean, self).__init__(**attrs)
     self.validator = validators.Bool()