[FIX] base: error handling of server actions

Currently when a server action causes an error it raises an Exception
which will be caught by sentry and causes unnecessary traffic.

So, we stop catching exceptoins from server actions which are supposed
to be generated by User's Mistakes.

sentry-4169384356

closes odoo/odoo#121707

Signed-off-by: Adrien Widart (awt) <awt@odoo.com>
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
Rahul Prajapati
2023-05-31 15:54:02 +02:00
committed by Adrien Widart (awt)
parent 3b78f6ae9b
commit 2bd074e26c
+12 -2
View File
@@ -555,7 +555,13 @@ class IrActionsServer(models.Model):
return True
def _run_action_code_multi(self, eval_context):
safe_eval(self.code.strip(), eval_context, mode="exec", nocopy=True, filename=str(self)) # nocopy allows to return 'action'
try:
safe_eval(self.code.strip(), eval_context, mode="exec", nocopy=True, filename=str(self)) # nocopy allows to return 'action'
except Exception as e:
external_id = self.get_external_id().get(self.id)
if not external_id or external_id.startswith('__export__'):
e.sentry_ignored = True
raise
return eval_context.get('action')
def _run_action_multi(self, eval_context=None):
@@ -764,7 +770,11 @@ class IrServerObjectLines(models.Model):
for line in self:
expr = line.value
if line.evaluation_type == 'equation':
expr = safe_eval(line.value, eval_context)
try:
expr = safe_eval(line.value, eval_context)
except Exception as e:
e.sentry_ignored = True
raise
elif line.col1.ttype in ['many2one', 'integer']:
try:
expr = int(line.value)