show/hide fields based on selection in openerp 7 - odoo

I have a selection field in openerp form
what I want is that when I select any value from this field , another field (which is hidden or invisible ) is shown automatically , based on the selected value.

I know that it is possible to show or hide a field checking or unchecking a boolean field in your view (e.g. needs_moreinfo).
<field name="moreinfo" attrs="{'invisible':['needs_moreinfo','=', false]}" />
I guess you could do the same, based on the IDs of the elements of your selection field. But it has to be hardcoded and you have to know in advance the ids in you DB...

Related

How to automatically fill a form field?

I would like to fill automatically a field when a certain value is selected in an other field. The columns concerned in my form :
I want when the value "Recrutement" in field [Nom Entreprise] is selected fill automatically field [Candidats Potentiels] with the word "Recrutement".
Should I create an event?

Control Source of a text boxes set to DCount function - Refresh issue

I'm setting the control source of text fields to return the value of a function (multiple fields with different filtering conditions). The form has a combo box with a list of years: when the user selects a specific year, the on change event triggers a refresh of all the fields.
My problem is the fields don't show any values unless after combo box's On Change events. I have to click on the form/fields before the values start showing up.
I tried to do form refresh & field's requery but doesn't work.
The text field's Control Source is set to:
=SummaryReport("Projects","G","1",[Forms]![frmSUMMARY_REPORT]![cmbYEARS])
What I'm trying to do is when the user selects a year from a drop down, the fields values are updated & displayed by the On Change event - currently they seem to be updated but are not showing unless I click on the screen and that's when values start showing up in each field.
The method to update calculated fields is Me.Recalc (or myForm.Recalc):
https://learn.microsoft.com/en-us/office/vba/api/access.form.recalc
Try this instead of .Refresh.
Also I think the better event to use is After Update instead of On Change for a combo box.

select nothing in many2one widget

I have a many2one field for which the selection of nothing (e.g. none, false, null) is a normal and valid state.
However the many2one widget in Odoo per default allows no empty selection. After a the record has been set, the user cannot unset the field with the normal widget.
Is there maybe some flag or Odoo feature that I can use to enable null selection?
As described in the comments, an empty value is selected when all text in the many2one widget is removed and one clicks outside.
So you can select from the drop down an item. When you remove part of the items name, it is still selected. When you remove all text in the field, the selection changes to empty. I was not aware of this because I am used to having an empty row at the top or bottom in the drop down that represents the null selection.
If you want to assign empty value for a Many2one field through code try this:
self._your_many2one_field = 0
And if you want to select blank in a Selection field try this:
self._your_selection_feild = False

Show / Hide Fields in Pentaho Report Based on User Input

I'm trying to show / hide fields in a Pentaho report based upon user input.
For example, I would like to offer a checkbox to the user saying "Show Product Count" -- if the box is unchecked, it will not include that column in the report.
Is there a way to do this in Pentaho Report Designer, perhaps using Parameters?
Thanks for the help -Monica
Yes, you have half the answer. Have a Yes/No Parameter "ShowProductCount"
Then on the conditional fields, go to the visible property, click the + formula icon and enter:
=IF([ShowProductCount]="Yes"; TRUE(); FALSE())
Simple! :)
There is more to this that the above answer. For example, if you don't want a field to show on the report, you pass the value mentioned above by Codek but the field will not show but the space for it will. The field has to be in a BAND and the band layout has to be set to ROW. Also, on the field you want to not display or display based on user selection, you have to set that field's style properties under size & position - invisible-consumes-space = false.

dijit.form.Combobox show label Instead of value

I've a dijit.form.Combobox field which uses a ItemFileReadStore to pull Its data.
Teh ItemFileReadStore has two attribute per Item value which will be used for form submission , generally Unique Integers and label which is Human Understandable String.
In ComboBox HTML I've done searchAttr="value" labelAttr="label"
When the ComboBox Shows the list it uses teh label Attribute.
But When the User selects one of the Item it shows the value of that Item.
What I want is , The value Attribute will Still be used for Form Submission. But the User will always see the label in the combobox Control.
alt text http://img822.imageshack.us/img822/6660/dijitcombo.jpg
e.g. I Want to Show The Label for value 3 (Admin) instead of 3
Use FilteringSelect instead of Combobox.
Note: ComboBox only has a single value that matches what is displayed while FilteringSelect incorporates a hidden value that corresponds to the displayed value.
I have tried the following.
var cmbObject = Registry.byId('combo dojo id'); var id =
cmbObject.item.<Code Property>;
You should check if item is null.