В настоящее время я работаю над приложением для управления запасами и хочу изменить заказ на доставку, для этого я должен также изменить продукты в накладной, когда я изменяю строку, т.е. работает идентификатор, но когда я вставляюмассив идентификаторов работает, но с аномалией в том, что таблица продуктов (sale.order.line) изменяется, но все строки продуктов, содержащиеся в поставке, принимают одинаковые значения
, вот код:
EditBL: function (sale, callback) {
db.connect(function (err) {
if (err) {
return console.log(err);
}
var inParams = [];
var tabId = [];
//array for retrieve ids to update
for (let i = 0; i < sale.products.length; i++) {
tabId[i] = sale.products[i].id;
}
inParams.push(tabId);
for (let i = 0; i < sale.products.length.length; i++) {
amount_tax = sale.products[i].amount_tax;
id_tax = sale.products[i].price_tax * 1;
price_subtotal =sale.products[i].price_unit*sale.products[i].product_uom_qty;
price_tax = (price_subtotal * amount_tax) / 100;
inParams.push({
'name': 'Produit #' + sale.products[i].product_id,
'product_uom_qty': sale.products[i].product_uom_qty,
'price_unit': sale.products[i].price_unit,
'product_id': sale.products[i].product_id,
"tax_id": [6, 0, [id_tax]]],
"price_subtotal": parseFloat(price_subtotal),
"price_total": parseFloat(price_subtotal) + parseFloat(price_tax),
"price_tax": parseFloat(price_tax),
});
}
var params = [];
params.push(inParams);
db.execute_kw('sale.order.line', 'write', inParams, function (err, value) {
if (err) {
console.log(err);
}
console.log(value);
return value;
});
});} `