Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] ir_model_fields: register selection options #31207

Closed
wants to merge 1 commit into
base: 11.0
from

Conversation

Projects
None yet
7 participants
@Elkasitu
Copy link
Contributor

Elkasitu commented Feb 18, 2019

Before this commit:
-> Debug mode
-> Settings
-> Database structure
-> Fields
-> Any selection field
=> The field selection of the ir.model.fields form view does not
display the selection options of the field being viewed, this is because
the selection field is not registered at _reflect_field_params of
ir.model.fields.

After this commit:

The field is properly registered; for Selection fields with static
options, these are shown as-is, for fields with a lambda function as
options, the string 'function' is displayed, and for fields using a
function name as a string, the same string will be displayed.

Fixes #28360

@Elkasitu Elkasitu requested a review from rco-odoo Feb 18, 2019

@robodoo robodoo added the seen 🙂 label Feb 18, 2019

@C3POdoo C3POdoo added the RD label Feb 18, 2019

@robodoo robodoo added the CI 🤖 label Feb 18, 2019

@Elkasitu Elkasitu force-pushed the odoo-dev:11.0-fix-selection-ir-model-fields-adt branch Feb 20, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Feb 20, 2019

[FIX] ir_model_fields: register selection options
Before this commit:
        -> Debug mode
        -> Settings
        -> Database structure
        -> Fields
        -> Any selection field
=> The field `selection` of the ir.model.fields form view does not
display the selection options of the field being viewed, this is because
the selection field is not registered at `_reflect_field_params` of
`ir.model.fields`.

After this commit:

The field is properly registered; for Selection fields with static
options, these are shown as-is, for fields with a lambda function as
options, the string 'function' is displayed, and for fields using a
function name as a string, the same string will be displayed.

Fixes #28360

@Elkasitu Elkasitu force-pushed the odoo-dev:11.0-fix-selection-ir-model-fields-adt branch to 7599603 Feb 26, 2019

@robodoo robodoo removed the CI 🤖 label Feb 26, 2019

@rco-odoo
Copy link
Member

rco-odoo left a comment

robodoo pushed a commit that referenced this pull request Feb 26, 2019

[FIX] ir_model_fields: register selection options
Before this commit:
        -> Debug mode
        -> Settings
        -> Database structure
        -> Fields
        -> Any selection field
=> The field `selection` of the ir.model.fields form view does not
display the selection options of the field being viewed, this is because
the selection field is not registered at `_reflect_field_params` of
`ir.model.fields`.

After this commit:

The field is properly registered; for Selection fields with static
options, these are shown as-is, for fields with a lambda function as
options, the string 'function' is displayed, and for fields using a
function name as a string, the same string will be displayed.

Fixes #28360

closes #31207
@robodoo

This comment has been minimized.

Copy link
Contributor

robodoo commented Feb 26, 2019

Merged, thanks!

@robodoo robodoo closed this Feb 26, 2019

@luisg123v

This comment has been minimized.

Copy link
Contributor

luisg123v commented Feb 27, 2019

@Elkasitu @rco-odoo
After this change, I get an exception when trying to create a selection field from an XML data. AFAIK, it's because the selection attribute is set to None when it's not a list, and when a selection field is created from an XML, the selection attribute is a string.

Here I leave the full traceback:

Traceback (most recent call last):
  File "/.repo_requirements/odoo/odoo/tools/safe_eval.py", line 206, in test_expr
    expr = expr.strip()
