widget.autocomplet vs IS_IN_DB : formatting, filtering

57 views
Skip to first unread message

jean-mic...@meggitt.com

unread,
May 5, 2017, 11:50:18 AM5/5/17
to web2py-users
Hi,
I'm developping a tool to fill a pruchase request. Then it will be sent, sign , ...
First step : design the database (it's done, under MSSQL), draw the form, and fill it.
When the use arrive to the field "Supplier", sometime he knows it and its code, sometime he know about its name but not its code, sometime its not his job to know the suppliers.

In the first version of my app, I choose a
requires = IS_IN_DB(db(db.Suppliers.active=='Actif'),db.Suppliers.Code, '%(Code)s %(Name)s - %(City)s')
It works well (even with 4000 suppliers). BUT the user must know a supplier. He cannot leave this field empty, He cannot type something else.

In the second version, I discover the
widget=SQLFORM.widgets.autocomplete(request, db.Suppliers.Code)
It's goog to leave the field blank, or to type someting like "the company who absorb my old supplier" (INMAC / WSTORE).
BUT I get many inconvenients :
 * I cannot filter the active suppliers
 * I have to give the name of a field, I cannot build a combined field (like '%(Code)s %(Name)s - %(City)s')
 * It takes a while before print aech letter on the screen, after 2 letters the field lose the focus (I have to click in the field, add a letter, click again, add a letter), and (because the focus have been lost) if I type <bacspace> the system go a page back (the page site before I began to fill my form).

Probably the solution is between the two versions :
 * either IS_IN_BD, with on "IS_OPTIONNAL" option
 * or Autocomplete, but with the possibility to filter, to format the output, and to keep the focus while typing.

Thank you all for this nice tool and nice forum.
I discover web2py for 2 months, and my first app already makes some nice things => insert PurchaseRequests, update PR, validate PR, send PR to a buyer, store one or more attached to a PR, ... Next step : manage the workflow of the PR => who validate, in witch case, is there a condition, condition about the price, about the category of pieces (chemical, )

Dave S

unread,
May 5, 2017, 2:53:35 PM5/5/17
to web2py-users


On Friday, May 5, 2017 at 8:50:18 AM UTC-7, jean-mic...@meggitt.com wrote:
Hi,
I'm developping a tool to fill a pruchase request. Then it will be sent, sign , ...
[...]
Thank you all for this nice tool and nice forum.
I discover web2py for 2 months, and my first app already makes some nice things => insert PurchaseRequests, update PR, validate PR, send PR to a buyer, store one or more attached to a PR, ... Next step : manage the workflow of the PR => who validate, in witch case, is there a condition, condition about the price, about the category of pieces (chemical, )


I can't help you with the widget issue, but I can tell you web2py does have some workflow support.  See this post by Niphlod; the JobGraph stuff is in 2.14.6.

<URL: https://groups.google.com/d/msg/web2py/MzP4t6xevrc/9c6AKIxkVc8J>
 
/dps

Brian M

unread,
May 8, 2017, 8:41:06 PM5/8/17
to web2py-users
I've used bootstrap-select ( https://silviomoreto.github.io/bootstrap-select/examples/ ) to enhance standard select drop down lists and allow live searching. Would work well with your lists of <code> <name> <city> because the user can just type in part of any one of them and the options automatically filter down to only those that match.
Reply all
Reply to author
Forward
0 new messages