# Is "resources" as field definition forbidden?

**URL:** <https://discuss.tryton.org/t/is-resources-as-field-definition-forbidden/2089>\
**Category:** Developer\
**Created:** [December 16, 2019, 6:39pm UTC](https://discuss.tryton.org/t/is-resources-as-field-definition-forbidden/2089 "2019-12-16T18:39:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [December 16, 2019, 6:39pm UTC](https://discuss.tryton.org/t/is-resources-as-field-definition-forbidden/2089/1 "2019-12-16T18:39:43Z")

</div>

I have again something weird going on with a One2Many field. This time I get

```auto
Traceback (most recent call last):
  File "/trytond/wsgi.py", line 108, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 48, in rpc
    request, database_name, *request.rpc_params)
  File "/trytond/wsgi.py", line 76, in auth_required
    return wrapped(*args, **kwargs)
  File "/trytond/protocols/wrappers.py", line 131, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 186, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
TypeError: 'One2Many' object is not callable

```

This error pops up about 1 second after you have opened a list / form view. After you have clicked the error away, you can proceed with everything without loosing data.  
It’s a very simple scheme:

```auto
class ReviewActivityResources(ModelSQL, ModelView):
    __name__ = 'review.activity.resources'

    review = fields.Many2One('review.activity', 'Review')

class ReviewActivity(Workflow, ModelSQL, ModelView):
    __name__ = "review.activity"

    resources = fields.One2Many('review.activity.resources', 
        'review', 'Resources')

```

When I rename `resources` to for example `activity_resources` the error is gone. I have multiple models with a `resources` field and they all have the same behavior.

---

<div class="post-metadata">

**Author:** ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)\
**Post date:** [December 16, 2019, 7:04pm UTC](https://discuss.tryton.org/t/is-resources-as-field-definition-forbidden/2089/2 "2019-12-16T19:04:35Z")

</div>

I think it is because your `resources` field is overriding the `resources` function in [modelstorage.py](https://hg.tryton.org/trytond/file/tip/trytond/model/modelstorage.py#l554). Thats why it works when called `activity_resources`.

---

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [December 16, 2019, 7:14pm UTC](https://discuss.tryton.org/t/is-resources-as-field-definition-forbidden/2089/3 "2019-12-16T19:14:22Z")

</div>

> [@dave](#):
>
> because your `resources` field is overriding the `resources` function in [modelstorage.py](https://hg.tryton.org/trytond/file/tip/trytond/model/modelstorage.py#l554)

And together with Tryton being much stricter what to do with fields and their data, this makes sense. I also have a wizard with a `resources` field which doesn’t have any problem. This is because I’m not inheriting the ModelStorage class.

---

<div class="post-metadata">

**Author:** ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)\
**Post date:** [January 15, 2020, 7:14pm UTC](https://discuss.tryton.org/t/is-resources-as-field-definition-forbidden/2089/4 "2020-01-15T19:14:24Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
