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

Odoo 11: Wrong values when using widget float_time in qweb report

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
float_timeWidgetsqweb-reportodoo11community
2 Respostas
6288 Visualizações
Avatar
TK

I am customizing the attendance model and made a wizard that displays a table with an overview of worktime, begin, end and overtime. 

Fields worktime, begin, end and overtime are all fields.Float()

I am using widget='float_time' to display them in the form view of the model. 






I wanted to create a report of that overview that is displayed as qweb-html and can be printed if necessary. 

I created an xml template and used 

It seemed to work because the end field was printed like 18:21.

I compared the form view and the qweb view and discovered that the values are different. 

Some values are just one minute below or above the form view value (ok the rounding seems to work differently) but others are completely nonsense. 

Especially the field overtime differs a lot. 

Form view: -06:40  qweb: -07:19

the correct value that I calculated by hand is -06:40 meaning a float value of -6.66666


Question 1) Where is the calculation difference ? What function is used by the form view and what function is used by the qweb view ?

I only found /web/static/src/js/fields/field_utils.js where there is a formatFloatTime() and a parseFloatTime() function. 


Question 2) Why are the qweb values sometimes completely wrong? 


Yes, I made sure that the field values are completely identical. I even displayed the float values in the qweb report and could validate that they are correct. It is "only" a formatting issue.

0
Avatar
Cancelar
TK
Autor

test

TK
Autor

I finally found the answer and if somebody comes across this ...here you are ...

There are indeed two places where conversion is made:

#####################################################

Form view: Javascript method in /web/static/src/js/fields/field_utils.js

#####################################################

function formatFloatTime(value) {

var pattern = '%02d:%02d';

if (value < 0) {

value = Math.abs(value);

pattern = '-' + pattern;

}

var hour = Math.floor(value);

var min = Math.round((value % 1) * 60);

if (min === 60){

min = 0;

hour = hour + 1;

}

return _.str.sprintf(pattern, hour, min);

###########################

QWeb view:

In module base/ir/ir_qweb/fields.py

###########################

class FloatTimeConverter(models.AbstractModel):

""" ``float_time`` converter, to display integral or fractional values as

human-readable time spans (e.g. 1.5 as "01:30").

Can be used on any numerical field.

"""

_name = 'ir.qweb.field.float_time'

_inherit = 'ir.qweb.field'

@api.model

def value_to_html(self, value, options):

hours, minutes = divmod(value * 60, 60)

return '%02d:%02d' % (hours, minutes)

It seems that Math.round and Math.floor behaves differently compared to python divmod function. At least I had huge differences.

Avatar
TK
Autor Melhor resposta

Thanks for your answer Karthikeyan if I understand it right, you say there is no difference using the widget in form view and in qweb, but I had different results. There must be a difference. 

Unforunately, I am not used to debugging of javascript otherwise I could follow the code step by step as I do in python code. 


Reply to comment:

If there is a difference while printing in excel where does this come from? Please explain if you know.

0
Avatar
Cancelar
Begineer

Yeah, the difference will arise only if you print that in excel report

Avatar
Begineer
Melhor resposta

Hi,

    I guess you figured its a formatting issue,

In form view you have used the widget float_time,  to convert the float value into time format (HH:MM)

Same goes while generating a qweb ,  

span t-field="o.your_float_field" t-options= '{"widget": "float_time"}'


I couldn't open and close span tag , make sure you do.

Hope it helps,

Thanks


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
Print values of field variables declared inside html content Odoo11? Resolvido
html qweb-report odoo11community
Avatar
Avatar
Avatar
Avatar
7
nov. 18
13353
Odoo stays in the loading screen after report is generated
report bug qweb-report odoo11 odoo11community
Avatar
Avatar
3
jan. 23
7156
Qweb Report : which font display proper output when print PDF in DOT-MATRIX printer ? [ODOO V11 CE]
printer linux_system qweb-report odoo11community dot-matrix
Avatar
Avatar
1
set. 20
7060
while print pdf report it takes too much loading time.
loading wkhtmltopdf qweb-report odoo11community printpdf
Avatar
Avatar
1
dez. 19
6732
Conversion from float_time to float
float_time
Avatar
Avatar
Avatar
2
nov. 24
8940
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