Pass one or several tax_id to odoo 9 (to your native api)

0

I currently have this:

$line_array_product = array(
    'order_id' => new xmlrpcval($erp_order_id, "int"),
    'type' => new xmlrpcval('Product', "string"),
    'product_id' => new xmlrpcval($erp_product_id, "int"),
    'price_unit' => new xmlrpcval($total_price, "string"),
    'product_uom_qty' => new xmlrpcval($details['product_quantity'], "string"),
    'name' => new xmlrpcval(str_replace('+', ' ', urlencode($details['product_name'])), "string"),
    'discount' => new xmlrpcval($reduction_rate_tax_excl, "string"),
    'tax_id' => new xmlrpcval($erp_tax_id, "string"), ## <-- Problema aqui
    'ecommerce_channel' => new xmlrpcval('prestashop', "string"),
);

I want to be able to pass Odoo 9 the taxes but for some reason odoo is not receiving the data (native API of odoo 9).

I know that the tax_id can receive several ids but I'm not sure how ..

    
asked by Daniel Díaz 01.08.2017 в 12:33
source

2 answers

0

You had to format it as you ask odoo like this:

$tax_id = new xmlrpcval(
    array(
        new xmlrpcval(
            array(
                new xmlrpcval(6, "int"),
                new xmlrpcval(0, "int"),
                new xmlrpcval(
            array(
                new xmlrpcval($erp_tax_id, "int"),
            ), "array")
        ), "array")
    ), "array");


$line_array_product = array(
    'order_id' => new xmlrpcval($erp_order_id, "int"),
    'type' => new xmlrpcval('Product', "string"),
    'product_id' => new xmlrpcval($erp_product_id, "int"),
    'price_unit' => new xmlrpcval($total_price, "string"),
    'product_uom_qty' => new xmlrpcval($details['product_quantity'], "string"),
    'name' => new xmlrpcval(str_replace('+', ' ', urlencode($details['product_name'])), "string"),
    'discount' => new xmlrpcval($reduction_rate_tax_excl, "string"),
    'tax_id' => new xmlrpcval($tax_id, "string"),
    'ecommerce_channel' => new xmlrpcval('prestashop', "string"),
);
    
answered by 22.08.2017 / 10:03
source
1

If I'm not wrong, the tax_id field in table order_line_id is type many2many , so try doing it this way:

If you have a value:

'tax_id' = [(0,0,{'id_tax_en_tabla_m2m': 1})]

If you have several values:

'tax_id' = [(0,0,{'id_tax_en_tabla_m2m': 1}),(0,0,{'id_tax_en_tabla_m2m':2}),...]

I would like to be more exact but I have not used Odoo for a long time and I do not have examples at hand.

Here is what is indicated by your documentation:

  

For a many2many field, a list of tuples is expected. Here is the list of tuples that are accepted, with the corresponding semantics:

     

(0, 0, {values}) link to a new record that needs to be created with the given values dictionary

     

(1, ID, {values}) update the linked record with id = ID (write values on it)

     

(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)

     

(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)

     

(4, ID) link to existing record with id = ID (adds a relationship)

     

(5) unlink all (like using (3, ID) for all linked records)

     

(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4, ID) for each ID in the list of IDs)

    
answered by 01.08.2017 в 17:44