def get_default_value(self, field, context, arnum):
        """Get the default value of the field
        """
        name = field.getName()
        default = field.getDefault(context)
        if name == "Batch":
            batch = self.get_batch()
            if batch is not None:
                default = batch
        if name == "Client":
            client = self.get_client()
            if client is not None:
                default = client
        # only set default contact for first column
        if name == "Contact" and arnum == 0:
            contact = self.get_default_contact()
            if contact is not None:
                default = contact
        if name == "Sample":
            sample = self.get_sample()
            if sample is not None:
                default = sample
        # Querying for adapters to get default values from add-ons':
        # We don't know which fields the form will render since
        # some of them may come from add-ons. In order to obtain the default
        # value for those fields we take advantage of adapters. Adapters
        # registration should have the following format:
        # < adapter
        #   factory = ...
        #   for = "*"
        #   provides = "bika.lims.interfaces.IGetDefaultFieldValueARAddHook"
        #   name = "<fieldName>_default_value_hook"
        # / >
        hook_name = name + '_default_value_hook'
        adapter = queryAdapter(
            self.request,
            name=hook_name,
            interface=IGetDefaultFieldValueARAddHook)
        if adapter is not None:
            default = adapter(self.context)
        logger.info("get_default_value: context={} field={} value={} arnum={}"
                    .format(context, name, default, arnum))
        return default
def get_default_value ( self , field , context , arnum ) : name = field . getName ( ) default = field . getDefault ( context ) if name == "Batch" : batch = self . get_batch ( ) if batch is not None : default = batch if name == "Client" : client = self . get_client ( ) if client is not None : default = client if name == "Contact" and arnum == 0 : contact = self . get_default_contact ( ) if contact is not None : default = contact if name == "Sample" : sample = self . get_sample ( ) if sample is not None : default = sample hook_name = name + '_default_value_hook' adapter = queryAdapter ( self . request , name = hook_name , interface = IGetDefaultFieldValueARAddHook ) if adapter is not None : default = adapter ( self . context ) logger . info ( "get_default_value: context={} field={} value={} arnum={}" . format ( context , name , default , arnum ) ) return default
Get the default value of the field