Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Changing one2many widget to many2many causes error on creation, many2many on 2 models seems to not relate them (all web UI)

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
1 Răspunde
4647 Vizualizări
Imagine profil
Roberto Cocchiararo

Hi

First of all, I would like to clarify that I am working with the web interface and not "programing" an instalable module, since I know programing basics, but no python.

My objective is to add functionality to the fleet management module.
I created 2 additional models, "events" and "fleet insurance" (the built in contracts can be used for other objectives, but the actual insurance is managed differently, only 2 companies are used and this allows keeping the vehicles up to date easier).

One is for listing events (name, date, description). Each event can have "x" number of vehicles participating (each vehicle can participate in any number of events, and this is a log).

The other is for registering insurance contracts (number, expiration and company). Each contract can have "y" vehicles associated (but one vehicle can have only 1 fleet insurance contract active).

I then need to extend the fleet.vehicle model, adding a list of all the events where it has participated, and the information of the current insurance contract (it can have only one).

My issues start here.

I first tried using many2many fields. This allowed me to pick vehicles in the events/fleet insurance, or events/fleet insurance from the vehicle form, but changing one entity has no effect on the other.

I then tried with one2many in the vehicles, many2one in events/fleet insurance. Now I could pick correctly from the vehicles, but could only have one on the other models (and it was a selection showing just one field, not all the info). Also, from the events/fleet insurance, the "add new" opened the vehicle creatin form, instead of listing the existing ones.

Finally I went with many2one in vehicles, one2many on the other side. This time the problem was inverted.
Then u tried setting the widget on both ends to "many2many", which seemed to be the answer. Too bad now I can't create new vehicles or events/fleet insurance because I get an " unhashable: list" error.

I tries also having many2many on one end, one2many on the other. Similar error when creating.

Can you helpe fix my issue or instruct on the correct way of achieving my objective, using only the web interface of course?

The XML code i ended up with (with some variations, like read only for the fleet insurance on the vehicle form view) was:

Fleet insurance form view:
<?xml version="1.0"?>
<form>
<group string="Seguro">
<field name="x_compania"/>
<field name="x_numeropoliza"/>
<field name="x_fechavencimiento"/>
</group>
<group string="Asegurados">
<field name="x_vehiculos" nolabel="1" widget="many2many"/>
</group>
</form>

Events form view:
<?xml version="1.0"?>
<form>
<group string="Evento">
<field name="x_nombreevento"/>
<field name="x_fechaevento"/>
</group>
<group string="Descripción">
<field nolabel="1" name="x_descripcion" placeholder="Escriba aquí información del evento"/>
</group>
<group string="Participantes">
<field name="x_vehiculos" nolabel="1" widget="many2many"/>
</group>
</form>

Vehicle form view addition (i tried with and without notebook, but with notebook it looked better):

<notebook>
<page string="Seguro de Flota" attrs="{'invisible': [('x_aseguradoflota','=',False)]}">
<group>
<field name="x_seguroflota" nolabel="1" widget="many2many" readonly="1"/>
</group>
</page>
<page string="Eventos" attrs="{'invisible': [('model_id','=',False)]}">
<group>
<field name="x_eventos" nolabel="1" widget="many2many"/>
</group>
</page>
</notebook>

 

0
Imagine profil
Abandonează
Imagine profil
Roberto Cocchiararo
Autor Cel mai bun răspuns

I have been doing more experiments, and i believe now that what i tried was not supported, and that is the reason it failed in the first place :P

In any case, now i have:

Events (one2many) > Vehicles (many2many)

Fleet insurance (one2many) > Vehicles (many2one)

Doing it this way, i can have every vehicle participate in any number of events, and modifying one list, does the same on the other. Only downside is i had to change the form view for the events so that the vehicle list is "readonly", because the "one2many" list widget tries to create a new vehicle instead of picking existing ones.

At the same time, each vehicle can have only one fleet insurance active at any moment, which is good. My only issue is that since i am using just the web interface, and these are all custom models/fields, it seems like only "luck" decides what field is displayed in "vehicles" for the "many2one" field relating to "fleet insurance". This time, it was the policy number (more or less usefull), but i had another case where the "user that created the record" was displayed, which was not good at all.

Can i manage this in any way when i am not defining the model/field in python code? If i where, i could set the "_rec_name" of each custom "many2one" field i needed to display the 2 or 3 fields from the "fleet insurance" model in the "vehicle" form view.

 

 

 

0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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