Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
5155 มุมมอง

What is the best way to add suppliers to all of my products? I have an Excel list with all of my products and skus, which are also already in Odoo, but the link in between is missing. What is the best way to link suppliers with products programmatically?

อวตาร
ละทิ้ง

let me confirm, do you want to add a unique supplier to all your products or you have a list suppliers with their products ?

ผู้เขียน คำตอบที่ดีที่สุด

OK guys, here is my solution in PHP:


function _createSupplierRelation($data){

$url = "xxx";

$db = "xxx";

$username = "xxx";

$password = "xxx";

$sku = $data[0];

$supplier_relation = $data[1];

$product_code = $data[2];

//connect

$common = ripcord::client("$url/xmlrpc/2/common");

$uid = $common->authenticate($db, $username, $password, array());

$models = ripcord::client("$url/xmlrpc/2/object");

//get odoo product id

$product = $models->execute_kw($db, $uid, $password,

'product.product', 'search_read',

array(array(array('default_code', '=', $sku)))

)[0];

//create supplier relation

$models->execute_kw($db, $uid, $password,

'product.supplierinfo', 'create',

array(array('name' => $supplier_relation, 'min_qty' => 0, 'delay' => 10, 'product_tmpl_id' => $product['id'], 'product_code' => $product_code))

);

}

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Step 1. Define suppliers and read their IDS

Step 2. Export + Reimport products CSV with added suppliers IDS
 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Michael Aigner,

Its better if you write a script to read your excel file(that must have product_name, supplier_name, and qty_supplied) and

create a record for each supplier for respective product(for object "product.supplier_info") and tag these records to the corresponding  product.

As there is a one2many for product.supplier_info in product.product, you can simply refer record to it.

Hope it help

อวตาร
ละทิ้ง
ผู้เขียน

Hi Pawan, that's exactly what I'm looking for! You don't have such a script by any chance? Thanks!

No micheal, i don't have any......

Related Posts ตอบกลับ มุมมอง กิจกรรม
Last purchase date แก้ไขแล้ว
2
ก.ย. 21
4018
Limit the product to a specific supplier แก้ไขแล้ว
2
มิ.ย. 17
4042
0
ต.ค. 15
3494
1
ก.พ. 25
7552
2
มี.ค. 15
5250