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

create and edit items of a one2many field through on_change method

Abonare

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

Această întrebare a fost marcată
one2manyon_changeactive_id
9606 Vizualizări
Imagine profil
Romuald Franck

I have this class (evaluation)

class schoolem_evaluation(osv.Model):
_name = 'schoolem.evaluation'
_columns = {
    'name' : fields.char('Evaluation',help="Champ automatique = periodeN_ExamenN_CoursX_SalleDeClasseS"),
    'aca_id' : fields.many2one('schoolem.aca','Annee Academique',required=True),
    'periode_id' : fields.many2one('schoolem.periode','Periode',required=True,help="Par exemple : trimestre01"),
    'examen_id' : fields.many2one('schoolem.examen','Examen',required=True),
    'salle_de_classe_id' : fields.many2one('schoolem.salle_de_classe','Salle de Classe',required=True),
    'cours_id' : fields.many2one('schoolem.cours','Cours',required=True),
    'note_ids' : fields.one2many('schoolem.note_evaluation','evaluation_id','Notes'),
}

and this class (note_evaluation)

 class schoolem_note_evaluation(osv.Model):
    _name = 'schoolem.note_evaluation'
    _order = 'etudiant_id'
    _columns = {
        'name' : fields.float('Note',digits=(6,2),required=True),
        'evaluation_id' : fields.many2one('schoolem.evaluation','Evaluation',),
        'etudiant_id' : fields.many2one('schoolem.etudiant','Etudiant',required=True),
        'rang' : fields.integer('Rang'),
        'observation' : fields.text('Observation'),
    }

And I would like the user to be able to generate one2many note_evaluation lines through an on_change method when selecting the value of the last field(cours_id) in the Evaluation_form; and to make that the generated lines appear directly in the view, so that he can insert the name value (note) of each note_evaluation line. And save all.

Is it possible? This is my current XML view file

<field name="cours_id"  context="{'evaluation_id': active_id, 'test': 1}" on_change="on_change_cours_id(examen_id,salle_de_classe_id,cours_id,aca_id)"/>
                    </group>
                    <notebook>
                        <page string="Inserer des notes">
                            <field nolabel="1" name="note_ids" context="{'evaluation_id': active_id}"/>
                        </page>

and this is the onchange function:

def on_change_cours_id(self,cr, uid, ids,examen_id,salle_de_classe_id,cours_id,aca_id,context=None):

    context=context or {}

    #if context is None:

     #   context = {}
            for etud_id in etudiant_ids:

                note_eval = self.pool.get('schoolem.note_evaluation')

                if not context.get('id', False): #id de l'evaluation

                    context['id'] = context.get('evaluation_id')

                eval_id = context.get('id', False)
                raise osv.except_osv(('the form!'), (context.get('active_id')))

                id = note_eval.create(cr, uid, {'name':0,'etudiant_id':etud_id,'evaluation_id':eval_id}, context=context)

With this, it the on_change method create the note_evaluation in the database but the user interface do not load them and the one2many field remain empty. I observe the note_evaluation in teh database donnot have the evaluation_id.

How to do?

0
Imagine profil
Abandonează
Romuald Franck
Autor

solved, look at http://stackoverflow.com/questions/20954412/create-and-edit-items-of-a-one2many-field-through-on-change-method

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 use Onchange function in one2many
one2many on_change
Imagine profil
Imagine profil
1
mar. 15
6572
What data structure does one2many fields have, when they are passed as arguments in onchange method? Rezolvat
one2many on_change v7
Imagine profil
Imagine profil
1
mar. 15
5249
Dataerror updating function field of one2many object using on_change event
one2many on_change function_field
Imagine profil
0
mar. 15
5743
is there any way to unlink line items on onchange?
one2many on_change line
Imagine profil
Imagine profil
1
mar. 15
9059
Load default values for one2many field based on onchange field !? (Odoo 13)
one2many on_change onchange Odoo13
Imagine profil
Imagine profil
1
mai 21
7221
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