Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Mail.Activity Creation Error

Naroči se

Get notified when there's activity on this post

This question has been flagged
customoeemail.activity
1 Odgovori
3823 Prikazi
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
Opusti
Hayden McCarthy
Avtor

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
Best Answer

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
Opusti
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!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Self hosting Odoo custom Solved
custom
Avatar
1
avg. 24
2953
Allow follower to mark activity as done without having access to write/create on the main record
mail.activity
Avatar
0
feb. 22
2090
Add a custom field (for storing domains owned) to a Customer record? Solved
custom
Avatar
Avatar
13
mar. 16
6355
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
7000
How do i utilize odoo's websocket connection ?
development custom
Avatar
Avatar
1
avg. 25
3530
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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