How to enable "typing" on selection widget in Odoo? - odoo-8

I have used a selection widget in my program and it has lot of items in the drop down. Is there any method to enable typing on it so user can select item easily. (just like making a JComboBox editable in java)

If you are using the many2one field with the widget="selection", you can select the selection box by clicking it and you start typing what you are looking for, the box change to the value that you are writing. By the way, you must write it fast and the drop down must not be deployed.
The other option is to use a many2one field without the selection widget. You can install the community module web_m2x_options and use the limit attibute to avoid the option "Search More". Like this you can write in the box to find the elements. For example, you can show until 10 elements without the option "Search More" with this example:
<field name="example_id" options="{'create': False, 'create_edit': False, 'limit': 10}" />

Related

Rails: disable input tag upon selection from a dropdown menu

Scenario/Context
I've got a drop down menu with two input elements underneath.
From the dropdown menu, are names of companies (with values set to the respective company id's), and another prompt to Add a new company.
If the option to Add a new company is selected from the dropdown, then the user is to fill out the 2 input field elements (i.e. company name and company email).
Otherwise, if an available company is selected from the dropdown,
then the 2 input fields (for company name and email are to be disabled).
My question
Is this possible to do without an AJAX call if I want things to happen without a page refresh?
Can anyone suggest some other alternatives??
Many thanks!
That is absolutely possible, though you'd need to use some JavaScript to make it happen and load a bit more data to the DOM on the initial page load.
For each option in your company select dropdown, add a data attribute for the name and email.
Then, watch that dropdown for the change event in JavaScript. Whenever that event is fired, if the data-company-name and data-company-email attributes are defined for the selected option, disable the input fields and populate them with those values. If those data attributes are not defined for the option (likely only for your 'Add a new company' option), then clear the values from the input fields and enable them.

Custom drop-down as an item in a kendo tree

I am trying to create an item that is a button "show more" and when you press on it you can show a kind of context menu / drop down that all of the items in that drop down are with checkboxes and there is a search component in it too, so you can search some items in the dropdown by their name. For example: (instead of "c++,c#,Object c" it's should show "show more", i.e. static text)
I tried to use kendoContextMenu. But I don't know if it's could work because the problem with context menu is that when I will click on a checkbox the menu will close. Please advise me of a way to do that or if you have an example of code. Thanks!
The MultiSelect component might be a good starting point
https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect.
My understanding is that MultiSelect does not have a "select more than one at a time in dropdown" feature.
You might consider using a pop up window and within that implement your own custom ui that features everything you want
search term box
scrolling list of selected and selectable items
accept or cancel changes in selection
Regarding your dojo that extends drop down list, I can't code the extension for you. However, changing the dataSource assignment to a setDataSource call will populate the extension component according to the template.
// kendo.ui.DropDownList.fn.dataSource = options.testItemSource;
me.setDataSource(options.testItemSource);

Win32 ComboBox: Programmatically select (highlight) string from the list, without update the edit control

My goal is to Programmatically select items from the List of the combo box, but without updating the edit control. The same can be achieved with the mouse. E.g. when you drop down and hover an item from the list, that item is highlited. And that is all. If you want to select in it the combo box (e.g. move it to the edit control) - you must click on the LisBox.
I tried with CB_SELECTSTRING. But it automatically updates the ComboBox edit control with the selected text which is not what I want. I want to do this using raw Win32 or VB6
Thanks
There is a big difference between highlighting an item in the drop-down list and actually selecting an item to make it active. CB_SELECTSTRING selects an item, as its name implies. But there is no official ComboBox API to highlight an item, though.
However, you can display the drop-down list manually (CB_SHOWDROPDOWN), and either:
move the mouse over the desired item so the list can perform hot-tracking logic.
manipulate the list directly. Use CB_GETCOMBOBOXINFO or GetComboBoxInfo() to get the list's HWND, and then send LB_SETCURSEL to it.

Add record with ID, selecting NAME from another table

Can anyone, please, help me with Libreoffice Base form creation?
I have the following tables:
And I'm trying to add a form to enter new RESOURCES record with the following fields: [RESOURCE_NAME], [CURRENCY_NAME] and [AMOUNT]. But after 10+ tries I have not succeeded. I have tried adding it via wizard, selecting RESOURCES as main form and CURRENCIES as subform and vice versa. I have tried VIEWS and forms based on them. These tries only gave to me or no possibility to enter new record, either creation of the new CURRENCY.
I don't need to create new currency via this form, I only want to enter new Resource (only enter once, not to modify, not to delete). Since I don't want to remember all the ID's I want to select currency name via DropDown list.
Can anyone provide instructions about how to do it, please?
Thanks.
You do not need a subform for this - just create your form document with RESOURCES as the main form (only form).
You will need a listbox to enter the currency item. A listbox has two fields, a display field and a field that is saved in the table. You will set it up to display CURRENCY_NAME and store CURRENCY_ID.
When you create a listbox, the wizard that pops up may get you what you want. If the wizard falls short:
Make sure the form document is open in design mode: on the "Form Controls" toolbar, the leftmost/topmost icon of a pencil with a triangle should be depressed. If this icon is grayed out, close your document, right-click on its name and choose "Edit".
Right-click on the listbox and choose "Control"; this will open the properties window
On the tab "Data" change the "Type of list contents" to "Sql"
In the field "List content" enter SELECT "CURRENCY_NAME", "CURRENCY_ID" FROM "CURRENCIES" ORDER BY "CURRENCY_NAME"
The Bound Field should default to 1. If it isn't 1, change it to 1.
Close the properties window and save your form. It should work as you want now.
If you want a listbox inside a tablegrid: after you create the table, with the form in edit mode, right-click on the column name you want to change and choose "Replace with" and then "listbox".
Edited to include comment by OP about bound field needing to be 1

Is it possible to disable one of the options among a group of radio buttons?

I have a radio button control with two items in it.
<xforms:select1 ref="add-delete" appearance="full">
<xforms:item>
<xforms:label>Add</xforms:label>
<xforms:value>A</xforms:value>
</xforms:item>
<xforms:item>
<xforms:label>Delete</xforms:label>
<xforms:value>D</xforms:value>
</xforms:item>
</xforms:select1>
I want to disable only the radio button 'Delete' and not the radio button 'Add' on condition X. How can I carry out this ?
I tried using class attribute with xforms:item but that is not working. Is there any other way to do this ?
Good question. And unfortunately, this isn't as easy to do as it should:
If you just wanted the delete radio button to be hidden, instead of disabled, you can replace the <xforms:item> for the "Delete" by an <xforms:itemset ref="…"> that you bind to a node which you make non-relevant when you want that radio button not to show. But you can't use that same technique to disable the radio button by binding the itemset to a node you make read-only. (And yes, it would be good if you could do that.)
As it stands, I think you'll need to:
Create 2 <xforms:select1>. One for "Add", one for "Delete", so you can make the second one readonly upon some condition.
To make it readonly, but not have the "Add" be read-only as well, you need to bind them to 2 separate node.
If you want to have 1 node with either A or D, you need to create a calculate to populate that node based on the 2 values.
You want the values to be exclusive, and they won't be if you have two <xforms:select1>, so you need to deselect "delete" when "add" is selected reacting to xforms-select, and vice versa.
In the model, you would have:
<xforms:instance>
<instance>
<add/>
<delete/>
<add-delete/>
<delete-enabled>true</delete-enabled>
</instance>
</xforms:instance>
<xforms:bind ref="add-delete" calculate="string-join((../add, ../delete), ' ')"/>
<xforms:bind ref="delete" readonly="../delete-enabled = 'false'"/>
And in the view:
<xforms:select1 ref="instance()/add" appearance="full">
<xforms:item>
<xforms:label>Add</xforms:label>
<xforms:value>A</xforms:value>
</xforms:item>
<xforms:setvalue ev:event="xforms-select" ref="instance()/delete"/>
</xforms:select1>
<xforms:select1 ref="instance()/delete" appearance="full">
<xforms:item>
<xforms:label>Delete</xforms:label>
<xforms:value>D</xforms:value>
</xforms:item>
<xforms:setvalue ev:event="xforms-select" ref="instance()/add"/>
</xforms:select1>
And see this Gist for the full source of this example.

Resources