Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
4796 Vistas

Hello guys. Anyone knows why my domain doesn't work?

[('customer','=',True),('company_type','=','company')]

I'm trying to use that domain on an action to filter and it works for customer True, but keep showing any company type :/

IT KEEP SHOWING COMPANY TYPE 'PERSON' WITH THIS DOMAIN 

<record id="partner_cliente_action" model="ir.actions.act_window">
<field name="name">Clientes</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner</field>
<field name="view_mode">kanban,tree,form</field>
<field name="view_type">form</field>
<field name="domain">[('customer','=',True),('company_type','=','company')]</field>
<field name="context">{"default_customer":1,"default_is_company":1,"default_company_type":"company","default_tipo_cliente":"pri"}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new client
</p>
</field>
</record>
Avatar
Descartar
Mejor respuesta

Hi Rafael, 

The field company_type is a non-stored compute, this means that it is not in the database and cannot be used to search using a domain. The result of this field is actually stored in a field called is_company, so try using that field instead.


Avatar
Descartar
Autor

Thanks Jake, it worked for me!

Mejor respuesta

Hi Rafael,

Odoo always allows to all users to access all contacts. So you need to prepare action accordingly.

What you have added is, you have added domain in action, but as odoo allows all users to access contacts, so domain will not work.

If you analyse in sales > Orders/Customer, Purchase > Orders/Vendors, Invoices > Customer Invoices/Customer etc. then you will find that they have added default search filter to filter specific types of contacts.

So you need to do the code as bellow:

<record id="partner_cliente_action" model="ir.actions.act_window">
    <field name="name">Clientes</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">res.partner</field>
    <field name="view_mode">kanban,tree,form</field>
    <field name="view_type">form</field>
    <field name="context">{"default_customer":1,"default_is_company":1,"default_company_type":"company","default_tipo_cliente":"pri", "search_default_customer":1, "search_default_type_company":1}</field>
    <field name="help" type="html">
        <p class="oe_view_nocontent_create">
        Click to create a new client
        </p>
    </field>
</record>

But if you want to only allow user to access contacts which are as Customer and Is Company, then you need to add record rules according to user group.

I hope this will helpful for you.

Thanks and regards

Haresh Kansara

Avatar
Descartar
Autor

Thanks very much Haresh, but default search don't solve my problem, I need to show only company partners. As Jake Robinson said I can use is_company on this domain to show only companies.