AttributeError: 'NoneType' object has no attribute 'strip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.repo_requirements/odoo/odoo/modules/registry.py", line 85, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/.repo_requirements/odoo/odoo/modules/loading.py", line 380, in load_modules
    loaded_modules, update_module, models_to_check)
  File "/.repo_requirements/odoo/odoo/modules/loading.py", line 274, in load_marked_modules
    perform_checks=perform_checks, models_to_check=models_to_check
  File "/.repo_requirements/odoo/odoo/modules/loading.py", line 134, in load_module_graph
    registry.setup_models(cr)
  File "/.repo_requirements/odoo/odoo/modules/registry.py", line 274, in setup_models
    model._setup_base()
  File "/.repo_requirements/odoo/odoo/models.py", line 2401, in _setup_base
    self.env['ir.model.fields']._add_manual_fields(self)
  File "/home/odoo/odoo-11.0/odoo/addons/base/ir/ir_model.py", line 908, in _add_manual_fields
    field = self._instanciate(field_data)
  File "/home/odoo/odoo-11.0/odoo/addons/base/ir/ir_model.py", line 899, in _instanciate
    attrs = self._instanciate_attrs(field_data)
  File "/home/odoo/odoo-11.0/addons/mail/models/ir_model.py", line 70, in _instanciate_attrs
    attrs = super(IrModelField, self)._instanciate_attrs(field_data)
  File "/home/odoo/odoo-11.0/odoo/addons/base/ir/ir_model.py", line 864, in _instanciate_attrs
    attrs['selection'] = safe_eval(field_data['selection'])
  File "/.repo_requirements/odoo/odoo/tools/safe_eval.py", line 348, in safe_eval
    c = test_expr(expr, _SAFE_OPCODES, mode=mode)
  File "/.repo_requirements/odoo/odoo/tools/safe_eval.py", line 212, in test_expr
    pycompat.reraise(ValueError, ValueError('"%s" while compiling\n%r' % (ustr(e), expr)), exc_info[2])
  File "/.repo_requirements/odoo/odoo/tools/pycompat.py", line 86, in reraise
    raise value.with_traceback(tb)
  File "/.repo_requirements/odoo/odoo/tools/safe_eval.py", line 206, in test_expr
    expr = expr.strip()
ValueError: "'NoneType' object has no attribute 'strip'" while compiling
None
CRITICAL com odoo.service.server: Failed to initialize database `com`.
Traceback (most recent call last):
  File "/.repo_requirements/odoo/odoo/tools/safe_eval.py", line 206, in test_expr
    expr = expr.strip()
AttributeError: 'NoneType' object has no attribute 'strip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.repo_requirements/odoo/odoo/service/server.py", line 945, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/.repo_requirements/odoo/odoo/modules/registry.py", line 85, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/.repo_requirements/odoo/odoo/modules/loading.py", line 380, in load_modules
    loaded_modules, update_module, models_to_check)
  File "/.repo_requirements/odoo/odoo/modules/loading.py", line 274, in load_marked_modules
    perform_checks=perform_checks, models_to_check=models_to_check
  File "/.repo_requirements/odoo/odoo/modules/loading.py", line 134, in load_module_graph
    registry.setup_models(cr)
  File "/.repo_requirements/odoo/odoo/modules/registry.py", line 274, in setup_models
    model._setup_base()
  File "/.repo_requirements/odoo/odoo/models.py", line 2401, in _setup_base
    self.env['ir.model.fields']._add_manual_fields(self)
  File "/home/odoo/odoo-11.0/odoo/addons/base/ir/ir_model.py", line 908, in _add_manual_fields
    field = self._instanciate(field_data)
  File "/home/odoo/odoo-11.0/odoo/addons/base/ir/ir_model.py", line 899, in _instanciate
    attrs = self._instanciate_attrs(field_data)
  File "/home/odoo/odoo-11.0/addons/mail/models/ir_model.py", line 70, in _instanciate_attrs
    attrs = super(IrModelField, self)._instanciate_attrs(field_data)
  File "/home/odoo/odoo-11.0/odoo/addons/base/ir/ir_model.py", line 864, in _instanciate_attrs
    attrs['selection'] = safe_eval(field_data['selection'])
  File "/.repo_requirements/odoo/odoo/tools/safe_eval.py", line 348, in safe_eval
    c = test_expr(expr, _SAFE_OPCODES, mode=mode)
  File "/.repo_requirements/odoo/odoo/tools/safe_eval.py", line 212, in test_expr
    pycompat.reraise(ValueError, ValueError('"%s" while compiling\n%r' % (ustr(e), expr)), exc_info[2])
  File "/.repo_requirements/odoo/odoo/tools/pycompat.py", line 86, in reraise
    raise value.with_traceback(tb)
  File "/.repo_requirements/odoo/odoo/tools/safe_eval.py", line 206, in test_expr
    expr = expr.strip()
ValueError: "'NoneType' object has no attribute 'strip'" while compiling
None

CC @luistorresm

@nje-odoo

This comment has been minimized.

Copy link
Contributor

nje-odoo commented Feb 27, 2019

Hello @Elkasitu @rco-odoo I'm getting same error as above, can you please check?
Thanks.

@Elkasitu

This comment has been minimized.

Copy link
Contributor Author

Elkasitu commented Feb 27, 2019

The bug is being tracked at #31447

@odony odony deleted the odoo-dev:11.0-fix-selection-ir-model-fields-adt branch Feb 27, 2019

@odony

This comment has been minimized.

Copy link
Contributor

odony commented Feb 27, 2019

This PR was reverted via #31466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.