baumgaro / Odoo-Talend-Component

Input and Output Component for Talend Open Studio (Dataintegration)
31 stars 18 forks source link

How to put many2many data #5

Open Gregoire42 opened 10 years ago

Gregoire42 commented 10 years ago

Hello I want to create a product with the component. I don't manage to put the taxes_id.

How can I do? I tried that : new Object[]{"6","0", new Object[]{"2"}}

baumgaro commented 10 years ago

Hello! I just debugged this - and found out it is not possible yet - since this API function putMany2ManyValue of the core library in the Talend-Component is not used yet: https://github.com/xsalefter/openerp-java-api/blob/master/src/main/java/com/debortoliwines/openerp/api/Row.java --> Java Code-Example with the many2many field "category_id" in res_partner // Update Partner

com.debortoliwines.openerp.api.FilterCollection filters = new com.debortoliwines.openerp.api.FilterCollection();
filters.add("id","=",6);
com.debortoliwines.openerp.api.RowCollection partners = partnerAd.searchAndReadObject(filters, new String[]{"name","email","category_id"});

com.debortoliwines.openerp.api.Row TestRow = partners2.get(0);
TestRow.put("email", "test2email@gmail.com");
TestRow.putMany2ManyValue("category_id",new Object[]{"1","2"},false);

I will add this function to the OpenERP-Talend-Component as soon as there is time - probably in the next two weeks.

Robert

jeremiedelobel commented 9 years ago

Hello Robert,

do you have implement this fonctionnality ?

I have problem to use it for object "account.invoice.line" and the Many2Many fields "invoice_line_tax_id". Can you help me !

com.debortoliwines.openerp.api.Session openERPSession = new com.debortoliwines.openerp.api.Session(context.odoo_host, Integer.valueOf(context.odoo_port), context.odoo_database_name, context.odoo_user, context.odoo_password);
    openERPSession.startSession();
    System.out.println(openERPSession.getServerVersion());

ObjectAdapter invoicelineAd = openERPSession.getObjectAdapter("account.invoice.line"); // creation de l'objet
FilterCollection line_filter = new FilterCollection(); // filtre déclaration
line_filter.add("id","=","208"); // filtre définition
RowCollection invoice_lines = invoicelineAd.searchAndReadObject(line_filter, new String[]{"id","invoice_line_tax_id"}); // récupération de champs

com.debortoliwines.openerp.api.Row invoice_lines_tax = invoice_lines.get(0); // récupération de l'objet de ligne

Hashtable <String, Object> tax_id = new Hashtable<String, Object>();
      //tax_id.put("id","208");
      tax_id.put("invoice_line_tax_id","[(0,0,{4})]");
      Collection<Object> c = tax_id.values();
      Object[] objectArray = c.toArray();

//invoice_lines_tax.putMany2ManyValue("invoice_line_tax_id", new Object[]{"4"} ,false);
invoice_lines_tax.putMany2ManyValue("invoice_line_tax_id", objectArray ,false);

All implementation have no result, no change on the invoice line.

Jeremie

baumgaro commented 9 years ago

Hello Jérémie,

unfortunatly there was no time for integrating the many2many function. If you do it, consider using the newer Version of https://github.com/xsalefter/openerp-java-api

Anyway - I think you probably didn't do in your code - the commit:

boolean success = invoicelineAd.writeObject(invoice_lines_tax, true);

Hope this helps! Would appreciate if somebody is doing this many2many feature - I will merge it into the master.

My considerations for this - we could implement it as a just one row add function. This way we could use the Talend flow and add each many2many relation with one row in the flow.

The "append" attribute should then be "true" - e.g.

TestRow.putMany2ManyValue("category_id",new Object[]{"1","2"},true);

Robert

jeremiedelobel commented 9 years ago

Hi Robert,

sorry for my late reply. Thank you for all that informations In fact I had no commits.

I could also use the action on the workflow with version 1.4 of the API

Best regards

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ Jérémie DELOBEL Responsable de pratique Talend Talend practical leader

Savoir-faire Linux | ISO 9001 + ISO 14001 | Talend Gold Partner 7275 Saint-Urbain, bureau 200 Montréal, QC H2R 2Y5 Tel : + 1 (514) 276 5468, ext. 308

----- Mail original ----- De: "Robert Baumgartner" notifications@github.com À: "baumgaro/Odoo-Talend-Component" Odoo-Talend-Component@noreply.github.com Cc: "Jérémie DELOBEL" jeremie.delobel@savoirfairelinux.com Envoyé: Jeudi 6 Novembre 2014 12:30:53 Objet: Re: [Odoo-Talend-Component] How to put many2many data (#5)

Hello Jérémie,

unfortunatly there was no time for integrating the many2many function. If you do it, consider using the newer Version of https://github.com/xsalefter/openerp-java-api

Anyway - I think you probably didn't do in your code - the commit:

boolean success = invoicelineAd.writeObject(invoice_lines_tax, true);

Hope this helps! Would appreciate if somebody is doing this many2many feature - I will merge it into the master.

My considerations for this - we could implement it as a just one row add function. This way we could use the Talend flow and add each many2many relation with one row in the flow.

The "append" attribute should then be "true" - e.g.

TestRow.putMany2ManyValue("category_id",new Object[]{"1","2"},true);

Robert

— Reply to this email directly or view it on GitHub .