Hi,
I have an Enumeration field in my Entity 'Payment'
amount_is = Column(camelot.types.Enumeration([(0,u'inkl. Steuer'), (1,u"excl. Steuer"), (2,u"nur Steuer")]), index = True, nullable=False, default=u"inkl. Steuer")
In order to perform a calculation, each time this field is changed by the user, I have written a property funtion as a hook:
#_amount_is hook
def _set_amount_is(self, amount_is):
self.amount_is = amount_is
self.flush()
self.update_amounts()
def _get_amount_is(self):
return self.amount_is
_amount_is = property(_get_amount_is, _set_amount_is)
I adjusted
Admin
accordingly and set the
ComboBoxDelegate
as delegate:
class Admin(EntityAdmin):
verbose_name = _('Payment')
validator = PaymentValidator
#form
form_display = ['_entered_amount', '_amount_is','_tax','amount_excl', 'amount_incl', 'amount_tax']
field_attributes = dict(
_amount_is=dict(delegate=delegates.ComboBoxDelegate, target="Payment", editable=True),
_entered_amount=dict(delegate=delegates.FloatDelegate, editable=True),
_tax=dict(delegate=delegates.Many2OneDelegate, target='Tax', editable=True)
)
Now the problem is, that the Choices delegate is not supplied with my list of choices, so I get some Errors like this:
ERROR:camelot.view.controls.editors.ChoicesEditor:Could not set value nur Steuer in field _amount_is_editor because it is not in the list of choices
What is the proper way to supply the ComboBoxDelegate with the list of choices in this case?
Thanks for your help, guys
Sebastian