我需要關於XMLRPC的幫助,我正在使用python,我試圖創建產品變體,並且我需要爲字段many2many指定值,這裏是我的代碼Odoo 8 Python如何分配Many2many或one2many XMLRPC創建對象
idProductLineAttributeLine =
models.execute_kw(db,uid,password,'product.attribute.line','create',
[{'product_tmpl_id':idProduct,'attribute_id':idAttr,'value_ids': (6,0,
[idValue])}])
如果我分配領域的正常工作,萬物罰款,但是當涉及到many2many場或one2many領域的顯示箭頭這樣
in __dump\nTypeError: cannot marshal <type 'builtin_function_or_method'> objects\n", "message": "cannot marshal <type 'builtin_function_or_method'> objects", "name": "exceptions.TypeError", "arguments": ["cannot marshal <type 'builtin_function_or_method'> objects"]}}}
我做了什麼錯?請幫我:)謝謝在先進
在書中odoo必不可少的說,我必須使用這一個了分配many2many值或one2many值,但仍然沒有運氣
(0,_ ,{' field': value}): This creates a new record and links it to this one
(1, id,{' field': value}): This updates values on an already linked record
(2, id,_): This unlinks and deletes a related record
(3, id,_): This unlinks but does not delete a related record
(4, id,_): This links an already existing record
(5,_,_): This unlinks but does not delete all linked records
(6,_,[ ids]): This replaces the list of linked records with the provided list
更新 我管理通過添加[] THX解決這個問題dccdany指出這一點:)和產品變形加入到產品
models.execute_kw(db,uid,password,'product.attribute.line','create', [{'product_tmpl_id':idProduct,'attribute_id':idAttr,'value_ids': (6,0, [idValue])}])
,但產品變形不會自動產生,我仍然東東d通過編輯手動刷新產品並保存任何想法爲什麼?
所看到的截圖有4個產品變異,但近頂部的狀態正確只說3變體沒有我在這裏錯過了什麼?
你試過[(6,0,[ids])]嗎? – dccdany
啊我看到我做到了,以及如何更新當前many2many關係?我的意思是如果我想添加更多的價值many2many關係而不更換值,因爲如果我嘗試使用[(6,0,[ids])]?它不斷更換以前的值可以舉一些例子??如何使用(0,0,{}) – dmh
您可以通過ID和4:[(4,ID)] – dccdany