I think you data model is not sufficient to deal with your requirements.

The next model, including the calculation of the total, gives the options 
to add invoice lines (products).

def invoice_sum(line_ids):
    invoice_sum = db.invoice_line.price.sum()
    sum = db(db.invoice_line.id in 
line_ids).select(invoice_sum).first()[invoice_sum]
    return sum

db.define_table("invoice_line",
                Field("product"),
                Field("price", "integer"),
                format='%(product)s')

db.define_table("invoice",
                Field("name"),
                Field("invoice_line_ids", "list:reference invoice_line"),
                Field('total_price', compute=lambda r: 
invoice_sum(r['invoice_line_ids'])  ),
                format='%(name)s')

Hope this helps.

Richard D


On Wednesday, January 23, 2019 at 5:56:43 PM UTC+1, mostwanted wrote:
>
> I have a little invoice page in my app, but i also want people to be able 
> to invoice as many things as possible at once without having to keep saving 
> so many times, this is what i used:
>
> *MODEL*
> db.define_table("invoice", 
>                 Field("product", "list:string"),
>                 Field("price", "list:integer"),
>                 format='%(product)s')
>
> In my view i want these details displayed in an html table but they appear 
> in list format, how do i remove them from the list to display them 
> individually na d how do i sum up those in my price field?
>
> Mostwanted
>

-- 
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/d/optout.

Reply via email to