Skip to Content
Menu
This question has been flagged
1 Reply
2155 Views

I have a model:

ledger_id = fields.Many2one('contribution.ledger', default=_get_default_ledger_id, readonly=True)
is_owner = fields.Boolean()
owner_id = fields.Many2one('res.partner', related='ledger_id.owner_id')
line_id = fields.Many2one('contribution.ledger.line')
partner_id = fields.Many2one('res.partner', related='line_id.partner_id')

Then I have a view with:

name="close_price_comm"
attrs="{'invisible': ['|', ('is_owner', '=', True), ('partner_id', '=', owner_id)]}"/>

What I want is that close_price_comm will be invisible when either is_owner is True or partner_id is equal to owner_id. But when I open the view, I got the error message:

Traceback (most recent call last):
  File "/Users/giangnguyen/odoo/odoo/tools/cache.py", line 85, in lookup
    r = d[key]
  File "", line 2, in __getitem__
  File "/Users/giangnguyen/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/Users/giangnguyen/odoo/odoo/tools/lru.py", line 34, in __getitem__
    a = self.d[obj]
KeyError: ('contribution.ledger.close.wizard', , (False, 'form', None, 'en_US'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/giangnguyen/odoo/odoo/http.py", line 1584, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/Users/giangnguyen/odoo/odoo/service/model.py", line 134, in retrying
    result = func()
  File "/Users/giangnguyen/odoo/odoo/http.py", line 1613, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/Users/giangnguyen/odoo/odoo/http.py", line 1810, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "/Users/giangnguyen/odoo/odoo/addons/base/models/ir_http.py", line 149, in _dispatch
    result = endpoint(**request.params)
  File "/Users/giangnguyen/odoo/odoo/http.py", line 699, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/Users/giangnguyen/odoo/addons/web/controllers/dataset.py", line 42, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/Users/giangnguyen/odoo/addons/web/controllers/dataset.py", line 33, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/Users/giangnguyen/odoo/odoo/api.py", line 457, in call_kw
    result = _call_kw_model(method, model, args, kwargs)
  File "/Users/giangnguyen/odoo/odoo/api.py", line 430, in _call_kw_model
    result = method(recs, *args, **kwargs)
  File "/Users/giangnguyen/odoo/odoo/addons/base/models/ir_ui_view.py", line 2481, in get_views
    result['views'] = {
  File "/Users/giangnguyen/odoo/odoo/addons/base/models/ir_ui_view.py", line 2482, in 
    v_type: self.get_view(
  File "/Users/giangnguyen/odoo/odoo/addons/base/models/ir_ui_view.py", line 2666, in get_view
    result = dict(self._get_view_cache(view_id, view_type, **options))
  File "", line 2, in _get_view_cache
  File "/Users/giangnguyen/odoo/odoo/tools/cache.py", line 90, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/Users/giangnguyen/odoo/odoo/addons/base/models/ir_ui_view.py", line 2629, in _get_view_cache
    arch, models = view.postprocess_and_fields(arch, model=self._name, **options)
  File "/Users/giangnguyen/odoo/odoo/addons/base/models/ir_ui_view.py", line 1028, in postprocess_and_fields
    name_manager = self._postprocess_view(node, model or self.model, **options)
  File "/Users/giangnguyen/odoo/odoo/addons/base/models/ir_ui_view.py", line 1173, in _postprocess_view
    transfer_node_to_modifiers(node, node_info['modifiers'])
  File "/Users/giangnguyen/odoo/odoo/addons/base/models/ir_ui_view.py", line 84, in transfer_node_to_modifiers
    modifiers.update(ast.literal_eval(attrs.strip()))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py", line 99, in literal_eval
    return _convert(node_or_string)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py", line 88, in _convert
    return dict(zip(map(_convert, node.keys),
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py", line 82, in _convert
    return list(map(_convert, node.elts))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py", line 80, in _convert
    return tuple(map(_convert, node.elts))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py", line 98, in _convert
    return _convert_signed_num(node)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py", line 75, in _convert_signed_num
    return _convert_num(node)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py", line 66, in _convert_num
    _raise_malformed_node(node)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py", line 63, in _raise_malformed_node
    raise ValueError(f'malformed node or string: {node!r}')
ValueError: malformed node or string: 

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    RPCError@http://localhost:8069/web/assets/187-f5f4315/web.assets_backend.min.js:963:279
    makeErrorFromResponse@http://localhost:8069/web/assets/187-f5f4315/web.assets_backend.min.js:967:175
    @http://localhost:8069/web/assets/187-f5f4315/web.assets_backend.min.js:975:34

Please help. Thank you!

Avatar
Discard

Mention your complete model name with fields and if there are two model show two model may be that owner_id field exist in one model but not exist on another in which close_price_comm field exist. Please specify your model correctly

Author

close_price_comm is in the same model with ledger_id, is_owner, owner_id, line_id, partner_id. Sorry but my model is quite long so I can't mention it here.

Best Answer

Hi, 

Try like this,

<field name="close_price_comm" attrs="{'invisible': ['|', ('is_owner', '=', True), ('partner_id', '=', 'owner_id')]}"/>


Thanks

Avatar
Discard
Author

I tried your suggestion and got no error message but the close_price_comm field does not hide even I select the line id with the same partner_id as owner_id. Please help!

Related Posts Replies Views Activity
3
Nov 24
2953
5
Nov 24
7472
2
Oct 24
2888
4
Oct 24
1869
2
Oct 24
4027