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

User-defined Filters - not accepting dynamic filters for e.g: "user_id","=", uid

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
filtersettingsdynamic
1 Responder
6624 Visualizações
Avatar
Robert Young

Odoo 13 Enterprise Edition

Having created a User-defined filter that is shared to all users, I have edited it to include user_id = uid as follows:

["&","&","&",["customer_rank",">",0],["activity_ids","!=",False],["user_id","=", uid],["activity_date_deadline","=","2021-01-12"]]
When saving, I get the following error message: The domain you entered was not properly formatted.

I have also tried replacing the static date for activity_date_deadline with a dynamic filter as follows:

["activity_date_deadline", "=", (context_today() + datetime.timedelta(days=1)).strftime('%%Y-%%m-%%d') ]

When saving this, the change is reverted silently - no error is displayed.

Question:  How should I edit the User-defined Filter to use dynamic filters for User and Date, please?

0
Avatar
Cancelar
Ray Carnes (ray)

What model are you creating this for? Does the model have a user_id field? Take a look at the Filters defined in the sale.order.list.select view which leverage both UID and context_today() https://github.com/odoo/odoo/blob/14.0/addons/sale/views/sale_views.xml#L728

Ibrahim Boudmir

Hi,

i see [] instead of () in your domain. it should be like this:

domain="[(condition), (condition), (condition), (), ..]"

in your case, it is:

[("customer_rank",">",0),("activity_ids","!=",False),("user_id","=", uid),("activity_date_deadline","=","2021-01-12")]

P.S: If all conditions must have and as an operator, no need to add it in the domain.

Robert Young
Autor

@Ray Carnes

Thanks for your response. This is being created for the 'Contact' model. The model does have a user_id field - if limiting to a specific named user the filter works - for e.g: ["user_id","ilike","Austen"]

Thank you for the link to the view source that I will test with the the context_today option. If you have any other suggestions for the UID I would certainly appreciate it.

Thank you!

Alessandro Fiorino

Where are you entering the domain ? Are you using Studio ?

Robert Young
Autor

@Alessandro Fiorino and @Ibrahim Boudmir

The steps that I follow are as follows:

1. Go to 'Contacts' and create a filter with the following rules:

---Companies,

---Add Custom Filter: Salesperson contains Austen,

---Add Custom Filter: Next Activity Deadline is equal to 13/01/2021

2. Select the drop-down beside 'Favourites' and select 'Save Current Search'

3. Set the name for the search, and select 'Share with all users' then SAVE.

4. Go to 'Settings' (make sure debug is enabled for this step)

5. Select Technical > User Interface > User-defined Filters

6. Select the custom filter created at step 3 and EDIT

The domain is set automatically when creating the filter from the Contacts module. The corresponding code in the code editor is also created by the action of creating the filter.

I am not using Studio for this task.

Let me know if any further information is required - many thanks.

Pierre

Any solution? I'm struggling with the same problem... 2 years later ...

Avatar
shubham shiroya
Melhor resposta

you can achieve dynamic filtering using the following approach:

  1. Create a Custom Filter:

    • First, create a custom filter as you've done.

    • In the filter's domain field, you'll need to set a static condition to ensure the filter is correctly saved. For example:

      ["&", ["customer_rank", ">", 0], ["activity_ids", "!=", False]]
      
  2. Use Context in the Action:

    • Instead of trying to set dynamic values directly in the filter, you can use context variables when defining an action. This action can be associated with a menu item or button.
  3. Set Dynamic Values in the Action:

    • In the action's context, you can set dynamic values for the user and date. Here's an example of how you can define the action:

       id="action_custom_filter" model="ir.actions.server">
          name="name">Custom Filter Action
          name="model_id" ref="model_your_model_name"/>
          name="state">code
          name="code">self.domain = [("customer_rank", ">", 0), ("activity_ids", "!=", False), ("user_id", "=", self.env.user.id), ("activity_date_deadline", "=", fields.Date.today() + timedelta(days=1))] 
      
      

      In this example, self.env.user.id is used to dynamically set the user, and fields.Date.today() + timedelta(days=1) sets the date to tomorrow.

  4. Use the Action in a Menu Item or Button:

    • Finally, you can create a menu item or button and associate it with the action you defined. When users click on this menu item or button, it will apply the dynamic filter based on the context values.


0
Avatar
Cancelar
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
Toggle <field>'s visibility in search view Resolvido
filter invisible dynamic
Avatar
Avatar
2
mar. 15
6662
How to show all users in filter list automatically by clicking on filter button?
filter users list dynamic
Avatar
Avatar
1
jul. 21
4715
Dynamicly apply filter for one2many field
filter domain one2many dynamic
Avatar
0
dez. 16
6015
cbbbbggf
filter
Avatar
0
nov. 25
2
Factura en estado "EN PROCESO DE PAGO"
filter
Avatar
0
nov. 25
2
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