This is one way. You surely will find a more fast/enhanced ways by
searching web2py and Python features:

order_numbers = set([row.purchase_order.po_number for row in rows])
new_data = [[number,] + [row.item.id for row in rows if
row.purchase_order.po_number == number] for number in order_numbers]
new_data.insert(["purchase_order.po_number",])
max_fields = max([len(row) for row in new data])
csv_output = ""
for row in new_data:
    extra_fields = max_fields - len(row)
    csv_output += ",".join(row) + ","*extra_fields + "\n"

On 24 ene, 22:34, Adi <adnan.smajlo...@gmail.com> wrote:
> Thanks Alan for your advise, but I'm not sure how I would implement what
> you are suggesting?
>
> For now I use smartgrid's onpdate and oncreate events to update purchase
> order "items" field (type list:string) with all items for that particular
> order, but I hate this solution since it's computed value. This way I can
> product csv easier, but would rather flatten two tables into one at the
> time when the report is run.
>
> Thanks once again... and i'm still open for more suggestions, if anyone has
> any idea.
>
> Adi

Reply via email to