Skip to content

getO2MRecord throwing exception on model #331

@joseluiselp

Description

@joseluiselp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions