summaryrefslogtreecommitdiff
path: root/odoo/addons/test_new_api/tests/test_new_fields.py
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2020-03-02 13:10:05 +0000
committerAdrian Torres <adt@odoo.com>2020-03-04 15:39:18 +0000
commit26680badef1a8d2091ada0434ca6dcbe0c85b26b (patch)
treef77449d62dc3c78e9353478f8c5af383210fc5d6 /odoo/addons/test_new_api/tests/test_new_fields.py
parentbabf9e4f2c20d31c18b959133d80ae23cda38631 (diff)
[FIX] base: handle custom non-stored m2m
Before this commit, one could create a custom, non-stored m2m field through the web interface BUT the deletion of the custom field would be impossible after saving the form. This is due to the fact that the relation would not be stored in DB since the field is store=False, therefore the value of the relation would equal to None, and since the unlinking mechanism assumes that the value is never None, it tries to drop a table of name None, which does not exist. closes odoo/odoo#46909 X-original-commit: cdd1439a380810569db80d984c8cb80d213b1bf3 Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
Diffstat (limited to 'odoo/addons/test_new_api/tests/test_new_fields.py')
-rw-r--r--odoo/addons/test_new_api/tests/test_new_fields.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/odoo/addons/test_new_api/tests/test_new_fields.py b/odoo/addons/test_new_api/tests/test_new_fields.py
index 0712e088f78..3204b25bfe6 100644
--- a/odoo/addons/test_new_api/tests/test_new_fields.py
+++ b/odoo/addons/test_new_api/tests/test_new_fields.py
@@ -2037,6 +2037,18 @@ class TestX2many(common.TransactionCase):
for line in lines:
self.assertEqual(len(line.tags), 3)
+ def test_custom_m2m(self):
+ model_id = self.env['ir.model']._get_id('res.partner')
+ field = self.env['ir.model.fields'].create({
+ 'name': 'x_foo',
+ 'field_description': 'Foo',
+ 'model_id': model_id,
+ 'ttype': 'many2many',
+ 'relation': 'res.country',
+ 'store': False,
+ })
+ self.assertTrue(field.unlink())
+
class TestHtmlField(common.TransactionCase):