Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Mail.Activity Creation Error

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
customoeemail.activity
1 Svar
3569 Visninger
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
Kassér
Hayden McCarthy
Forfatter

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
Bedste svar

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
Kassér
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,

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
Self hosting Odoo custom Løst
custom
Avatar
1
aug. 24
2782
Allow follower to mark activity as done without having access to write/create on the main record
mail.activity
Avatar
0
feb. 22
1969
Add a custom field (for storing domains owned) to a Customer record? Løst
custom
Avatar
Avatar
13
mar. 16
6157
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
sep. 15
6787
How do i utilize odoo's websocket connection ?
development custom
Avatar
Avatar
1
aug. 25
2725
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

Website made with

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