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

Mail.Activity Creation Error

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
customoeemail.activity
1 Responder
3828 Visualizações
Avatar
Hayden McCarthy

Hello, I cannot seem to create a mail.activity and evaluate for the user_id value. Please see my code below:

def _create_activity(self):
---"""Create an Odoo activity for the record on creation."""
---self.env['mail.activity'].create({
------'summary': 'Overall Equipment Efficiency',
------'user_id':self.env['res.users'].browse(self.env['ir.config_parameter'].sudo().get_param('oee.responsible_user')),'date_deadline': fields.Datetime.now() +relativedelta(months=1),
------'res_id': self.id,
------'res_model_id': self.env['ir.model']._get_id('oee.log'),
------'note': "Record machine hours from last month. Reference the previous month's record to see that starting hours for that month.",     
})


I am trying to gather the user_id from oee.responsible_user but it keeps giving me an error (Full Traceback)
ERROR: null value in column "user_id" of relation "mail_activity" violates not-null constraint
DETAIL: Failing row contains (15, 624, null, 0, null, null, Overall Equipment Efficiency,

Record machine hours from last month. Reference the previous ..., 2023-08-11, null, null, null, null, null, 2, 2023-07-11 17:52:38.94198, 2, 2023-07-11 17:52:38.94198).
2023-07-11 17:52:38,992 51 ERROR ******-odoo-sh-testing-8932533 odoo.http: Exception during JSON request handling.
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/tools/safe_eval.py", line 332, in safe_eval
return unsafe_eval(c, globals_dict, locals_dict)
File "", line 1, in
File "/home/odoo/src/user/nxc_oee/models/oee.py", line 61, in _create_activity
self.env['mail.activity'].create({
File "", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 412, in _model_create_multi
return create(self, [arg])
File "/home/odoo/src/odoo/addons/mail/models/mail_activity.py", line 263, in create
activities = super(MailActivity, self).create(vals_list)
File "", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_fields.py", line 613, in create
recs = super().create(vals_list)
File "", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/home/odoo/src/odoo/odoo/models.py", line 4081, in create
records = self._create(data_list)
File "/home/odoo/src/odoo/odoo/models.py", line 4179, in _create
cr.execute(query, params)
File "", line 2, in execute
File "/home/odoo/src/odoo/odoo/sql_db.py", line 90, in check
return f(self, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/sql_db.py", line 311, in execute
res = self._obj.execute(query, params)
psycopg2.errors.NotNullViolation: null value in column "user_id" of relation "mail_activity" violates not-null constraint
DETAIL: Failing row contains (15, 624, null, 0, null, null, Overall Equipment Efficiency,

Record machine hours from last month. Reference the previous ..., 2023-08-11, null, null, null, null, null, 2, 2023-07-11 17:52:38.94198, 2, 2023-07-11 17:52:38.94198).


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/odoo/src/odoo/odoo/http.py", line 698, in dispatch
result = self._call_function(**self.params)
File "/home/odoo/src/odoo/odoo/http.py", line 368, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/http.py", line 357, in checked_call
result = self.endpoint(*a, **kw)
File "/home/odoo/src/odoo/odoo/http.py", line 921, in __call__
return self.method(*args, **kw)
File "/home/odoo/src/odoo/odoo/http.py", line 546, in response_wrap
response = f(*args, **kw)
File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1324, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1316, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/odoo/src/odoo/odoo/api.py", line 462, in call_kw
result = _call_kw_model_create(method, model, args, kwargs)
File "/home/odoo/src/odoo/odoo/api.py", line 442, in _call_kw_model_create
result = method(recs, *args, **kwargs)
File "", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 412, in _model_create_multi
return create(self, [arg])
File "/home/odoo/src/odoo/addons/base_automation/models/base_automation.py", line 324, in create
action._process(action._filter_post(records))
File "/home/odoo/src/odoo/addons/base_automation/models/base_automation.py", line 274, in _process
raise e
File "/home/odoo/src/odoo/addons/base_automation/models/base_automation.py", line 271, in _process
action_server.sudo().with_context(**ctx).run()
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_actions.py", line 643, in run
res = runner(run_self, eval_context=eval_context)
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_actions.py", line 512, in _run_action_code_multi
safe_eval(self.code.strip(), eval_context, mode="exec", nocopy=True) # nocopy allows to return 'action'
File "/home/odoo/src/odoo/odoo/tools/safe_eval.py", line 348, in safe_eval
raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))
Exceptiond

:


The responsible_user field is many2one on the res.users model. Might anyone here know this can be resolved? Am I retrieving the value improperly?

0
Avatar
Cancelar
Hayden McCarthy
Autor

Neha Kakkar, thank you for the reply. I printed the value of the config parameter (oee.responsible_user) using the logger. It is showing a null value, even though the value has been set in the UI. When I leave odoo settings and come back the value I set is still stored. I am not quite sure why this is happening but I will post here when I find the solution.

Avatar
Neha Kakkar
Melhor resposta

The value for user_id seems to be None, which is causing the error.
Check the value of oee.responsible_user.  The value returned by self.env['ir.config_parameter'].sudo().get_param('oee.responsible_user') is a valid user ID.
You can print the value to check its correctness.

0
Avatar
Cancelar
Neha Kakkar

Thank you for providing the additional information. If the oee.responsible_user configuration parameter is showing a null value despite being set in the UI and saved, it suggestsThat there might be an issue with the retrieval of the configuration parameter.

Check the code where the oee.responsible_user configuration parameter is set.
Might be typos or inconsistencies in the code that might be causing this issue.

Also Check if there are any other parts of your codebase that might be modifying or overriding the oee.responsible_user configuration parameter. Look for any customizations or other modules that might affect its value.
Verify if there are any access restrictions or permissions in place that could prevent the retrieval of the configuration parameter.
One more Important things that you can do restarting the Odoo server or refreshing the environment to ensure that the latest changes are reflected in the system. Sometimes, changes made in the UI might require a server restart to take effect.

Please keep us updated on any progress or findings you come across,

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
Self hosting Odoo custom Resolvido
custom
Avatar
1
ago. 24
2959
Allow follower to mark activity as done without having access to write/create on the main record
mail.activity
Avatar
0
fev. 22
2097
Add a custom field (for storing domains owned) to a Customer record? Resolvido
custom
Avatar
Avatar
13
mar. 16
6359
When i try to print a custom report i get a InternalError: current transaction is aborted, commands ignored until end of transaction block
custom
Avatar
Avatar
1
set. 15
7009
How do i utilize odoo's websocket connection ?
development custom
Avatar
Avatar
1
ago. 25
3546
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