# Why does test\_missing\_parent fail here?

**URL:** <https://discuss.tryton.org/t/why-does-test-missing-parent-fail-here/8624>\
**Category:** Developer\
**Created:** [June 1, 2025, 6:34pm UTC](https://discuss.tryton.org/t/why-does-test-missing-parent-fail-here/8624 "2025-06-01T18:34:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![htgoebel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/htgoebel/32/1256_2.png) [@htgoebel](https://discuss.tryton.org/u/htgoebel)\
**Post date:** [June 1, 2025, 6:34pm UTC](https://discuss.tryton.org/t/why-does-test-missing-parent-fail-here/8624/1 "2025-06-01T18:34:04Z")

</div>

Hi,  
I’m trying to port a module from 4.8 to 7.0. When running the test-suite via tox, one of the classes fails with

```auto
  File "/home/hartmut/devel/tryton/community/modules/bank_fints/.tox/py-sqlite/lib/python3.10/site-packages/trytond/tests/test_tryton.py", line 491, in test_missing_parent
    self.assertIn('_parent_%s' % depend, parent_depends,
AssertionError: '_parent_account' not found in {'account'} : Missing "_parent_account" in "bank.account.number"."fints_company"."on_change_with"

```

The code of that class is quite simple:

```auto
class BankAccountNumber2(ModelSQL, ModelView):
    'Bank Account Number'
    __name__ = 'bank.account.number'

    fints_company = fields.Function(fields.One2Many('party.party', None,
            'Owner', states={'invisible': True}), 'on_change_with_fints_company')

    @fields.depends('account')
    def on_change_with_fints_company(self, name=None):
        if self.account is None:
            return []
        return [x.id for x in self.account.owners]

```

Model `bank.account.number` is defined in official `trytond_bank` and contains the `account` field:

```auto
        if self.account is None:
            return []
        return [x.id for x in self.account.owners]

```

`bank` is declared as `depends` in `tryton.cfg` and the module is installed in the virtual environment created by tox.

What piece I’m missing?

---

<div class="post-metadata">

**Author:** ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)\
**Post date:** [June 2, 2025, 8:02am UTC](https://discuss.tryton.org/t/why-does-test-missing-parent-fail-here/8624/2 "2025-06-02T08:02:49Z")

</div>

Probably try this as depends:

```auto
@fields.depends('account', '_parent_account.owners')

```

---

<div class="post-metadata">

**Author:** ![htgoebel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/htgoebel/32/1256_2.png) [@htgoebel](https://discuss.tryton.org/u/htgoebel)\
**Post date:** [June 2, 2025, 2:44pm UTC](https://discuss.tryton.org/t/why-does-test-missing-parent-fail-here/8624/3 "2025-06-02T14:44:05Z")

</div>

Thanks this did the trick. Anyhow I’d like to understand what this does and where I can find this in the documentation. Any hits?

Answering myself: The answer is hidden in [Fields — Tryton server](https://docs.tryton.org/latest/server/ref/fields.html#one2many:)

> [`PYSON`](https://docs.tryton.org/latest/server/ref/pyson.html#trytond.pyson.PYSON) statement or [`Field.depends`](https://docs.tryton.org/latest/server/ref/fields.html#trytond.model.fields.Field.depends) of target records can access value of the parent record fields by prepending `_parent_` to the opposite field name and followed by the dotted notation.

---

<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:** [June 3, 2025, 2:44pm UTC](https://discuss.tryton.org/t/why-does-test-missing-parent-fail-here/8624/4 "2025-06-03T14:44:09Z")

</div>

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