DeBortoliWines / openerp-java-api

A Java API to connect to OpenERP and manage data using the XMLRPC interface.
Apache License 2.0
38 stars 71 forks source link

Error when executeWorkflow is called #10

Closed bwilmus closed 9 years ago

bwilmus commented 9 years ago

When I call executeWorkflow I have the following error message: A method named "executeWorkflow" is not declared in any enclosing class nor any supertype, nor through a static import.

Here is a summary of the context where the method is called:

import com.debortoliwines.openerp.api.Session; import com.debortoliwines.openerp.api.*; import com.debortoliwines.openerp.api.Row;

ObjectAdapter objectAdOrder = openERPSession.getObjectAdapter("sale.order"); String[] NewTuple = new String[]{"partner_id", "date_order", "client_order_ref"}; Row newObject = objectAdOrder.getNewRow(NewTuple); newObject.put("partner_id", partner_id); newObject.put("date_order", current_time); newObject.put("client_order_ref", booking_external_ref); objectAdOrder.createObject(newObject); objectAdOrder.executeWorkflow(newObject, "order_confirm");

I am using the 1.5 version of your api. Thanks for your help!

flotho commented 9 years ago

Hy bwilmus,

You have to split your code in 2 sequences. First create the object and get the id The make a filter on the id with a tuple that get name, id and state and THEN make the execute workflow. Remember that it's an asynchronous conversation, once the object is created, you only have a image of the object before it exists in Odoo. The tuple in your java code won't be associated to an Odoo Object.

That's why you MUST recall a searchAndreadObject so that the object you'll try to manipulate will be "synchronized".

Hope it could help

bwilmus commented 9 years ago

Hi Flotho,

I have tried what you propose but it seems that your solution doesn't solve the problem. I have the feeling that I miss some class import or do not call executeWorkFlow on the right object.

This error is raised by Pentaho data integration before running the process when the class syntax is checked.

The error message says: A method named "executeWorkflow" is not declared in any enclosing class nor any supertype, nor through a static import

flotho commented 9 years ago

Hy bwilmus,

here is a piece of code that woks with openerp 7 and lib 1.4 :

import com.debortoliwines.openerp.api.*;
import java.util.Date;

private Session openERPSession = null;
private com.debortoliwines.openerp.api.Row  accountToUpdate;
private Integer model_id ;
private Boolean success= false;
private Object[] r;
private com.debortoliwines.openerp.api.Row  orderToValidate;

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
    r = getRow();
    if (r == null) {
        setOutputDone();
        return false;
    }
    try {
        if (first) {        
            first=false;
        }
            r = createOutputRow(r, data.outputRowMeta.size());
            ObjectAdapter objectAd = openERPSession.getObjectAdapter("sale.order");

            FilterCollection filters = new FilterCollection();
            Long order_id = get(Fields.In, "order_id").getInteger(r);

            String order_number = get(Fields.In, "effective_piece").getString(r);
            //Filtre sur la facture déjà créée
            filters.add("id","=", order_id );

            String[] tuple = new String[]{"id","origin","company_id", "name"};
            RowCollection orders = objectAd.searchAndReadObject(filters, tuple);           

            if (orders.isEmpty()){
                //Alors on créé
                logError("Devis  " +  order_number + "Non trouvé");
            }else{
                //Sinon on met à jour          
                logBasic("Le devis/commande " + order_number + " existe");
                orderToValidate =  (com.debortoliwines.openerp.api.Row) orders.get(0);

                objectAd.executeWorkflow(orderToValidate, "order_confirm");
            }

            putRow(data.outputRowMeta, r);
            return true;
    } catch (Exception e) {
            logError("erreur : Exception e" + e.getMessage());
            setErrors(1);
            success= false;
    }
    return true;    
}

public boolean init(StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface)
{
    if (parent.initImpl(stepMetaInterface, stepDataInterface)){
        try{
            openERPSession = new Session("localhost", 8069, "base", "admin", "admin");
            openERPSession.startSession();
            return true;
        }
        catch(Exception e){
            logError("Error connecting to TestDB: "+ e.getMessage());
            setErrors(1);
            stopAll();
        }
    }
    return false;
}

Could you also try on v7 and lib 1.4 to start with a stable configuration,

Hope it could help,

flotho commented 9 years ago

Hy @bwilmus didi you solved your issue?

bwilmus commented 9 years ago

Yes, this was a problem of Java JRE version.