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

what is the differnce between self.env.uid and self.env.user ?

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
developmentcommunitylearnModule
14 Respostas
34838 Visualizações
Avatar
Usman Farzand

thanks in Advance please define it in detail...

1
Avatar
Cancelar
Sehrish

get logged in user id: http://learnopenerp.blogspot.com/2018/08/get-current-logged-in-user-id-in-odoo.html

Avatar
Niyas Raphy (Walnut Software Solutions)
Melhor resposta

Hi,

self.env.uid will give the id of the current user

and

self.env.user will return the current user record

Example

self.env.uid - 1
self.env.user - res.users(1,)

Thanks

15
Avatar
Cancelar
Avatar
Palkesh Baraiya
Melhor resposta

hi, Usman Farzand


self.env.uid will return Id of Current Login User

self.env.user will return Current User Record





2
Avatar
Cancelar
Niyas Raphy (Walnut Software Solutions)

Hey,

Earlier when i have checked my answer it was accepted and have green tick in it, and now it seems the green tick for you answer.

Anything new you have added in the answer ? or my answer is wrong ? was not my clear ?

Niyas Raphy (Walnut Software Solutions)

* was not my answer clear ?

Palkesh Baraiya

no you are right, but you not mentation that Current Login User. i think

Niyas Raphy (Walnut Software Solutions)

What does the meaning of current user ? Didn't see that ? Are you saying current user and current login user is different ?

Look even in your answer you have used current user record.

Usman Farzand
Autor

you both are right can you please any one tell me if it's different from each other

self.env.uid - 1

self.env.user - res.users(1,)

then why condition is same for both ????

@api.multi

def do_clear_done(self):

domain = [('is_done', '=', True),'|',('user_id', '=', self.env.uid),

('user_id', '=', False)]

dones = self.search(domain)

dones.write({'active': False})

return True

@api.multi

def do_toggle_done(self):

for task in self:

if task.user_id != self.env.user:

raise ValidationError('Only the Responsible can do this!')

return super(TodoTask, self).do_toggle_done()

if condition chk and domain chk in same way can any one tell me more in detail sorry i'm beginner

Usman Farzand
Autor

('user_id', '=', self.env.uid),

if task.user_id != self.env.user:

noted point why ?

Palkesh Baraiya

see the thing is, when You simply write 'user_id' than it will return one Object like res.users(1,)

and if you want to put condition on it than u required Object in other side also otherwise it give Error to you. so we use self.env.user.

And For the Domain case i think while You Search any Record or Applying Domain on Record then you need ID of the Record, so domain = [('is_done', '=', True),'|',('user_id', '=', self.env.uid),

Usman Farzand
Autor

@ Palkesh Baraiya if i write

if task.user_id != self.env.id:

excpt this

if task.user_id != self.env.user

is it will correct ?

thanks for answer i clear my more concept....

Palkesh Baraiya

Look If you want to Compare only ID than u can write

if task.user_id.id != self.env.uid:

it will compare your 'user_id' with current Login User ID. like

if 'user_id' = 1 and Current Login user('self.env.uid') = 1

than Condition was fulfil.

and other case was,

if task.user_id != self.env.user

it will use 'user_id' as object like 'res.partner(1,)' and for self.env.user as 'Current Login User Object like res.users(1,)'

Usman Farzand
Autor

excellent thank you soo much @Palkesh Baraiya....thanks again...

Avatar
subbarao
Melhor resposta

self.env.uid will return Database table Id  (ex: admin login --> 1)

self.env.user will return ORM browse object (ex: admin login --> res.user(1))

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
multi tenancy odoo 12 or 13
development community
Avatar
0
mai. 20
3867
How active is the Odoo community?
development community
Avatar
Avatar
1
mar. 15
7728
Load custom module after al other modules
development customization Module
Avatar
0
ago. 16
3483
how to set up odoo community on docker Resolvido
development community docker v17
Avatar
Avatar
Avatar
Avatar
3
abr. 25
21163
What are the differences between Community and Enterprise when it comes to module development?
development community enterprise odoo11
Avatar
Avatar
1
out. 19
4055
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