Odoo-mobile / framework

Odoo Mobile Framework
https://play.google.com/store/apps/dev?id=8607973775002477408
Other
327 stars 374 forks source link

getO2MRecord throwing exception on model #331

Open joseluiselp opened 7 years ago

joseluiselp commented 7 years ago

I'm trying to save a local column given a condition inside any of the O2M records, using the following code inside a OModel class.

@Odoo.Functional(method = "isRead", depends = {"notification_ids"}, store = true)
     OColumn is_read = new OColumn("Notification read", OVarchar.class).setLocalColumn();

  public boolean isRead(OValues values) {
         try {
             //First way to doit
             List<Integer> ints = values.toDataRow().getO2MRecord("notification_ids").getIds();
             for(Integer i : ints){
                 System.out.println(i+" id notification");
             }
              //Second way to doit
             List<ODataRow> notifications = values.toDataRow().getO2MRecord("notification_ids").browseEach();
             for(ODataRow r : notifications){
                 System.out.println(r.getInt("id")+" notification tal");
                 System.out.println(r.getBoolean("is_read"));
 .......

  }

Both ways are throwing a java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.odoo.core.orm.OO2MRecord. I'm using the latest version of your code, also tried with childs_id inside ResPartner model and I got the same results.

pathob commented 7 years ago

Some things...

@dpr-odoo / @dso-odoo: This project needs some maintanence and the pull requests need some reviews. Please feel responsible for this project again. Thanks.

ahbouchareb commented 4 years ago

Hi @pathob thank you for help,

so with that, can i for exemple give stock_inventory_line for each stock_inventory with O2M relation. if yes please give me an example