Creates copies of the fields we are keeping
        track of for the provided model, returning a
        dictionary mapping field name to a copied field object.
2315
def copy_fields(self, model):
        
        fields = {'__module__' : model.__module__}

        for field in model._meta.fields:

            if not field.name in self._exclude:

                field  = copy.deepcopy(field)

                if isinstance(field, models.AutoField):
                    #we replace the AutoField of the original model
                    #with an IntegerField because a model can
                    #have only one autofield.

                    field.__class__ = models.IntegerField

                if field.primary_key:
                    field.serialize = True

                #OneToOne fields should really be tracked
                #as ForeignKey fields
                if isinstance(field, models.OneToOneField):
                    field.__class__ = models.ForeignKey


                if field.primary_key or field.unique:
                    #unique fields of the original model
                    #can not be guaranteed to be unique
                    #in the audit log entry but they
                    #should still be indexed for faster lookups.

                    field.primary_key = False
                    field._unique = False
                    field.db_index = True


                if field.remote_field and field.remote_field.related_name:
                    field.remote_field.related_name = '_auditlog_{}_{}'.format(
                        model._meta.model_name,
                        field.remote_field.related_name
                    )
                elif field.remote_field:
                    try:
                        if field.remote_field.get_accessor_name():
                            field.remote_field.related_name = '_auditlog_{}_{}'.format(
                                model._meta.model_name,
                                field.remote_field.get_accessor_name()
                            )
                    except e:
                        pass

                fields[field.name] = field

        return fields
872034
def fill_with_model(self, model, *fields):
        
        model_dct = model.to_dict(include=self._fields.keys())
        localized_dct = self.localize(*fields, **model_dct)
        if model.key:
            localized_dct['id'] = model.key.id()
        return localized_dct
1271942
private FieldDescriptorDef cloneField(FieldDescriptorDef fieldDef, String prefix)
    {
        FieldDescriptorDef copyFieldDef = new FieldDescriptorDef(fieldDef, prefix);

        copyFieldDef.setOwner(this);
        // we remove properties that are only relevant to the class the features are declared in
        copyFieldDef.setProperty(PropertyHelper.OJB_PROPERTY_IGNORE, null);

        Properties mod = getModification(copyFieldDef.getName());

        if (mod != null)
        {
            if (!PropertyHelper.toBoolean(mod.getProperty(PropertyHelper.OJB_PROPERTY_IGNORE), false) &&
                hasFeature(copyFieldDef.getName()))
            {
                LogHelper.warn(true,
                               ClassDescriptorDef.class,
                               "process",
                               "Class "+getName()+" has a feature that has the same name as its included field "+
                               copyFieldDef.getName()+" from class "+fieldDef.getOwner().getName()); 
            }
            copyFieldDef.applyModifications(mod);
        }
        return copyFieldDef;
    }
1092132
def set_fields(self, fields=None, *fields_args, **fields_kwargs):
        
        if fields_args:
            fields = [fields]
            fields.extend(fields_args)
            for field_name in fields:
                self.set_field(field_name)

        elif fields_kwargs:
            fields = make_dict(fields, fields_kwargs)
            for field_name, field_val in fields.items():
                self.set_field(field_name, field_val)

        else:
            if isinstance(fields, Mapping):
                for field_name, field_val in fields.items():
                    self.set_field(field_name, field_val)

            else:
                for field_name in fields:
                    self.set_field(field_name)

        return self
792856
def _clone_reverses(self, old_reverses):
        

        for ctype, reverses in old_reverses.items():
            for parts in reverses.values():
                sub_objs = parts[1]
                field_name = parts[0]

                attrs = {}
                for sub_obj in sub_objs:
                    if ctype != 'm2m' and not attrs:
                        field = sub_obj._meta.get_field(field_name)
                        attrs = {
                            field.column: getattr(self, field.rel.field_name)
                        }
                    sub_obj._clone(**attrs)

                if ctype == 'm2m':
                    setattr(self, field_name, sub_objs)
713866
def _map_dict_keys_to_model_attributes(model_type, model_dict):
    

    new_dict = {}
    for key, value in model_dict.items():
        new_dict[_get_k8s_model_attribute(model_type, key)] = value

    return new_dict
158359
def _create_mappings(self, spec):
        
        ret = dict(zip(set(spec.fields), set(spec.fields)))
        ret.update(dict([(n, s.alias) for n, s in spec.fields.items() if s.alias]))
        return ret
1264383
def get_fields(self):
        

        fields = self.Meta.fields
        exclude = self.Meta.exclude
        ignore_fields = self.Meta.ignore_fields
        indices = self.Meta.index_classes

        declared_fields = copy.deepcopy(self._declared_fields)
        prefix_field_names = len(indices) > 1
        field_mapping = OrderedDict()

        # overlapping fields on multiple indices is supported by internally prefixing the field
        # names with the index class to which they belong or, optionally, a user-provided alias
        # for the index.
        for index_cls in self.Meta.index_classes:
            prefix = ""
            if prefix_field_names:
                prefix = "_%s__" % self._get_index_class_name(index_cls)
            for field_name, field_type in six.iteritems(index_cls.fields):
                orig_name = field_name
                field_name = "%s%s" % (prefix, field_name)

                # Don't use this field if it is in `ignore_fields`
                if orig_name in ignore_fields or field_name in ignore_fields:
                    continue
                # When fields to include are decided by `exclude`
                if exclude:
                    if orig_name in exclude or field_name in exclude:
                        continue
                # When fields to include are decided by `fields`
                if fields:
                    if orig_name not in fields and field_name not in fields:
                        continue

                # Look up the field attributes on the current index model,
                # in order to correctly instantiate the serializer field.
                model = index_cls().get_model()
                kwargs = self._get_default_field_kwargs(model, field_type)
                kwargs['prefix_field_names'] = prefix_field_names
                field_mapping[field_name] = self._field_mapping[field_type](**kwargs)

        # Add any explicitly declared fields. They *will* override any index fields
        # in case of naming collision!.
        if declared_fields:
            for field_name in declared_fields:
                field_mapping[field_name] = declared_fields[field_name]
        return field_mapping
