I am creating a simple model to represent a chart of accounts:

For example, we have

0. top account
    1. Account 1
    1.1 account 1.1
       1.11
       1.12
       1.13
     1.2
(...)
    2.
      2.1
      2.2
         2.21
         2.22

The model is as below :

db.define_table('accountfromchart',
                SQLField('number', length=10),
                SQLField('description', length=155),
                SQLField('parentaccount', db.accountfromchart)
                )

db.accountfromchart.parentaccount.requires=IS_IN_DB
(db,'accountfromchart.id','accountfromchart.description')

So I am trying to have a nested database to represent the chart of
accounts, where for example the parent account of 2.22 is 2.2, and
where the parent account of 2.2 is 2, and the parent accounts of 2. is
account is zero.

I believe that using a foreign key would be the best option to do so,
but it fails with the following message:

Traceback (most recent call last):
  File "/home/francois/web2py/gluon/restricted.py", line 107, in
restricted
    exec ccode in environment
  File "/home/francois/web2py/applications/cookbook4/models/db.py",
line 41, in <module>
    SQLField('parentaccount', db.accountfromchart.id)
  File "/home/francois/web2py/gluon/sql.py", line 520, in __getattr__
    return self[key]
  File "/home/francois/web2py/gluon/sql.py", line 514, in __getitem__
    return dict.__getitem__(self, str(key))
KeyError: 'accountfromchart'


Where am i wrong? what is my mistake?

Thanks,

Francois
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to