[MERGE] forward port branch 10.0 up to 24b677a359

This commit is contained in:
Christophe Simonis
2019-07-03 19:23:14 +02:00
2 changed files with 10 additions and 6 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ class ModelA(models.Model):
_description = "Model A" _description = "Model A"
name = fields.Char(required=True) name = fields.Char(required=True)
field_b1 = fields.Many2one("test_rpc.model_b", required=True) field_b1 = fields.Many2one("test_rpc.model_b", string="required field", required=True)
field_b2 = fields.Many2one("test_rpc.model_b", ondelete="restrict") field_b2 = fields.Many2one("test_rpc.model_b", string="restricted field", ondelete="restrict")
class ModelB(models.Model): class ModelB(models.Model):
+8 -4
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from odoo.tests import common from odoo.tests import common
from odoo.tools.misc import mute_logger
class TestError(common.HttpCase): class TestError(common.HttpCase):
@@ -15,7 +16,8 @@ class TestError(common.HttpCase):
""" Create: mandatory field not provided """ """ Create: mandatory field not provided """
self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "create", {"name": "B1"}) self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "create", {"name": "B1"})
try: try:
self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "create", {}) with mute_logger("odoo.sql_db"):
self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "create", {})
raise raise
except Exception as e: except Exception as e:
self.assertIn("The operation cannot be completed:", e.faultString) self.assertIn("The operation cannot be completed:", e.faultString)
@@ -38,7 +40,8 @@ class TestError(common.HttpCase):
# FORWARD-PORT: in master, `required=True` implies `ondelete="restrict"` # FORWARD-PORT: in master, `required=True` implies `ondelete="restrict"`
# => the message should be the same than 'Unlink b2' case. # => the message should be the same than 'Unlink b2' case.
try: try:
self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "unlink", b1) with mute_logger("odoo.sql_db"):
self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "unlink", b1)
raise raise
except Exception as e: except Exception as e:
self.assertIn("The operation cannot be completed:", e.faultString) self.assertIn("The operation cannot be completed:", e.faultString)
@@ -47,11 +50,12 @@ class TestError(common.HttpCase):
"Delete: another model requires the record being deleted. If possible, archive it instead.", "Delete: another model requires the record being deleted. If possible, archive it instead.",
e.faultString, e.faultString,
) )
self.assertIn("Model: Model A (test_rpc.model_a), Field: Field b1 (field_b1)", e.faultString) self.assertIn("Model: Model A (test_rpc.model_a), Field: required field (field_b1)", e.faultString)
# Unlink b2 => ON DELETE RESTRICT constraint raises # Unlink b2 => ON DELETE RESTRICT constraint raises
try: try:
self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "unlink", b2) with mute_logger("odoo.sql_db"):
self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "unlink", b2)
raise raise
except Exception as e: except Exception as e:
self.assertIn("The operation cannot be completed:", e.faultString) self.assertIn("The operation cannot be completed:", e.faultString)