Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

two taxes in order line with xmlrpcval

By
jose freire
on 6/14/16, 6:49 AM 318 views

Hi,

We have this code:


 $line_array[$i]=new xmlrpcval(array(

'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"), 

),"struct");


We need to pass two values ​​in the field tax_id, because we need some order lines to have two taxes (VAT + RE)

It is possible? How?

0

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2983
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 6/14/16, 8:00 AM

yes you can !

tax_id from sale.order.line is a many2many field.

So you can use the notation 'tax_id': [(6, 0, your_taxes_ids)],


or in php

array(
    '...' => '...',
    'tax_id'=> array(array(6, 0, array(tax_id_1, tax_id_2, tax_id_3)))
)


you can also take a look here (same for the field categories) : https://www.odoo.com/forum/help-1/question/create-product-using-xmlrpc-php-issue-with-public-categ-ids-102914

0
jose freire
On 6/14/16, 9:21 AM

hi, 

thanks for your help.

I followed your advice and changed the code, but no order is created. This is the modified code:

 

foreach ($order_details as $details) {

    $erp_product_id = $product->check_specific_product($details['product_id'],$details['product_attribute_id'],$userId, $client);

    $total_price = $details['unit_price_tax_excl'];

    $reduction_rate_tax_excl='0';

    $tax_id = Db::getInstance()->getRow("SELECT `id_tax` from `" . _DB_PREFIX_ . "order_detail_tax` where `id_order_detail`=" . $details['id_order_detail'] . "");

    if ($tax_id['id_tax'] > 0) {

        $erp_tax_id = $tax->check_specific_tax($tax_id['id_tax'], $client, $userId);

    }

    else

        $erp_tax_id = -1;

    $line_array[$i]=new xmlrpcval(array(

        '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' => array(array(6, 0, array('1', '24'))),

    ),"struct");

    $i = $i+1;

}

$msg1 = new xmlrpcmsg('execute');

$msg1->addParam(new xmlrpcval(Configuration::getGlobalValue("ErpDatabase"), "string"));

$msg1->addParam(new xmlrpcval($userId, "int"));

$msg1->addParam(new xmlrpcval(Configuration::getGlobalValue("ErpPassword"), "string"));

$msg1->addParam(new xmlrpcval("force.done", "string"));

$msg1->addParam(new xmlrpcval("create_n_confirm_order", "string"));

$msg1->addParam(new xmlrpcval($order_data, "struct"));

$msg1->addParam(new xmlrpcval($line_array, "array"));

$response = $client->send($msg1); 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/14/16, 6:49 AM
Seen: 318 times
Last updated: 6/14/16, 9:22 AM