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

many2one link between 2 classes

Abonare

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

Această întrebare a fost marcată
many2onev7id
1 Răspunde
5655 Vizualizări
Imagine profil
N

I have create a class 'sale_order_section' in order to decompose a quotation into multiples sections. Here is a part of my code :

class sale_order_section(osv.osv):
    _name = 'sale.order.section'
    #_rec_name = 'number'
    _columns = {
               'order_id': fields.many2one('sale.order', 'Order Reference', ondelete='cascade', select=True, readonly=True),
               'order_line': fields.one2many('sale.order.line', 'section_id', 'Order Lines', readonly=False),
               'number': fields.integer('n° section')
    }

class sale_order_line(osv.osv):

_name = 'sale.order.line'
_inherit = 'sale.order.line'
_columns = {
    'section_id': fields.many2one('sale.order.section', 'n° section', required=True, ondelete='cascade', select=True, readonly=True, states={'draft':[('readonly',False)]}),
    'is_option': fields.boolean('option')
}
sale_order_line()


class sale_order(osv.osv):
_name = "sale.order"
_inherit = 'sale.order'
_columns = {
            'order_section': fields.one2many('sale.order.section', 'order_id', 'Order Sections', readonly=True, states={'draft': [('readonly', False)]})
    }

The problem is that when i create a new section in a view, the "order_id" relative to this section is not created, so i don't have a link between the sale order and the section which belongs to this sale order. How can i fix that ? Thanks

0
Imagine profil
Abandonează
Imagine profil
saad
Cel mai bun răspuns

Normally, you should create sections from sale order view as order_section is a one2many field in sale.order model. The order_id field is automatically filled.

0
Imagine profil
Abandonează
N
Autor

Maybe it doesnt work because i cannot have two one2many fields in the same table (order_line and order_section) ?

N
Autor

Also now i have a field "section_id" in the table "sale.order" in PostgreSQL : i am not supposed to have this becaus it's a one2many field...

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
Related Posts Răspunsuri Vizualizări Activitate
How to retrieve id of in a many2one field
many2one field v7 id reference
Imagine profil
0
mar. 15
8397
Get other field than id in database (many2one field)
database many2one id
Imagine profil
Imagine profil
1
mai 16
5764
How to use selection on many2one?
many2one v7 selection
Imagine profil
Imagine profil
2
mar. 15
15237
Which database am I working in?
database v7 id
Imagine profil
Imagine profil
Imagine profil
2
mar. 15
9468
Show different data in many2one
many2one v7 m2o
Imagine profil
Imagine profil
Imagine profil
2
mar. 15
5983
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