Hello,

my application uses a sqlite database with several numeric fields. In
the database table they are declared as REAL(6,2) and the like. In the
application the DataStructure of the bizobj is set explicitly:

self.DataStructure = (("ausg_id", "I", True, "ausgaben", "ausg_id"),
                      ("artikel", "C", False, "ausgaben", "artikel"),
                      ("firma", "C", False, "ausgaben", "firma"),
                      ("euro_betrag", "N", False, "ausgaben",
                       "euro_betrag"),
                      ("ausg_datum", "D", False, "ausgaben",
                       "ausg_datum"),
                      ("abrech_datum", "D", False, "ausgaben",
                       "abrech_datum"),
                      ("kauf_typ", "C", False, "ausgaben", "kauf_typ"),
                      ("ausland", "I", False, "ausgaben", "ausland"),
                      ("orig_betrag", "N", False, "ausgaben",
                       "orig_betrag"),
                      ("waehrung", "C", False, "ausgaben", "waehrung"),
                      ("kurs", "N", False, "ausgaben", "kurs"),
                      ("aufschlag", "N", False, "ausgaben", "aufschlag")
                      ("bemerk", "C", False, "ausgaben", "bemerk"))

The form for entry and editing of single records uses dTextBox instances
for the numeric fields - this is a database for my own use only, and the
amounts vary too much for a dSpinner to be really helpful. What's more
important, this works correctly with the field "euro_betrag" which in
most cases is the only one filled in. Now today for the first time I had
to put values in "orig_betrag" and "kurs". I _did_ enter a dot and not a
comma as the decimal separator, and I didn't enter anything non numeric,
but I got this:

s...@elend:~/pfotweg/dabo_visa> ./visa_s_dabo.py
Dabo Error Log: Sun Sep 20 11:04:22 2009: !!! Falsche Datentypzuordnung:
Feld=kurs. Erwartet: <class 'decimal.Decimal'>; Erhalten: <type 'unicode'>
--- after entering the value. This is the problem, I think. The error at
saving follows logically. No similar message for "orig_betrag" which
gets its value from a dTextBox as well. No difference between entering
numbers with or without decimal point.

--- trying to save the record:
Dabo Error Log: Sun Sep 20 11:04:31 2009: Error in scanChangedRows:
unsupported operand type(s) for /: 'Decimal' and 'unicode'
Traceback (most recent call last):
  File "/home/sib/svn_src/dabo_trunk/dabo/ui/uiwx/dControlMixin.py",
line 27, in _onWxHit
    self.raiseEvent(dEvents.Hit, evt, *args, **kwargs)
  File "/home/sib/svn_src/dabo_trunk/dabo/ui/uiwx/dPemMixin.py", line
949, in raiseEvent
    super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
  File "/home/sib/svn_src/dabo_trunk/dabo/lib/eventMixin.py", line 93,
in raiseEvent
    bindingFunction(event)
  File "/home/sib/svn_src/dabo_trunk/dabo/ui/uiwx/dForm.py", line 716,
in onSave
    def onSave(self, evt): self.save()
  File "/home/sib/svn_src/dabo_trunk/dabo/ui/uiwx/dForm.py", line 383,
in save
    bizobj.saveAll()
  File "/home/sib/svn_src/dabo_trunk/dabo/biz/dBizobj.py", line 362, in
saveAll
    startTransaction=False)
  File "/home/sib/svn_src/dabo_trunk/dabo/biz/dBizobj.py", line 777, in
scanChangedRows
    func(*args, **kwargs)
  File "/home/sib/svn_src/dabo_trunk/dabo/biz/dBizobj.py", line 410, in save
    self._validate()
  File "/home/sib/svn_src/dabo_trunk/dabo/biz/dBizobj.py", line 1077, in
_validate
    message = self.validateRecord()
  File "./visa_s_dabo.py", line 51, in validateRecord
    euro = orig / kurs
TypeError: unsupported operand type(s) for /: 'Decimal' and 'unicode'

This is the record validation method:

def validateRecord(self):
    if self.getFieldVal("ausland"):
        rund = decimal.Decimal("0.01")
        orig = self.getFieldVal("orig_betrag")
        kurs = self.getFieldVal("kurs")
        euro = orig / kurs
        aufschlag = euro * decimal.Decimal("0.0185")
        self.setFieldVal("euro_betrag", euro.quantize(rund))
        self.setFieldVal("aufschlag", aufschlag.quantize(rund))
    else:
        for fld in ["orig_betrag", "kurs", "aufschlag"]:
            self.setFieldVal(fld, None)

And here is the code from afterInit() of a dPage which puts the
textboxes into the form (gsp is a dGridSizer - not the same instance in
the two calls):

gsp.append(dabo.ui.dTextBox(panel1, RegID="txtPreisID",
                            DataSource="ausgaben",
                            DataField="euro_betrag"), "x")
....
gsp.append(dabo.ui.dTextBox(panel2, DataSource="ausgaben",
                            DataField="kurs"))

I can't see why one of them works and the other doesn't. Here is the
version information, but I don't really think it will help.

Platform: GTK
Python Version: 2.6 on linux2
Dabo Version: Version 0.9.2; Revision 5402M
UI Version: 2.8.9.2 on wxGTK (gtk2)

Did I leave out relevant information?

Thanks for help,
Sibylle

-- 
Sibylle Koczian



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to