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

odoo9: why default value does not work

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
defaultvaluesodoo
7 Respostas
7046 Visualizações
Avatar
Rihene

Hello everybody!!!

I want to put a value by defaut in the currency_id of res_ompany model.

SO i have tried this but nothing appears in odoo.

 def _get_default_currency(self, cr, obj ,context=None):

print('----------------CURRENCY--------------------')

currency_obj = self.pool.get('res.currency')

print ('test1')

print currency_obj

currency_ids = currency_obj.search(cr, obj, [('name','=','DTN')])

print currency_ids

currency_res = currency_obj.read(cr,obj,currency_ids,['id'],context=context)

print currency_res

for v in currency_res :

print v['id']

currency_id = v['id']

return currency_id


_defaults = {'currency_id' : _get_default_currency}

Can anyone help please.

Thanks a lot in advvance.

Best Regards.

0
Avatar
Cancelar
Avatar
Rihene
Autor Melhor resposta

I have understand what happened.

In fact, currency_id field have a default value which is coming from _get_euro function so that i have to override this function and everything will work fine.

 def _get_euro(self, cr, obj ,context=None):

print('----------------CURRENCY--------------------')

currency_obj = self.pool.get('res.currency')

print ('test1')

print currency_obj

currency_ids = currency_obj.search(cr, obj, [('name','=','DTN')])

print currency_ids

currency_res = currency_obj.read(cr,obj,currency_ids,['id'],context=context)

print currency_res

for v in currency_res :

print v['id']

currency_id = v['id']

return currency_id

0
Avatar
Cancelar
Avatar
Kirubanidhi Rajarathinam
Melhor resposta

In odoo9, 

     We use for this code this helpful for you,

currency_id = fields.Many2one('res.currency', string='Currency',default=lambda self: self.env['res.currency'].search([('name','=','USD')]))

0
Avatar
Cancelar
Avatar
Prakash
Melhor resposta

Please Open this link /web#id=3&view_type=form&model=res.currency ,and

check that DTN is  available in res.currency or not ,

By default there is no as currency name DTN.

I am posting the code that i have used, it's work for me  .

def _get_default_currency(self, cr, uid ,context=None):

currency_obj = self.pool.get('res.currency')

currency_id=None

currency_ids = currency_obj.search(cr, uid, [('name','=','USD')],limit=1)

currency_res = currency_obj.read(cr,uid,currency_ids,['id'],context=context)

for v in currency_res :

currency_id = v['id']

return currency_id


0
Avatar
Cancelar
Rihene
Autor

Thanks for the answer friend ;) But, i have added this currency in the table res.currency and it does exist

Prakash

just place a logger before return and check currency_id is None or not

Prakash

+check the indentation _defaults = {} , it's is in the class body or not??

Rihene
Autor

i have inherited the class and make the default value in the second class. I have cheked the result and i got what i want

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
Set default value for Html field!? Resolvido
values odoo
Avatar
Avatar
Avatar
5
mai. 24
14715
using SQL within Odoo...
values sql odoo
Avatar
Avatar
1
fev. 24
3447
How can I get the parent value in the creation of a child? In Odoo 9 Resolvido
default odoo odoo9
Avatar
Avatar
1
out. 22
29356
How to get different default value in different view Resolvido
filter default odoo
Avatar
Avatar
2
out. 22
5096
Why does Odoo store the link not the value of related field?
values link related_fields odoo
Avatar
Avatar
Avatar
2
ago. 25
1998
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