Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • 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
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

how to format value for a many2many field thru XML RPC

Subscribe

Get notified when there's activity on this post

This question has been flagged
xmlrpcmany2manyperl
4 Replies
29104 Views
Avatar
Nicolas C

Hello,

Up to now I was able to search/read/create and write objects thru XML RPC (using perl script).

Until now I was only dealing with "simple" values like : string (name of a product) number (price) boolean (true/false) ...

But I need now to deal with "many2many" field and I don't know how to perform...

As seen within "XML RPC perl - OpenERP dev book example" h t t p : / / doc.openerp.com/v6.0/developer/6_22_XML-RPC_web_services/#perl-example I build the "object data" as a hash reference and it work fine for all "simple values".

For "many2many" I tried to use list of "target model id" in the following format within the "object data" hash :

['1', '2']
[['1', '2']]
[('1', '2')]

or directly using the native "array" from perl (ie: @array) But I get any error while writing the data (the write is correctly running for other fields like name) and .... so.. nothing happened for this many2many field :(

I'm currently dealing with "multi variant" product an the field I try to update is "dimension_type_ids" from model "product.template" on v6.1/ubuntu 12.04 using apps extra module "product_variant_multi".

Any idea/help is welcome (even with other language than perl) !!!

Have a nice day.

3
Avatar
Discard
Avatar
saad
Best Answer

When we are creating a many2many field we use this syntax:

'field_name':fields.many2many('related_model_name','relation_table_name','current_model_id','related_model_id', 'string' )

If we want manually fill this field, we should insert data in relation_table_name by executing this querie:

cr.execute('insert into relation_table_name (current_model_id, related_model_id) values(%s,%s)',(first_value,second_value))

OpenObject (OpenERP Framework) provide a list of tuples to use many2many fields in an easy way. Here is the list of tuple that are accepted, with the corresponding semantics

The dimension_type_ids field is a many2many relationship, and the (6, 0, Ids) means to replace any existing records (of product.variant.dimension.option) with those in Ids, because you're calling a create() method.

4
Avatar
Discard
Nicolas C
Author

Thank you very much !!!!!! Now I understand very much : how OpenERP framework internally work and... what I have to do ! I will test right now and let you know. Your link to the "list of tuple" is really great !!!!

Avatar
Nicolas C
Author Best Answer

Hello,

After solving some issue on the Ubuntu side, I have now a "/var/log/openerp-server.log" file working again.

Launching OpenERP server with additional options "--debug --log-level=debug_rpc_answer" now provide me useful informations !!!

When performing "product.template" edition thru the web interface, I captured the following syntax :

'dimension_type_ids': [[6, False, [1, 2]]]

I fully know/understand what is the last part of the "value" => "[1, 2]". This is the list of "foreign IDs" from model "product.variant.dimension.option" I just assigned to my template from the Web interface. But I don't know at all what the begin "6, False" refer to... :(

Does anyone have a clue about this syntax ? I'm not familiar with python at all so maybe this is some particular python syntax ? Or an OpenERP "usual format" ?

Any advice will be nice, I keep searching on my side ;o)

Just FYI, when performing a "read" on the same object I only get :

'dimension_type_ids': [1, 2]

Have a nice day everybody.

@++ Nicolas


UPTADE based on S@@D awesome answer

As only one answer is allowed, I'll update my own response here based on S@@D answer.

For an people looking to use perl as XML RPC interface to OpenERP, here is a sample of template.product object data (ie: a perl hash ref):

$object_data = {
    'name' => 'this is my template',
    'uom_id' => '1',
    'uom_po_id' => '1',
    'procure_method' => 'make_to_order',
    'variant_model_name' => '[_o.option_id.code_]',
    'do_not_update_variant' => '1',
    'sale_ok' => '1',
    'dimension_type_ids' => '[[6, 0, [1, 2]]',
    'variant_model_name_separator' => '\'\'',
    'supply_method' => 'produce',
    'type' => 'product',
    'categ_id' => '24',
    'is_multi_variants' => '1'
};

Where :

'dimension_type_ids' => '[[6, 0, [1, 2]]',

Is an update of a "many2many" field.

Have a look to S@@D link about tuple syntax (sorry but I have not enough karma to add link in my own answer). At the bottom of the developer book documentation page, you will have the "write" explained with all kindly syntax for many2many, one2many, many2one (the simpler one ;) ).

Note: I was only aware of CRUD (create/read/update(ie write)/delete(ie unlink) capability of OpenERP XML RPC... I'll now have a look to others listed in the doc page ;)

Thank you again S@@D Have a nice day

@++ Nicolas

6
Avatar
Discard
Avatar
Luis Javier
Best Answer

Thank you Nicolas C, i was trying to add some records to a Many2many field in Python.

model_obj.write({'field': [[6, 0, ids]]})
0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to find out the table name for a many2many relation (Where is the many2many table name stored?) Solved
orm xmlrpc many2many
Avatar
Avatar
Avatar
Avatar
Avatar
4
अक्तू॰ 21
25242
Create product using XMLRPC - PHP, issue with public_categ_ids
php xmlrpc many2many
Avatar
Avatar
2
जून 16
11968
Is it possible to retrieve 2 fields of all entry within a model thru xml-rpc?
list xmlrpc perl
Avatar
Avatar
Avatar
3
मार्च 15
10494
[closed] help with xmlrpc + many2many_tags
tags xmlrpc many2many
Avatar
Avatar
2
मार्च 15
5765
How can I do a xmlrpc-Search via a many2many-field (from account.invoice.line to account.tax)?
search xmlrpc many2many
Avatar
0
मार्च 15
4059
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

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