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

Retrieve a Field using Related to select a Selection Field

Iscriviti

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

La domanda è stata contrassegnata
selectionrelated
9 Risposte
60686 Visualizzazioni
Avatar
Cameron

I'm very disappointed with myself having to ask this question, but after almost two wasted days....

I am creating my first module I have

from osv import osv, fields
    class sale_pack_type(osv.Model):
    _inherit = 'sale.order'
    _columns = {
    'sale_pack_type': fields.selection((('a', 'A'), ('b', 'B'), ('c', 'C')), 'Sale Packaging Type'),
    }
    _defaults = {
        'sale_pack_type': 'a',
    }

Which works just dandy!

But when I try to retrieve the value using

class ware_pack_type(osv.Model):
    _inherit = 'stock.picking.out'
    _columns = {
        'ware_pack_type': fields.related('sale_id', 'sale_pack_type', type='char', relation='sale.order', readonly=True, store=True, string='Packaging Type'),
    }

I get constant failure :( -

The best I can achieve is displaying 'Packaging Type' in the view and 'ware_pack_type' in the 'stock.picking.out' db, all values = NULL.

I've tried everything ...

type='selection', selection=(('a','A'),.....

with and without relation=...

type='one2many'

gone through hundreds of web pages

and many many more

Nothing works, pleeeeasssse help.

5
Avatar
Abbandona
Zahin

It seems to be wrong related field implementation, I am not sure but please check related field documentation. related filed can be use with self related field. please see documentation or batter example from blogs other than openerp docs.

Cameron
Autore

Cheers Zahin - did you mean to say "related field CAN be used"? or did you mean "Cannot"?

The only example / commentary relating to field.related is about a bug but thats four years old, and suppose to be resolved https://bugs.launchpad.net/openobject-server/+bug/385117 - I'm off for a beer!

Zahin

@Cameron: What I mean is exact given in answer 1, sale_id should require.

Avatar
Vasiliy Birukov
Risposta migliore

For correct work in related field you must define list of selection values one more. Working example will be:

from osv import osv, fields

PACKAGE_TYPE_SELECTION = [
    ('a', 'A'),
    ('b', 'B'),
    ('c', 'C')
]

class sale_pack_type(osv.Model):
    _inherit = 'sale.order'
    _columns = {
        'sale_pack_type': fields.selection(PACKAGE_TYPE_SELECTION, 'Sale Packaging Type'),
    }
    _defaults = {
        'sale_pack_type': 'a',
    }

class ware_pack_type(osv.Model):
    _inherit = 'stock.picking.out'
    _columns = {
        'sale_id': fields.many2one('sale.order', 'sale order'),
        'ware_pack_type': fields.related('sale_id', 'sale_pack_type', type='selection', selection=PACKAGE_TYPE_SELECTION, readonly=True, store=True, string='Packaging Type'),
    }
7
Avatar
Abbandona
Avatar
Kirubanidhi Rajarathinam
Risposta migliore

Create first py file:

class Book_return(models.Model):

_name = 'college.return'

statusbar_custom = fields.Selection([('new', 'New'), ('draft', 'Draft'), ('cancel', 'Cancel'), ('confirm', 'Confirm'), ('done', 'Done')])

Create second py file.I implement the another table selection field in my current table.In this example is helpful for u

class Book_form(models.Model):

_name = 'college.book'

stage_id=fields.Many2one('college.return',string='Stage ID')

     stage_state = fields.Selection(related='stage_id.statusbar_custom',string='Stage State')

0
Avatar
Abbandona
Avatar
Najlae Boudali
Risposta migliore

hi , have a problem with my related field , i have two classes : nomenclature and projet_ligne i want to get the value of ' sous' on 'eta' so there s my code


class nomenclature(models.Model):

 _name = 'nomenclature'

name = fields.Char('Nom de la nomenclature',required=True)

quantite = fields.Integer('Quantité',required=True)

produit=fields.Many2one('product.product')

sous= fields.Boolean('sous')


class projet_ligne(models.Model):

_name = 'projet.ligne'

#name = fields.Char('nom du sous essaie',required=True)

nomenclature=fields.Many2one('nomenclature',required=True)

responsable=fields.Many2one('res.users',)

projet = fields.Many2one('projet',required=True)

date= fields.Date() etat=fields.Boolean('Achevé?')

reference= fields.Char('Réference')

nature= fields.Char('Nature')

dateprelevement= fields.Date()

lieuprelevement= fields.Char('lieu')

etatvalider= fields.Boolean('Validé')

eta= fields.Boolean(related='nomenclature.sous')


It doesn t work :/

0
Avatar
Abbandona
Avatar
Juan Carrasquel
Risposta migliore

Good afternoon here will be useful information

https://www.odoo.com/files/memento/OpenERP_Technical_Memento_v0.7.4.pdf

0
Avatar
Abbandona
Avatar
joseph d'souza
Risposta migliore

it should be like this

class ware_pack_type(osv.Model):
_inherit = 'stock.picking.out'
_columns = {
    'sale_id': fields.many2one('sale.order', 'sale order'),
    'ware_pack_type': fields.related('sale_id', 'sale_pack_type', type='selection', relation='sale.order', readonly=True, store=True, string='Packaging Type'),
}
ware_pack_type()

Above same for the stock.picking object

Hope It works !

Mark true on the answer if is correct

Thanks,

dsouzajoseph199@gmail.com

0
Avatar
Abbandona
Cameron
Autore

Many thanks but I'm afraid it doesn't work, same as before NULL in the db

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à
Can't pass value from res.partner to project.project
selection related
Avatar
0
apr 15
4078
how to add values dynamically in selection fields? Risolto
selection
Avatar
Avatar
Avatar
Avatar
Avatar
4
dic 23
23529
Dynamically change choices in selection fields Risolto
selection
Avatar
Avatar
Avatar
Avatar
Avatar
5
lug 24
16929
Working with fields.selection values Risolto
selection
Avatar
Avatar
1
giu 22
28734
How to change the values for a selection field? Risolto
selection
Avatar
Avatar
Avatar
Avatar
Avatar
9
mag 22
55014
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