# Extending a domain

**URL:** https://discuss.tryton.org/t/extending-a-domain/4961
**Category:** Developer
**Created:** [January 27, 2022, 10:20am UTC](https://discuss.tryton.org/t/extending-a-domain/4961 "2022-01-27T10:20:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![acaubet](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/acaubet/32/1493_2.png) [@acaubet](https://discuss.tryton.org/u/acaubet)
#### Post date: [January 27, 2022, 10:20am UTC](https://discuss.tryton.org/t/extending-a-domain/4961/1 "2022-01-27T10:20:59Z")

</div>

Hello, I have a M2O on the production outputs (stock.move) to sale.line, I’m trying to extend the `sale_supply_production.act_production_form` domain but It’s giving me to many values to unpack:  
The `domain` that causes the crash on `model/fields/field.py", line 400` is: `('id', '=', 2328, 'sale.line')`

```auto
  File "/home/vant/Documentos/GitLab/XXXX/.venv/lib/python3.8/site-packages/trytond/model/modelsql.py", line 1447, in convert
    expression = field.convert_domain(domain, tables, cls)
  File "/home/vant/Documentos/GitLab/XXXX/.venv/lib/python3.8/site-packages/trytond/model/fields/field.py", line 400, in convert_domain
    name, operator, value = domain
ValueError: too many values to unpack (expected 3)

```

```auto
        <record model="ir.action.act_window" id="sale_supply_production.act_production_form">
            <field name="active" eval="False"/>
        </record>
        <record model="ir.action.act_window" id="act_production_form">
            <field name="name">Productions</field>
            <field name="res_model">production</field>
            <field
                name="domain"
                eval="
                [
                    If(Eval('active_ids', []) == [Eval('active_id')],
                        ['OR',
                            [
                                ('origin.sale.id', '=', Eval('active_id'), 'sale.line')
                            ],
                            [
                                ('outputs.sale_line.sale.id', '=', Eval('active_id'))
                            ]
                        ],
                        ['OR',
                            [
                                ('origin.sale.id', 'in', Eval('active_ids', []), 'sale.line')
                            ],[
                                ('outputs.sale_line.sale.id', 'in', Eval('active_ids', []))
                            ]
                        ]
                    )
                ]"
                pyson="1"/>
        </record>

        <record model="ir.action.keyword" id="act_production_form_keyword1">
            <field name="keyword">form_relate</field>
            <field name="model">sale.sale,-1</field>
            <field name="action" ref="act_production_form"/>
        </record>

```

I tried to check the or conditions on console and all seams to work okey (expected results are okey, 3 productions):

```auto
Tryton 6.0.1, Python 3.8.10 (default, Nov 26 2021, 20:14:08) 
[GCC 9.3.0] on linux
>>> Production = pool.get('production')
>>> domain = ['OR',
... [('origin.sale.id', 'in', [2328], 'sale.line')],
... [('outputs.sale_line.sale.id', 'in', [2328])]]
>>> Production.search(domain)
[Pool().get('production')(832), Pool().get('production')(830), Pool().get('production')(831)]
>>> domain =['OR',
... [('origin.sale.id', '=', 2328, 'sale.line')],
... [('outputs.sale_line.sale.id', '=', 2328)]]
>>> Production.search(domain)
[Pool().get('production')(832), Pool().get('production')(830), Pool().get('production')(831)]
>>>

```

Can anyone help to point what the hell I’m doing wrong?  
Huge thanks!

---

<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: [January 27, 2022, 1:29pm UTC](https://discuss.tryton.org/t/extending-a-domain/4961/2 "2022-01-27T13:29:07Z")

</div>

I suspect that the domain inversion does not work correctly with reference fields.

---

<div class="post-metadata">

### Author: ![acaubet](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/acaubet/32/1493_2.png) [@acaubet](https://discuss.tryton.org/u/acaubet)
#### Post date: [February 3, 2022, 4:24pm UTC](https://discuss.tryton.org/t/extending-a-domain/4961/3 "2022-02-03T16:24:10Z")

</div>

The problem was a previous wrong domain atempt loaded in database. Domain inversion works as expected.  
Sorry for disturbing and thanks.

---

<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 5, 2022, 4:24pm UTC](https://discuss.tryton.org/t/extending-a-domain/4961/4 "2022-03-05T16:24:59Z")

</div>

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