Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

Retrieve a Field using Related to select a Selection Field

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
selectionrelated
9 Respostas
60684 Visualizações
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
Cancelar
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
Melhor resposta

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
Cancelar
Avatar
Kirubanidhi Rajarathinam
Melhor resposta

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
Cancelar
Avatar
Najlae Boudali
Melhor resposta

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
Cancelar
Avatar
Juan Carrasquel
Melhor resposta

Good afternoon here will be useful information

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

0
Avatar
Cancelar
Avatar
joseph d'souza
Melhor resposta

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
Cancelar
Cameron
Autor

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

Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
Can't pass value from res.partner to project.project
selection related
Avatar
0
abr. 15
4078
how to add values dynamically in selection fields? Resolvido
selection
Avatar
Avatar
Avatar
Avatar
Avatar
4
dez. 23
23529
Dynamically change choices in selection fields Resolvido
selection
Avatar
Avatar
Avatar
Avatar
Avatar
5
jul. 24
16929
Working with fields.selection values Resolvido
selection
Avatar
Avatar
1
jun. 22
28733
How to change the values for a selection field? Resolvido
selection
Avatar
Avatar
Avatar
Avatar
Avatar
9
mai. 22
55012
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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