Thanks Adi,
Alex
On Sunday, September 15, 2013 5:33:36 AM UTC-7, Adi wrote:
>
> Untested, and modified sample:
>
>
>
> *Model:*
> db.define_table('purchase_order',
> Field('po_number', 'string', label=T('PO Number'), unique=
> True),
> Field('status', 'string', default='Processed',
> requires= IS_IN_SET(['Processed',
> 'Cancelled', 'On Hold', 'Shipped']), label=T('Status')),
> format='%(po_number)s',
> )
>
>
> *Controller:*
> def po_onupdate(form):
>
> # send an email, but only first time (when status changes to
> 'Shipped', additional record updates will not trigger an email)
> if ((form.vars.status == 'Shipped') & (form.record.status != 'Shipped'
> )):
> mail.send(to=['[email protected]',], subject='Order %s
> shipped. Date: %s' % (form.record.po_number, request.now), message="Long
> message")
> session.flash = ('Updated a %s' % (tbl_name)) + ' ' +
> (form.vars.po_number
> if tbl_name == 'purchase_order' else '')
>
> return
>
> def purchase_order():
> grid=SQLFORM.smartgrid(db.purchase_order, details=True, links_in_grid=
> True,
> paginate=20,
> sortable=True,
> onupdate = po_onupdate,
> editable = True,
> formstyle='bootstrap',
> user_signature=True,
> )
> return dict(grid=grid)
>
>
>
>
>
>
>
>
>
> On Sunday, September 15, 2013 12:29:04 AM UTC-4, Alex Glaros wrote:
>>
>> Adi, you had a tiny working example above
>>
>> *this works:
>> grid=SQLFORM.smartgrid(.....*
>>
>> is the data model available for that?
>>
>> I'm looking for any small self-contained working example of smartgrid
>> redirecting to edit
>>
>> thanks,
>>
>> Alex
>>
>> On Saturday, September 14, 2013 5:38:58 PM UTC-7, Adi wrote:
>>>
>>> Alex,
>>> Can you please clarify what model do you need? I can post the sample
>>> code but not sure what exactly do you need.
>>>
>>>
>>> On Fri, Sep 13, 2013 at 8:13 PM, Alex Glaros <[email protected]> wrote:
>>>
>>>> Adi,
>>>>
>>>> can you post the model for this?
>>>>
>>>> thanks,
>>>>
>>>> Alex Glaros
>>>>
>>>>
>>>> On Friday, December 23, 2011 9:44:17 AM UTC-8, Adi wrote:
>>>>>
>>>>> this works:
>>>>>
>>>>> grid=SQLFORM.smartgrid(db.**purchase_order, details=False,
>>>>> links_in_grid=True,
>>>>> maxtextlengths={'purchase_**
>>>>> order.po_number':15,},
>>>>> maxtextlength=30,
>>>>> paginate=20,
>>>>> sortable=True,
>>>>> orderby=dict(purchase_order=[~**
>>>>> db.purchase_order.modified_on]**, ),
>>>>> oncreate = dict(purchase_order=[po_**
>>>>> oncreation]),
>>>>> csv=False,
>>>>> ui='jquery-ui',
>>>>> links=dict(purchase_order=[**lambda row:
>>>>> A('Duplicate',
>>>>> _class='button',
>>>>> _href=URL('duplicate_purchase_**order',args=[row.id])), lambda row:
>>>>> A('Print',
>>>>> _class='button',
>>>>> _href=URL('print_all',args=[ro**w.id <http://row.id>]))]),
>>>>> user_signature=False, onupdate=auth.archive,
>>>>> )
>>>>>
>>>>>
>>>>> def po_oncreation(form1):
>>>>>
>>>>> auth.archive
>>>>>
>>>>> last_id = form1.vars.id
>>>>>
>>>>> row = db(db.purchase_order.id==last_**id).select().first()
>>>>>
>>>>> str_po_number = row.po_number + str(row.id)
>>>>> row.po_number = str_po_number
>>>>> row.update_record()
>>>>>
>>>>> #response.flash = 'Added a Purchase Order'
>>>>>
>>>>> session.flash = 'Added a Purchase Order'
>>>>> return
>>>>>
>>>>>
>>>>>
>>>>> --
>>>> 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.
>>>>
>>>
>>>
>>>
--
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.