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>
26 lines
718 B
Python
26 lines
718 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
class ModelA(models.Model):
|
|
_name = "test_rpc.model_a"
|
|
_description = "Model A"
|
|
|
|
name = fields.Char(required=True)
|
|
field_b1 = fields.Many2one("test_rpc.model_b", string="required field", required=True)
|
|
field_b2 = fields.Many2one("test_rpc.model_b", string="restricted field", ondelete="restrict")
|
|
|
|
|
|
class ModelB(models.Model):
|
|
_name = "test_rpc.model_b"
|
|
_description = "Model B"
|
|
|
|
name = fields.Char(required=True)
|
|
value = fields.Integer()
|
|
|
|
_sql_constraints = [
|
|
('qty_positive', 'check (value > 0)', 'The value must be positive'),
|
|
]
|