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

templating: t-if for string length

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
templateskanbant-if
2 Respostas
11019 Visualizações
Avatar
Alexander Soare

I want to display an origin ('City A') and destination ('City B') in a kanban template. These are both char fields in my model. I want to bit an arrow '→' between them but only if both are specified. This is a piece of my code:

<span>

<field name="x_quote_pickup_city"/>

<span t-if="x_quote_pickup_city != '' and x_quote_delivery_city != ''"> → </span>

<field name="x_quote_delivery_city"/>

<field name="x_quote_value"/>

</span>

The t-if doesn't seem to be working. This attempt just gives me the '→' even if the chars aren't set.

How would I go about achieving my goal here?

0
Avatar
Cancelar
Avatar
Celia
Melhor resposta

Try to do this: 

<field name="x_quote_pickup_city"/> <field name="x_quote_delivery_city"/>     <field name="x_quote_value"/>

<span t-if="x_quote_pickup_city.raw_value and x_quote_delivery_city.raw_value">

    <t t-raw="x_quote_pickup_city.raw_value"/> →

    <t t-raw="x_quote_delivery_city.raw_value"/> </span>

I hope this works

1
Avatar
Cancelar
Avatar
Alexander Soare
Autor Melhor resposta

@Celia, I tried and get the following error message upon reloading the page:

Uncaught TypeError: Cannot read property 'raw_value' of undefined

https://erp.ontruck.io/web?debug#view_type=kanban&model=crm.lead&action=146&active_id=3:46

Traceback:

TypeError: Cannot read property 'raw_value' of undefined

at Engine.eval (eval at <anonymous> (https://erp.ontruck.io/web/static/lib/qweb/qweb2.js:402:33), <anonymous>:46:33)

at Engine.QWeb2.Engine.QWeb2.tools.extend._render (https://erp.ontruck.io/web/static/lib/qweb/qweb2.js:391:58)

at Engine.QWeb2.Engine.QWeb2.tools.extend.render (https://erp.ontruck.io/web/static/lib/qweb/qweb2.js:383:26)

at Engine.QWeb2.Engine.QWeb2.tools.extend._render (https://erp.ontruck.io/web/static/lib/qweb/qweb2.js:413:29)

at Engine.QWeb2.Engine.QWeb2.tools.extend.render (https://erp.ontruck.io/web/static/lib/qweb/qweb2.js:383:26)

at OdooClass.Widget.extend.init_content (https://erp.ontruck.io/web_kanban/static/src/js/kanban_record.js:67:34)

at OdooClass.Widget.extend.init (https://erp.ontruck.io/web_kanban/static/src/js/kanban_record.js:42:14)

at OdooClass.prototype.(anonymous function) [as init] (https://erp.ontruck.io/web/static/src/js/framework/class.js:89:38)

at OdooClass.Class (https://erp.ontruck.io/web/static/src/js/framework/class.js:106:33)

at OdooClass.Widget.extend.add_record (https://erp.ontruck.io/web_kanban/static/src/js/kanban_column.js:141:22)

Here is my entire code for your reference: (your solution starting on line 44)

<?xml version="1.0"?>

<xpath expr="//kanban" position="replace">

<kanban default_group_by="stage_id" class="o_kanban_small_column">

<field name="stage_id" options="{&quot;group_by_tooltip&quot;: {&quot;requirements&quot;: &quot;Description&quot;, &quot;legend_priority&quot;: &quot;Use of stars&quot;}}"/>

<field name="color"/>

<field name="priority"/>

<field name="planned_revenue"/>

<field name="user_email"/>

<field name="user_id"/>

<field name="partner_address_email"/>

<field name="message_needaction_counter"/>

<field name="tag_ids"/>

<field name="partner_id"/>

<field name="active"/>

<field name="company_currency"/>

<field name="x_quote_pickup_city"/>

<field name="x_quote_delivery_city"/>

<field name="x_quote_value"/>

<templates>

<field name="date_deadline"/>

<t t-name="kanban-box">

<div t-attf-class="#{kanban_color(record.color.raw_value)} oe_kanban_global_click">

<div class="o_dropdown_kanban dropdown">

<a class="dropdown-toggle btn" data-toggle="dropdown" href="#">

<span class="fa fa-bars fa-lg"/>

</a>

<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">

<t t-if="widget.editable"><li><a type="edit">Edit</a></li></t>

<t t-if="widget.deletable"><li><a type="delete">Delete</a></li></t>

<li t-if="! record.active.value"><a name="action_set_active" type="object">Unarchive</a></li>

<li t-if="record.active.value"><a name="action_set_unactive" type="object">Archive</a></li>

<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>

</ul>

</div>

<div class="oe_kanban_content">

<div>

<field name="tag_ids"/>

</div>

<div>

<strong><field name="name"/></strong>

</div>

<div>

<span t-if="x_quote_pickup_city.raw_value and x_quote_delivery_city.raw_value">

<t t-raw="x_quote_pickup_city.raw_value"/> →

<t t-raw="x_quote_delivery_city.raw_value"/>

</span>

</div>

<div class="text-muted">

<t t-if="record.planned_revenue.raw_value"><field name="planned_revenue" widget="monetary" options="{'currency_field': 'company_currency'}"/></t> <span t-if="record.partner_id.value"> - <t t-esc="record.partner_id.value"/></span>

</div>

<div class="text-muted">

<t t-if="record.date_action.raw_value and record.date_action.raw_value lt (new Date())" t-set="red">oe_kanban_text_red</t>

<span t-attf-class="#{red || ''}">

<field name="date_action"/>

<t t-if="record.date_action.raw_value"> : </t>

<field name="next_activity_id"/>

</span>

</div>

<div class="o_kanban_footer">

<field name="priority" widget="priority" groups="base.group_user"/>

<t t-if="record.message_needaction_counter.raw_value">

<span class="oe_kanban_mail_new" title="Unread Messages"><i class="fa fa-comments"/><t t-raw="record.message_needaction_counter.raw_value"/></span>

</t>

<img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" width="24" height="24" class="oe_kanban_avatar pull-right"/>

</div>

</div>

<div class="oe_clear"/>

</div>

</t>

</templates>

</kanban>

</xpath>

PS this is for the "CRM - Leads Kanban" view.


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
Extending kanban: template t-call not working ? Resolvido
templates kanban t-call V16
Avatar
1
ago. 24
2236
How to make the order of "default_group_by" in kanban view?
kanban
Avatar
Avatar
1
jan. 25
2782
"harmonised" template for various use cases
templates
Avatar
0
jul. 24
2234
How can i inherit this template? Resolvido
templates
Avatar
Avatar
1
set. 23
2769
How to add search bare in a template that allow to search record in a modele ?
templates
Avatar
Avatar
1
jun. 23
3729
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