Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

how to format value for a many2many field thru XML RPC

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
xmlrpcmany2manyperl
4 Replies
29102 Rodiniai
Portretas
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
Portretas
Atmesti
Portretas
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
Portretas
Atmesti
Nicolas C
Autorius

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 !!!!

Portretas
Nicolas C
Autorius 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
Portretas
Atmesti
Portretas
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
Portretas
Atmesti
Enjoying the discussion? Don't just read, join in!

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

Registracija
Related Posts Replies Rodiniai Veikla
How to find out the table name for a many2many relation (Where is the many2many table name stored?) Solved
orm xmlrpc many2many
Portretas
Portretas
Portretas
Portretas
Portretas
4
spal. 21
25238
Create product using XMLRPC - PHP, issue with public_categ_ids
php xmlrpc many2many
Portretas
Portretas
2
birž. 16
11966
Is it possible to retrieve 2 fields of all entry within a model thru xml-rpc?
list xmlrpc perl
Portretas
Portretas
Portretas
3
kov. 15
10490
[closed] help with xmlrpc + many2many_tags
tags xmlrpc many2many
Portretas
Portretas
2
kov. 15
5764
How can I do a xmlrpc-Search via a many2many-field (from account.invoice.line to account.tax)?
search xmlrpc many2many
Portretas
0
kov. 15
4059
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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