# Add a Party Relation using Proteus

**URL:** https://discuss.tryton.org/t/add-a-party-relation-using-proteus/5946
**Category:** Developer
**Tags:** proteus
**Created:** [February 17, 2023, 1:43pm UTC](https://discuss.tryton.org/t/add-a-party-relation-using-proteus/5946 "2023-02-17T13:43:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![lars\_wuerfel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/lars_wuerfel/32/2794_2.png) [@lars\_wuerfel](https://discuss.tryton.org/u/lars_wuerfel)
#### Post date: [February 17, 2023, 1:43pm UTC](https://discuss.tryton.org/t/add-a-party-relation-using-proteus/5946/1 "2023-02-17T13:43:43Z")

</div>

Trying to add a party.relation to a newly created party in a proteus script like this:

```auto
        party = Party()
        Relation = Model.get('party.relation')
        RelationType = Model.get('party.relation.type')
        [...]
        (party is filled here)
        [...]
        party.save()

        relation = Relation()
        relation.from_ = party
        relation.to = Party(x) # x gives the party to relate to
        relation.type = RelationType(y) # y gives the relation type
        relation.save()

```

the following Error is thrown:

```auto
Traceback (most recent call last):
[...]
  File "/[...]/tryton-server-6.6/env/lib/python3.11/site-packages/proteus/ __init__.py", line 102, in newfunc
    return self.func(owner, [instance], *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/[...]/tryton-server-6.6/env/lib/python3.11/site-packages/proteus/ __init__.py", line 855, in save
    ids = proxy.create(values, context)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/[...]/tryton-server-6.6/env/lib/python3.11/site-packages/proteus/config.py", line 194, in __call__
    raise TypeError('%s is not callable' % self._name)
TypeError: create is not callable

```

Could someone please tell me how to add a party.relation using Proteus, or just tell me what is the problem here?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [February 17, 2023, 1:52pm UTC](https://discuss.tryton.org/t/add-a-party-relation-using-proteus/5946/2 "2023-02-17T13:52:43Z")

</div>

You can not use from RPC a model that does not inherit from `ModelView` (it is an internal model).  
You must use `party.relation.all` or even better use `party.relations.new()`.

---

<div class="post-metadata">

### Author: ![lars\_wuerfel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/lars_wuerfel/32/2794_2.png) [@lars\_wuerfel](https://discuss.tryton.org/u/lars_wuerfel)
#### Post date: [February 17, 2023, 2:12pm UTC](https://discuss.tryton.org/t/add-a-party-relation-using-proteus/5946/3 "2023-02-17T14:12:59Z")

</div>

Thank you @ced, it’s so easy but I did not see it.

```auto
        relation = party.relations.new()
        relation.to = Party(x)
        relation.type = RelationType(y)

```

---

<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: [March 19, 2023, 2:13pm UTC](https://discuss.tryton.org/t/add-a-party-relation-using-proteus/5946/4 "2023-03-19T14:13:43Z")

</div>

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