Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Retrieve a Field using Related to select a Selection Field

Odebírat

Get notified when there's activity on this post

This question has been flagged
selectionrelated
9 Odpovědi
60688 Zobrazení
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
Zrušit
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
Autor

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
Nejlepší odpověď

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
Zrušit
Avatar
Kirubanidhi Rajarathinam
Nejlepší odpověď

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
Zrušit
Avatar
Najlae Boudali
Nejlepší odpověď

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
Zrušit
Avatar
Juan Carrasquel
Nejlepší odpověď

Good afternoon here will be useful information

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

0
Avatar
Zrušit
Avatar
joseph d'souza
Nejlepší odpověď

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
Zrušit
Cameron
Autor

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

Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Can't pass value from res.partner to project.project
selection related
Avatar
0
dub 15
4079
how to add values dynamically in selection fields? Vyřešeno
selection
Avatar
Avatar
Avatar
Avatar
Avatar
4
pro 23
23529
Dynamically change choices in selection fields Vyřešeno
selection
Avatar
Avatar
Avatar
Avatar
Avatar
5
čvc 24
16930
Working with fields.selection values Vyřešeno
selection
Avatar
Avatar
1
čvn 22
28734
How to change the values for a selection field? Vyřešeno
selection
Avatar
Avatar
Avatar
Avatar
Avatar
9
kvě 22
55016
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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