Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    อสังหาริมทรัพย์
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    ปรึกษา
    • สำนักงานบัญชี
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • เหล็ก
    • เฟอร์นิเจอร์
    • อาหาร
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • ระบบพลังงานแสงอาทิตย์
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    อื่น ๆ
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

Update Quantity on Hand via XMLRPC and PHP

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
14300 มุมมอง
อวตาร
Thien Nguyen

Using Odoo v8 local installation

I'm brand new to Odoo and XMLRP. I want to update the quantity on hand of stock using XMLRPC and PHP code, just as if I had clicked the "Apply" button on the "Update Product Quantity" dialog that is reached via, e.g. Warehouse -> Products /<Select Product>/ Inventory tab -> (Quantity on Hand)Update

After much searching, based on the view found by clicking through Settings -> User Interface -> Views -> stock.change.product.qty
as well as the example in the following post:
http://thierry-godin.developpez.com/openerp/openerp-xmlrpc-php-en/
I tried the following PHP:


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php

set_include_path(get_include_path() . PATH_SEPARATOR . '/home/odootst/xmlrpc/lib/');
require_once( 'xmlrpc.inc' );
require_once( 'xmlrpcs.inc' );
require_once( 'xmlrpc_wrappers.inc' );

$GLOBALS['xmlrpc_internalencoding']='UTF-8';
 
$user = 'admin';
$password = 'acmePass123';
$dbname = 'acme123';
 
$server_url = 'http://192.168.4.2:8069'; 
$conn = new xmlrpc_client($server_url . "/xmlrpc/common");
$conn->setSSLVerifyPeer(0);
 
$c_msg = new xmlrpcmsg('login');
$c_msg->addParam(new xmlrpcval($dbname, "string"));
$c_msg->addParam(new xmlrpcval($user, "string"));
$c_msg->addParam(new xmlrpcval($password, "string"));
$c_response = $conn->send($c_msg);
 
if ($c_response->errno != 0){
    echo  '<p>error : ' . $c_response->faultString() . '</p>';
}
else{
    $uid = $c_response->value()->scalarval();
    
    $values = array ( 
        'product_id'=>new xmlrpcval(8,"int"), 
        'new_quantity'=>new xmlrpcval(7.0, "float"), 
        'location_id'=>new xmlrpcval(12,"int")                         
        ); 
    
    $client = new xmlrpc_client($server_url . "/xmlrpc/object");
    $client->setSSLVerifyPeer(0);
 
    $msg = new xmlrpcmsg('execute'); 
    $msg->addParam(new xmlrpcval($dbname, "string")); 
    $msg->addParam(new xmlrpcval($uid, "int")); 
    $msg->addParam(new xmlrpcval($password, "string")); 
    $msg->addParam(new xmlrpcval("stock.change.product.qty", "string")); 
    $msg->addParam(new xmlrpcval("change_product_qty", "string"));  
    $msg->addParam(new xmlrpcval($values, "struct")); 
    $response = $client->send($msg);
 
    if ($response->faultCode()){
        echo $response->faultString();
    } else {   
      echo '<h2>Update Completed Successfully</h2>';
    }
}
?>

I am able to connect to the system with the above code, but I get an error trying to access the database (full traceback not shown for brevity):

ERROR acme123 openerp.sql_db: bad query:  SELECT "stock_change_product_qty"."write_uid","stock_change_product_qty"."new_quantity","stock_change_product_qty"."id","stock_change_product_qty"."product_id","stock_change_product_qty"."write_date","stock_change_product_qty"."create_date","stock_change_product_qty"."create_uid","stock_change_product_qty"."location_id","stock_change_product_qty"."lot_id" FROM "stock_change_product_qty"
                        WHERE "stock_change_product_qty".id IN ('new_quantity', 'location_id', 'product_id')  ORDER BY "stock_change_product_qty"."id" 
                   
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
DataError: invalid input syntax for integer: "new_quantity"
LINE 2: ...          WHERE "stock_change_product_qty".id IN ('new_quant...

The error message itself is clear, but does not give me any idea where to go next. As I am only guessing at the proper calls to make in the code, I clearly have called something incorrectly. I am unsure of the following:

1) What is the correct method to call
2) What is the correct model to specify (I don't know how to find the model that is associated with a method)
3) The correct parameter list for the call

