yeah, my pov is because your product never save the sale id. imho, i think
your code should be :
db.define_table(
'sale',
Field('product_id', 'reference product'),
Field('user_id', db.auth_user, default=auth.user_id),
Field('start_date', 'date', requires=IS_DATE()),
Field('end_date', 'date', requires=IS_DATE()),
Field('start_time', 'time', requires = IS_TIME()),
Field('end_time', 'time', requires = IS_TIME()))
db.define_table(
'product',
Field('name', requires = IS_NOT_EMPTY()),
Field('price', 'double', default=0.00),
Field('description','text'),
Field('image', 'upload', default=''),
format = '%(name)s %(price)s')
because 1 sale has many product and each product belongs to sale, isn't it?
1 more thing please don't use id as your field name, because by default
web2py use it as a primary key.
taken from book :
- Each table must have a unique auto-increment integer field called "id"
- Records must be referenced exclusively using the "id" field.
ref:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Legacy-databases-and-keyed-tables
best regards,
stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.