# Help needed in notebook page states

**URL:** https://discuss.tryton.org/t/help-needed-in-notebook-page-states/1711
**Category:** Developer
**Created:** [September 4, 2019, 7:15am UTC](https://discuss.tryton.org/t/help-needed-in-notebook-page-states/1711 "2019-09-04T07:15:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kakamble](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/kakamble/32/494_2.png) [@kakamble](https://discuss.tryton.org/u/kakamble)
#### Post date: [September 4, 2019, 7:15am UTC](https://discuss.tryton.org/t/help-needed-in-notebook-page-states/1711/1 "2019-09-04T07:15:59Z")

</div>

How is states written in notebook page tag in XML?

I have tried the following

```
<page id="_renumeration" string="Renumeration Bills"
        states="{
        'readonly': ~Eval('state').in_(['draft']),
        'invisible': Eval('state').in_([
            'draft',
            'confirm',
            'approved',
            'in_progress'
        ])
    }" pyson="1">

```

but it doesn’t work.

Help is much appreciated

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [September 4, 2019, 7:18am UTC](https://discuss.tryton.org/t/help-needed-in-notebook-page-states/1711/2 "2019-09-04T07:18:36Z")

</div>

PYSON statements can not be used on xml defintion but it should be defined on python code by using the [view\_attributes](http://docs.tryton.org/projects/server/en/latest/ref/models/models.html?highlight=view_attributes#trytond.model.ModelView.view_attributes) function. You have an [example of it’s usage on the invoice module](http://hg.tryton.org/modules/account_invoice/file/6597f33e51d2/invoice.py#l1098http://hg.tryton.org/modules/account_invoice/file/6597f33e51d2/invoice.py#l1098)

Hope it helps!

---

<div class="post-metadata">

### Author: ![kakamble](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/kakamble/32/494_2.png) [@kakamble](https://discuss.tryton.org/u/kakamble)
#### Post date: [September 5, 2019, 5:14am UTC](https://discuss.tryton.org/t/help-needed-in-notebook-page-states/1711/3 "2019-09-05T05:14:55Z")

</div>

Thanks! It helped!

In the model, I wrote a separate dictionary for states

```
_RENUM_PAGE_STATES = {
    'readonly': ~Eval('state').in_(['draft']),
    'invisible': Eval('state').in_([
        'draft',
        'confirm',
    ])
}

```

then in view\_attributes, I wrote the follwing

```
@classmethod
def view_attributes(cls):
    return [('/form/notebook/page[@id="_renumeration"]', 'states', cls._RENUM_PAGE_STATES)]

```

Works perfectly!

---

<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: [October 5, 2019, 5:14am UTC](https://discuss.tryton.org/t/help-needed-in-notebook-page-states/1711/4 "2019-10-05T05:14:56Z")

</div>

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