Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

How to Import one2many field record from one model to one2many field in another model

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
one2manyonchange
1 Rispondi
13243 Visualizzazioni
Avatar
Nanda Kanoko

I need to import record saved from my o2m field to another o2m field in different model

class notebook_project(osv.osv):
    _name = "notebook.project"
    _description = "Notebook Project ID"

    def onchange_project_id(self, cr, uid, ids, project_id, arg, context=None):
        if project_id :
            prod = self.pool.get('project.project').browse(cr, uid, project_id, context=context)
            return {'value': {'name': prod.name}}
        return {}   

    _columns = {
        'name' : fields.char('Name', size=64),
        'project_id' : fields.many2one('project.project', 'Project'),
        'notebook_project_lines' : fields.one2many('notebook.project', 'notebook_project_id', 'Members Lines'),
        'notebook_project_id': fields.many2one('notebook.project', ondelete='cascade', select=True),
        'project_member' : fields.many2one('hr.employee', 'Members'),

        }

notebook_project()

Explanation :

I assigned some employee to certain project . When i see in my PostgreSQL , the notebook_project_id already record the ID that shows some employee already assigned to the project ID they assigned to . How can I call those record on different model ?

Ex : In first model , Project A have employee 1 , 2 , 3 . And on second model , when i choose project A and save , the field shows employee 1 , 2 , 3 on project A The models is somehow like mrp.bom and mrp.production . first model is mrp.bom and second model is mrp.production Please help !

0
Avatar
Abbandona
Avatar
ainur rofiq
Risposta migliore

I am not expert in python, there may be a better solution then this stupid code :)

class main_model(osv.osv)
    _name = "your.main.model"
    _columns = {
        'main_o2m':fields.one2many('some.model', 'field_id', 'Label', required=False),
        ......
    }

    def create(self, cr, user, vals, context={}):
        #first model
        first_obj = self.pool.get('your.first.model')
        #browse and get o2m fields, according to your selected project(id)
        first_o2m = first_obj.browse(cr, user, [SELECTED_ID]).lines

        #copy first o2m model to second o2m model
        for line in first_o2m:
            vals['main_o2m'].append([0, False, {'employe_id':line.employe_id.id,}])

        return super(main_model, self).create(cr, user, vals, context)

hope this help. thanks

0
Avatar
Abbandona
Nanda Kanoko
Autore

Here is the newest code i made , with error explanation in it . Please kindly check it , thanks . Link :http://stackoverflow.com/questions/17714692/copy-one2many-field-snafu

Nanda Kanoko
Autore

can u explain what is the selected ID ?

ainur rofiq

SELECTED_ID is 'id' of yout first model. this 'id' can be a field value in XML or a result of search condition as you want

Nanda Kanoko
Autore

well , according to my code posted in : http://stackoverflow.com/questions/17714692/copy-one2many-field-snafu ,, which one is the SELECTED_ID one ? because when i tried using notebook_project , it give Attribute Error

ainur rofiq

'project_id', but I get confused about your relation model. Is that work?

Nanda Kanoko
Autore

the truth is , i'm not really sure the relation is perfect , but ppl opinion said it's not wrong .. Actuallu it works , since it able to show the employee from first model ... but the problem is , the employee showed is not according to chosen project ,, the rest you can see at the web . Thanks anyway

Nanda Kanoko
Autore

tried it , it give an attribute error AttributeError: 'browse_record_list' object has no attribute 'lines'

ainur rofiq

that indicate method browse return a list.... try browse(cr, uid,......)[0].lines or if you use search method : project_id = obj.search(.....) then use project_id[0] as parameter in browse method. obj.browse(cr, uid, project_id[0])

Nanda Kanoko
Autore

added that , still got same error

ainur rofiq

I'm sory... I have no idea

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
How to update two levels o2m fileds relation
one2many onchange
Avatar
0
set 20
3713
Several levels of One2many
one2many onchange
Avatar
0
apr 16
3835
One2many onchange in ODOO Risolto
one2many onchange
Avatar
Avatar
3
mar 16
14886
How to return domain on one2many field so that seleted values are not shown in next line
domain one2many onchange
Avatar
1
apr 23
5932
onchange return domain for one2many product ID Field Risolto
domain one2many onchange
Avatar
Avatar
Avatar
Avatar
7
apr 23
19881
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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