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

How do I add a domain to a related field?

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
domainpaysliprelated_fieldsv11
5 Respostas
10539 Visualizações
Avatar
Bill Ennals

In Odoo 11 CE, I am trying to customise the Payslip object, "hr.payslip", which has a One2Many relation with the object "hr.payslip.lines" through the field "line_ids".

I have added a custom field to the object hr.payslip.


net_pay = fields.Float(string='Net Pay', related='line_ids.total', domain=[('line_ids.code', 'ilike', "NET")])


The aim of this field is to fetch the value from the field 'total' in the hr.payslip.line where the field 'code' is set to "NET".  There is only one line per payslip with this code.

The problem I'm having is that the domain does not seem to be applied and the net_pay is just returning the 'total' value from the first line (which has the code "GROSS"), and not excluding lines that have a code different to "NET".

What am I doing wrong?

0
Avatar
Cancelar
Bill Ennals
Autor

EDITED:

I thought I found the answer to my question thanks to this answer by Lan Pham at stackoverflow

https://stackoverflow.com/questions/59534725/odoo-domain-not-working-with-a-related-field

But the code below doesn't fetch the 'amount' from the payslip.line with code 'NET' for the relevant payslip. It seems to get the first possible value from the hr.payslip.line table.

net_pay = fields.Float(string='Net Pay', compute='_get_netpay')

@api.multi

def _get_netpay(self):

for line in self:

line.net_pay = self.env['hr.payslip.line'].search([('code', '=', "NET")], limit=1).amount

How can I make the "net_pay' field fetch from the line that belongs to the payslip?

Avatar
Axel Mendoza
Melhor resposta

Hi @Bill

Sorry but what you wanna do it's out of the scope of related field and their domain that only will be applied to relational fields, o2m, m2m, m2o to provide a way to filter the values to select at the UI.

What you wanna do it's easily get it done with a computed field that you could program the whole logic to determine the value for the field

1
Avatar
Cancelar
Bill Ennals
Autor

Hi Axel,

I thought I had it solved but the code above does not pull the 'amount' from the line that belongs to the relevant payslip. It's returning the same value regardless of which payslip I am looking at. Can you suggest how to fix it?

Avatar
Bill Ennals
Autor Melhor resposta

For a solution to achieve what I was hoping to do with related fields, but using computed fields instead (as suggested by Axel), see this thread:

https://www.odoo.com/fr_FR/forum/aide-1/question/how-can-i-filter-records-returned-from-a-computed-field-based-on-values-from-a-related-model-173568

0
Avatar
Cancelar
Axel Mendoza

That link is an answer of a very different and specific question. The one on this post was a wrong usage of the domain on a non filterable field

Bill Ennals
Autor

Yes, you're right Axel. I didn't mean to suggest you hadn't been helpful. I've edited the parts that I can and marked your answer as the best one.

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
Search() elements from many "One2many" Resolvido
domain one2many v11 search()
Avatar
Avatar
2
ago. 20
3489
How can I create a related field on purchase.order.line to give me the NAME of the product? (Without the Internal Reference Number prepended to it) Resolvido
many2one related related_fields v11 Community
Avatar
Avatar
2
set. 19
6299
naked domain set up Resolvido
domain
Avatar
Avatar
Avatar
Avatar
3
jul. 25
6412
Domain name Request
domain
Avatar
0
mai. 25
1750
Domain is not working
domain
Avatar
Avatar
2
mar. 24
3036
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