# How to update the domain of an existing act\_window

**URL:** https://discuss.tryton.org/t/how-to-update-the-domain-of-an-existing-act-window/4543
**Category:** Developer
**Created:** [August 17, 2021, 10:28pm UTC](https://discuss.tryton.org/t/how-to-update-the-domain-of-an-existing-act-window/4543 "2021-08-17T22:28:11Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![andres53016](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/andres53016/32/406_2.png) [@andres53016](https://discuss.tryton.org/u/andres53016)
#### Post date: [August 17, 2021, 10:28pm UTC](https://discuss.tryton.org/t/how-to-update-the-domain-of-an-existing-act-window/4543/1 "2021-08-17T22:28:11Z")

</div>

Hi folks. I need to update the domain of an existing act\_window of the products module, which is the following.

```auto
<record model="ir.action.act_window" id="act_template_by_category">
            <field name="name">Product by Category</field>
            <field name="res_model">product.template</field>
            <field name="context"
                eval="{'categories': [Eval('active_id')]}" pyson="1"/>
            <field name="domain"
                eval="[('categories_all','child_of', [Eval('active_id')], 'parent')]"
                pyson="1"/>
        </record>

```

From a new module I want to edit the domain, so that it looks like this.

```auto
<field name="domain"   
eval="['AND',('categories_all','child_of', [Eval('active_id')], 'parent'), 'type','=','goods')]"
    pyson="1"/>

```

Thanks in advance.

---

<div class="post-metadata">

### Author: ![rvong](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/3bc359/32.png) [@rvong](https://discuss.tryton.org/u/rvong)
#### Post date: [August 18, 2021, 1:05am UTC](https://discuss.tryton.org/t/how-to-update-the-domain-of-an-existing-act-window/4543/2 "2021-08-18T01:05:58Z")

</div>

I am not very sure what exactly you want to do, but my guess is that you want to limit or filter the products displayed in a existing list/form. Then the approach I will take is to create a `ir.rule` and set the domain that you need.

Something like this:

```auto
        <record model="ir.rule.group" id="rule_group_product_by_cat">
            <field name="name">Products by Active Cat</field>
            <field name="model" search="[('model', '=', 'product.template')]"/>
            <field name="global_p" eval="False"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_create" eval="True"/>
            <field name="perm_delete" eval="False"/>
        </record>
        <record model="ir.rule" id="rule_product_cat_1">
            <field name="domain" eval="[('categories_all','child_of', [Eval('active_id')], 'parent')]" pyson="1"/>
            <field name="rule_group" ref="rule_group_product_by_cat"/>
        </record>

```

I hope it helps.

---

<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: [August 18, 2021, 5:29am UTC](https://discuss.tryton.org/t/how-to-update-the-domain-of-an-existing-act-window/4543/3 "2021-08-18T05:29:39Z")

</div>

> [@andres53016](#):
>
> I need to update the domain of an existing act\_window of the products module, which is the following.

It is not good to update existing action (but doable if you use the same id but prefixed by the original module). You should consider create a new one with his own domain.

> [@rvong](#):
>
> Then the approach I will take is to create a `ir.rule` and set the domain that you need.

Access right should not be used for convenient display but only to apply global restrictions.

---

<div class="post-metadata">

### Author: ![andres53016](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/andres53016/32/406_2.png) [@andres53016](https://discuss.tryton.org/u/andres53016)
#### Post date: [August 18, 2021, 1:05pm UTC](https://discuss.tryton.org/t/how-to-update-the-domain-of-an-existing-act-window/4543/4 "2021-08-18T13:05:08Z")

</div>

> [@rvong](#):
>
> I am not very sure what exactly you want to do

Thanks for the reply, I want to change an action in the product category tree view, that when double clicked opens a new tab with the products that have that category. But I want that action to filter me also the products that are of type goods.

> [@ced](#):
>
> It is not good to update existing action (but doable if you use the same id but prefixed by the original module).

Thanks for the reply, it happens that if I create a new action, when I double click on the product category tree it does not take this new action, so I think that I should update or delete the existing action. By adding the prefix of the original module I got what I needed. I am left like this:

```auto
<record model="ir.action.act_window" id="product.act_template_by_category">
            <field name="name">Product by Category</field>
            <field name="res_model">product.template</field>
            <field name="context"
                eval="{'categories': [Eval('active_id')]}" pyson="1"/>
            <field name="domain"
                eval="['AND',('categories_all','child_of', [Eval('active_id')], 'parent'),('type','=','goods')]"
                pyson="1"/>
        </record>

```

Why is it not good to update existing actions?

---

<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: [August 18, 2021, 1:13pm UTC](https://discuss.tryton.org/t/how-to-update-the-domain-of-an-existing-act-window/4543/5 "2021-08-18T13:13:40Z")

</div>

> [@andres53016](#):
>
> it happens that if I create a new action, when I double click on the product category tree it does not take this new action

This is because you did not register your action with a keyword `tree_open`.

> [@andres53016](#):
>
> so I think that I should update or delete the existing action

Indeed you could deactivate the original action with just:

```auto
<record model="ir.action.act_window" id="product.act_template_by_category">
    <field name="active" eval="False"/>
</record>

```

> [@andres53016](#):
>
> Why is it not good to update existing actions?

Because some code may depend on it but also because on each update `trytond-admin` will update first with the initial value (or log a warning because the record has changed) when processing the original module and then update it with processing your module.

---

<div class="post-metadata">

### Author: ![andres53016](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/andres53016/32/406_2.png) [@andres53016](https://discuss.tryton.org/u/andres53016)
#### Post date: [August 18, 2021, 1:23pm UTC](https://discuss.tryton.org/t/how-to-update-the-domain-of-an-existing-act-window/4543/6 "2021-08-18T13:23:00Z")

</div>

Thank you very much for clarifying all my doubts, I am going to do it the right way, deactivating the original one and generating a new action.

---

<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: [September 17, 2021, 1:23pm UTC](https://discuss.tryton.org/t/how-to-update-the-domain-of-an-existing-act-window/4543/7 "2021-09-17T13:23:11Z")

</div>

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