Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSelection Read-Only #145

Closed
sylwek845 opened this issue Apr 24, 2016 · 3 comments
Closed

OSelection Read-Only #145

sylwek845 opened this issue Apr 24, 2016 · 3 comments

Comments

@sylwek845
Copy link

Hi,

I've asked you few months ago about OSelection and you gave me this tutorial https://dharmangsoni.odoo.com/blog/blog-1/post/working-with-oselection-field-widget-4
but I still have problem when I disable edit mode and I want read only mode. I have
java.lang.ArrayIndexOutOfBoundsException: length=13; index=-1 but it is working fine when edit mode is enabled. any ideas how to fix this ?

@dpr-odoo
Copy link
Collaborator

@sylwek845

can you explain more and please provide full error trace you are getting.

@sylwek845
Copy link
Author

so I want to display OColumn on_switch = new OColumn("On Switch", OSelection.class).addSelection("1", "Piezo Switch").addSelection("2", "Reed Switch"); as read-only. in my layout I have <odoo.controls.OField android:layout_width="match_parent" android:layout_height="wrap_content" app:fieldLabelColor="@color/theme_secondary" prefix:fieldName="on_switch" app:fieldTextAppearance="?android:textAppearanceMedium" app:iconResource="@drawable/ic_action_notes_content"></odoo.controls.OField> and it is working fine when I set editmode to true, but I when I set it to false the app crashed with following Exception 04-25 18:42:40.522 32240-32240/com.odoo E/AndroidRuntime: FATAL EXCEPTION: main Process: com.odoo, PID: 32240 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.odoo/com.odoo.addons.Equipment.EquipmentDetails}: java.lang.ArrayIndexOutOfBoundsException: length=13; index=-1 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:211) at android.app.ActivityThread.main(ActivityThread.java:5373) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) Caused by: java.lang.ArrayIndexOutOfBoundsException: length=13; index=-1 at java.util.ArrayList.get(ArrayList.java:310) at odoo.controls.OSelectionField.setValue(OSelectionField.java:386) at odoo.controls.OField.initControl(OField.java:272) at odoo.controls.OForm.initForm(OForm.java:170) at odoo.controls.OForm.initForm(OForm.java:139) at com.odoo.addons.Equipment.EquipmentDetails.setupActionBar(EquipmentDetails.java:109) at com.odoo.addons.Equipment.EquipmentDetails.onCreate(EquipmentDetails.java:91) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)  at android.app.ActivityThread.access$800(ActivityThread.java:156)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:211)  at android.app.ActivityThread.main(ActivityThread.java:5373)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) 

@dpr-odoo
Copy link
Collaborator

Fixed 6aa86cd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants