diff options
| author | Martin Trigaux <mat@odoo.com> | 2019-01-25 15:04:42 +0000 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2019-08-19 11:44:34 +0000 |
| commit | 7593b887dff4fcd474ca72aead6825481b419d86 (patch) | |
| tree | 28c5445d1440701de5c7534e1d8accef222798d8 /odoo/addons/test_new_api | |
| parent | a248171d96de3ad6d8e22c855886dfae61e145e2 (diff) | |
[REF] fields: use ir.model.fields.selection
The selection values of a selection field are now stored in database in the
model ir.model.fields.selection
This will allow to have a modular approche on selections and each selection
is now linked to the module that declared it.
Previously to this change, the selections were linked to the field, meaning
uninstalling a module had no impact on the selections stored on database.
With this change, the selections will now be translated in the correct module
(having an external id) and the records having a used selection will now be
reset to null.
closes odoo/odoo#30228
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Co-authored-by: Raphaƫl Collet <rco@odoo.com>
Diffstat (limited to 'odoo/addons/test_new_api')
| -rw-r--r-- | odoo/addons/test_new_api/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | odoo/addons/test_new_api/models.py | 7 | ||||
| -rw-r--r-- | odoo/addons/test_new_api/tests/test_schema.py | 6 |
3 files changed, 14 insertions, 0 deletions
diff --git a/odoo/addons/test_new_api/ir.model.access.csv b/odoo/addons/test_new_api/ir.model.access.csv index 3db5381a4b9..5e9aceeab50 100644 --- a/odoo/addons/test_new_api/ir.model.access.csv +++ b/odoo/addons/test_new_api/ir.model.access.csv @@ -30,6 +30,7 @@ access_test_new_api_monetary_custom,access_test_new_api_monetary_custom,model_te access_test_new_api_monetary_inherits,access_test_new_api_monetary_inherits,model_test_new_api_monetary_inherits,,1,1,1,1 access_test_new_api_field_with_caps,access_test_new_api_field_with_caps,model_test_new_api_field_with_caps,,1,1,1,1 access_test_new_api_req_m2o,access_test_new_api_req_m2o,model_test_new_api_req_m2o,,1,1,1,1 +access_test_new_api_selection,access_test_new_api_selection,model_test_new_api_selection,,1,1,1,1 access_test_new_api_attachment,access_test_new_api_attachment,model_test_new_api_attachment,,1,1,1,1 access_test_new_api_attachment_host,access_test_new_api_attachment_host,model_test_new_api_attachment_host,,1,1,1,1 access_test_new_api_model_image,access_test_new_api_model_image,model_test_new_api_model_image,,1,1,1,1 diff --git a/odoo/addons/test_new_api/models.py b/odoo/addons/test_new_api/models.py index e045754bcc2..b4cf23290ba 100644 --- a/odoo/addons/test_new_api/models.py +++ b/odoo/addons/test_new_api/models.py @@ -543,6 +543,13 @@ class FieldWithCaps(models.Model): pArTneR_321_id = fields.Many2one('res.partner') +class Selection(models.Model): + _name = 'test_new_api.selection' + _description = "Selection" + + state = fields.Selection([('foo', 'Foo'), ('bar', 'Bar')]) + + class RequiredM2O(models.Model): _name = 'test_new_api.req_m2o' _description = 'Required Many2one' diff --git a/odoo/addons/test_new_api/tests/test_schema.py b/odoo/addons/test_new_api/tests/test_schema.py index 6e79da8f362..6ede0e833d5 100644 --- a/odoo/addons/test_new_api/tests/test_schema.py +++ b/odoo/addons/test_new_api/tests/test_schema.py @@ -44,6 +44,12 @@ class TestReflection(common.TransactionCase): relation = self.env['ir.model.relation'].search([('name', '=', field.relation)]) self.assertTrue(relation) self.assertIn(relation.model.model, [field.model_name, field.comodel_name]) + if field.type == 'selection': + selection = [(sel.value, sel.name) for sel in ir_field.selection_ids] + if isinstance(field.selection, list): + self.assertEqual(selection, field.selection) + else: + self.assertEqual(selection, []) class TestSchema(common.TransactionCase): |