If anyone can even just point me in the right direction, that would be much appreciated. Thanks for any help you can give.

0
อวตาร
ละทิ้ง
Nicholas Burdick

Thien, Did you ever figure this out? I'm working on a similar situation, but using straight python to import new products into a system. I'd like to bring the qty in as well, but it doesn't work when trying to update Product.product or product.template directly. I think the answer is to do a stock move, but i'm not sure.

OdooBot
Sorry for the extremely late reply. I am traveling in some remote places and have spotty internet connection. I gave up trying to do this via xmlrpc and chose the (admittely) dangerous route of updating the database directly.

On July 6, 2015 4:25:11 PM EDT, Nicholas Burdick <nick@openerpacademy.com> wrote:

Thien, Did you ever figure this out? I'm working on a similar situation, but using straight python to import new products into a system. I'd like to bring the qty in as well, but it doesn't work when trying to update Product.product or product.template directly. I think the answer is to do a stock move, but i'm not sure.

--
Nicholas Burdick
Sent by Odoo S.A. using Odoo about Forum Post Update Quantity on Hand via XMLRPC and PHP

--
Thien Nguyen
อวตาร
Heinzer Leuchten & Design
คำตอบที่ดีที่สุด

Thien's initial request is quite old. Since I was struggling for quite a while now on the same issue, I'd like to share my solution anyways.


To update the quantity of a product via xmlrpc, proceed as follows:

1) Get hold of the product ID in Odoo, e.g. by searching 'product.product' (I use the field 'default_code' to map Odoo products with my own product model)

2) Create an instance of the wizard 'stock.change.product.qty' with the desired values for the fields 'product_id' and 'new_quantity'. You may optionally provide 'location_id' (and also 'lot_id'). If omitted, the quantity is booked to the default location 'Stock'.

3) Call the method 'change_product_qty' on the wizard.

I use the excellent Java API provided here: https://github.com/DeBortoliWines/openerp-java-api along with Odoo 8.0. The relevant code looks like this:


public void updateQuantity(Product product) {
try {
// 1) fetch Odoo product and location ID
int productId = getOdooProductId(product);
if (productId <= 0) {
throw new OdooIntegrationException(format(
"product %s with id %s not found in Odoo", product.getName(), product.getId()));
 }
 int locationId = getLocationId(product);

 // 2) create wizard instance
 ObjectAdapter wizardAdapter = odooSession.getObjectAdapter("stock.change.product.qty");

 Row wizard = wizardAdapter.getNewRow(new String[] { "product_id", "location_id", "new_quantity" });
 wizard.put("product_id", productId);
wizard.put("location_id", locationId);
 wizard.put("new_quantity", product.getInventory());

wizardAdapter.createObject(wizard);
 // 3) call change_product_qty() on the wizard
 odooSession.executeCommand("stock.change.product.qty", "change_product_qty", new Object[] {
 data.get("id"),
  odooSession.getContext()
  });
} catch (XmlRpcException | OpeneERPApiException e) {
  throw new OdooIntegrationException("inventory update failed", e);
}
}

It should be easy to translate this into native XML-RPC calls if required. The wizard itself creates a 'stock.inventory' and 'stock.inventory.line' item for the given product. You find the source code (v8.0) here: https://github.com/odoo/odoo/blob/8.0/addons/stock/wizard/stock_change_product_qty.py

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

Ahmed,


What error are you getting? I'd be happy to help as I am working within Python using the XML RPC and having no issues updating quantity, just updating product.product_qty works fine for me. 


Something like:


template =
{
'product_qty': '12',
}
 
sock.execute(dbname, uid, pwd, 'product.product','write', dbkey, template)
0
อวตาร
ละทิ้ง
อวตาร
ahmed
คำตอบที่ดีที่สุด

Hello,

i need to update a product quantity in odoo v8, anyone got any ideas ?
Thank you.

0
อวตาร
ละทิ้ง
Jesse Rye

See my reply.

สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now