912097
def _create_model_class(self, model):
        
        cls_name = model.replace('.', '_')
        # Hack for Python 2 (no need to do this for Python 3)
        if sys.version_info[0] < 3:
            if isinstance(cls_name, unicode):
                cls_name = cls_name.encode('utf-8')
        # Retrieve server fields info and generate corresponding local fields
        attrs = {
            '_env': self,
            '_odoo': self._odoo,
            '_name': model,
            '_columns': {},
        }
        fields_get = self._odoo.execute(model, 'fields_get')
        for field_name, field_data in fields_get.items():
            if field_name not in FIELDS_RESERVED:
                Field = fields.generate_field(field_name, field_data)
                attrs['_columns'][field_name] = Field
                attrs[field_name] = Field
        # Case where no field 'name' exists, we generate one (which will be
        # in readonly mode) in purpose to be filled with the 'name_get' method
        if 'name' not in attrs['_columns']:
            field_data = {'type': 'text', 'string': 'Name', 'readonly': True}
            Field = fields.generate_field('name', field_data)
            attrs['_columns']['name'] = Field
            attrs['name'] = Field
        return type(cls_name, (Model,), attrs)
134061
def get_field_mapping(self):
        
        fields = {}
        values = {}
        for tab in self.tabs:
            parameter_values = tab.get_parameter_value()
            fields.update(parameter_values['fields'])
            values.update(parameter_values['values'])
        return {
            'fields': fields,
            'values': values
        }
1315808
def copy(self, selection, smart_selection_adaption=True):
        
        assert isinstance(selection, Selection)
        self.__create_core_and_model_object_copies(selection, smart_selection_adaption)
994435
def key_value(self, *args, **kwargs):
        
        new_df = copy_df(self)
        fields = _render_field_set(args)
        self._assert_ml_fields_valid(*fields)
        new_df._perform_operation(
            op.FieldKVConfigOperation(dict((_get_field_name(f), KVConfig(**kwargs)) for f in fields)))
        return new_df
1084667
def copy(self):
        
        return self.__class__(field_type=self.get_field_type(), data=self.export_data())
684583
def copy(self):
        
        # new objects are constructed for each, so we just need to pass them in
        return BinaryQuadraticModel(self.linear, self.quadratic, self.offset, self.vartype, **self.info)
604153
def model_to_dict(instance, **options):
    ""

    options = _defaults(options)
    attrs = {}

    if options['prehook']:
        if isinstance(options['prehook'], collections.Callable):
            instance = options['prehook'](instance)
            if instance is None:
                return attrs

    # Items in the `fields` list are the output aliases, not the raw
    # accessors (field, method, property names)
    for alias in options['fields']:

        # Get the accessor for the object
        accessor = options['aliases'].get(alias, alias)

        # Create the key that will be used in the output dict
        key = options['prefix'] + alias

        # Optionally camelcase the key
        if options['camelcase']:
            key = convert_to_camel(key)

        # Get the field value. Use the mapped value to the actually property or
        # method name. `value` may be a number of things, so the various types
        # are checked below.
        value = get_field_value(instance, accessor,
                                allow_missing=options['allow_missing'])

        # Related objects, perform some checks on their options
        if isinstance(value, (models.Model, QuerySet)):
            _options = _defaults(options['related'].get(accessor, {}))

            # If the `prefix` follows the below template, generate the
            # `prefix` for the related object
            if '%(accessor)s' in _options['prefix']:
                _options['prefix'] = _options['prefix'] % {'accessor': alias}

            if isinstance(value, models.Model):
                if len(_options['fields']) == 1 and _options['flat'] \
                        and not _options['merge']:
                    value = list(serialize(value, **_options).values())[0]
                else:
                    # Recurse, get the dict representation
                    _attrs = serialize(value, **_options)

                    # Check if this object should be merged into the parent,
                    # otherwise nest it under the accessor name
                    if _options['merge']:
                        attrs.update(_attrs)
                        continue

                    value = _attrs
            else:
                value = serialize(value, **_options)

        attrs[key] = value

    # Apply post-hook to serialized attributes
    if options['posthook']:
        attrs = options['posthook'](instance, attrs)

    return attrs
1036643
def derive_fields(self):
        
        if self.fields:
            return self.fields

        else:
            fields = []
            for field in self.object_list.model._meta.fields:
                if field.name != 'id':
                    fields.append(field.name)
            return fields
80432
def _with_fields(*fields):
    
    dd = {}
    for x in fields:
        dd[x] = _COMMON_FIELDS[x]

    def wrap(cls):
        dd.update(cls.__dict__)
        return type(cls.__name__, cls.__bases__, dd)

    return wrap