Thanks Stifan, 

But that doesn't work either, because the product_id now displays in the 
sale form. I need to generate the sale_id first, and then have sow in the 
product table/form. Right now, it just shows up blank. 

On Wednesday, October 16, 2013 11:08:58 AM UTC-5, 黄祥 wrote:
>
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to