Skip to Content
Menu
This question has been flagged
2 Replies
2538 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?

Avatar
Discard
Best Answer

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

Avatar
Discard
Author Best Answer

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); 

Avatar
Discard