0

Actualmente tengo esto:

$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"),
);

Quiero poder pasarle a Odoo 9 los impuestos pero por algún motivo odoo no me está recibiendo el dato (API nativa de odoo 9).

Se que el tax_id puede recibir varios ids pero no tengo claro como..

2 respuestas 2

1

Si no me equivoco el campo tax_id de la tabla order_line_id es del tipo many2many, asi que prueba haciendolo de esta manera:

Si tienes un valor:

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

Si tienes varios valores:

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

Quisiera ser mas exacto pero hace mucho que no uso Odoo y no tengo ejemplos a la mano.

Aqui esta lo indicado por su documentacion:

For a many2many field, a list of tuples is expected. Here is the list of tuple 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)

1
  • Muchas gracias! Lo malo es que actualmente se está haciendo con xmlrpcval y si no lo trabajo todo igual me salta un error 500 :( Pero ha sido muy útil !! Investigo más el 2 ago. 2017 a las 7:31
0

Había que darle formato de como pide odoo así:

$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"),
);

Tu Respuesta

Al pulsar en “Publica tu respuesta”, muestras tu consentimiento a nuestros términos de servicio, política de privacidad y política de cookies

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.