Commit Graph
3 Commits
Author SHA1 Message Date
Adrien Widart (awt) 28075c915b [FIX] core: translate SQL constraints
To reproduce the issue:
1. Install `mrp`
2. Send a RPC to create a new BoM:
   - `{"product_tmpl_id": 1, "product_qty": -1}`

Error: It will generate a traceback

Because of the negative product qty, the RPC triggers a SQL constraint
that we try to return. However, the context does not have any `lang`,
hence the traceback

sentry-4088426130

closes odoo/odoo#120614

X-original-commit: badc554b9dd7a299aac8ebca24bec6b90bef779a
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
Signed-off-by: Rémy Voet <ryv@odoo.com>
2023-05-09 11:57:14 +02:00
Christophe Simonis 24b677a359 [FIX] test_rpc: more robust tests
- mute logger to avoid logging bad queries
 - enforce fields strings

These changes will forbid tests to fail in following versions.
2019-07-03 19:20:31 +02:00
6b647139b4 [IMP] base: make the integrity constraint violation error messages clearer
When an `IntegrityError` is raised, the user receives a cryptic error
message which doesn't provide much valuable information in order to
solve the problem.

However, such an error is raised in 3 cases:
1. A mandatory field is not provided at creation/update.
2. The deletion of a record makes a mandatory Many2one field NULL on a
referenced table (`ON DELETE SET NULL` on a not nullable field).
3. The deletion of a record raises a `ON DELETE RESTRICT` foreign-key
constaints.

In the first and second cases, we provide the table and field on which
the `NOT NULL` constaint is raised. We also suggest to archive the
record in case of a deletion.

In the third case, we provide the table and the constraint raised. We
also suggest to archive the record.

Notes:
- The IDs of the records causing the issue is not provided since the
information is not provided by PostgreSQL.
- Although cases 2 and 3 have a different root cause, the error
message raised is very similar. Indeed, from an end-user perspective
the solution is identical: archive the record. Another solution would
also be to manually edit the records raising the error, but most of
the time this is not an option: these records are locked and cannot be
edited anymore.

task-1970853
Closes #32949

closes odoo/odoo#33922

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>


Co-authored-by: Sapan Zaveri <sza@odoo.com>
Co-authored-by: Pragya Ladda <pla@odoo.com>
2019-06-28 07:57:26 +00:00