0

I'm using a Odoo service to get my data of web. In main class I have a method to read a data:

public void OdooRead() {
    OdooService.getCustomers(odoo, "myCallbackFunction");
}

So, I did create a other class to make this service:

public class OdooService {

    public static final String[] odooAllFields = {"id","name","customer_account_number","customer_group_id","segment_id","subsegment_id","economic_group_id","type_stablishment_id","street","street2","final_user","final_taxpayer","cnpj_cpf","inscr_est","ccm","cnae","phone","phone_extension","mobile","fax","email","email_extra","website","lang"};

    public static List<Customer> getCustomers(OdooClient client, "myCallbackFunction") {

        List<Customer> list = new ArrayList<>();

        ODomain domain = new ODomain();
        OdooFields odooFields = new OdooFields();
        odooFields.addAll(odooAllFields);

        String sorting = "id ASC";
        int offset = 0;
        int limit = 0;

        client.searchRead("res.partner", domain, odooFields, offset, limit, sorting, new IOdooResponse() {
        @Override
        public void onResult(OdooResult result) {
            // HERE I WANTS CALL THE CALLBACK FUNCTION TO MAIN!
        }
    });

        return list;
    }

}

So, when the method returns the result of search on web, I wants send a callback function to main, with the list of results as parameter. And while this, the main class runs normally, and when method finish I refresh user interface.

Augusto
  • 3,825
  • 9
  • 45
  • 93

0 Answers0