Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odpovědi
8501 Zobrazení

I have a client with multi-companies in Odoo 13.


Company A

Company B


How do I go into a view and say: 

If the person viewing this is viewing as someone from Company A, show these fields.  Else, don't show.

The equivalent of:

<div t-if="company_id == 2">
   <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
   <field name="uom_id" groups="uom.group_uom" options="{'no_create': True}"/>
   <field name="uom_po_id" groups="uom.group_uom" options="{'no_create': True}"/>
   <field name="currency_id" invisible="1"/>
   <field name="cost_currency_id" invisible="1"/>
   <field name="product_variant_id" invisible="1"/>
</div>
Avatar
Zrušit

Visible Invisible fields: https://goo.gl/Ts3qqK

Nejlepší odpověď

Hello Russ Schneider, 

You just need to pass the following inside view action:

<field name="domain">[('company_id','=',2)]</field>

Thanks

Anisha Bahukhandi

Technical Content Writer

Webkul

Avatar
Zrušit
Nejlepší odpověď

You can achieve that by using a server action, create 2 act_window then conditionally select them in server action:

    <record id="custom_server_action" model="ir.actions.server">
        <field name="name">Custom server action</field>
        <field name="model_id" ref="my_module.model_my_model"/>
        <field name="binding_model_id" ref="my_module.model_my_model" />
        <field name="state">code</field>
        <field name="code">
if env.company.id == 2:
    action = env.ref('your_module.custom_action1').read()[0]
else:
    action = env.ref('your_module.custom_action2').read()[0]
        </field>
    </record>    
Avatar
Zrušit
Autor Nejlepší odpověď

Solution that worked:

<field name="whatever" attrs="{'invisible': [('company_id', '=', 1)]}"/>

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
čvn 21
7494
1
kvě 21
4920
1
pro 20
277
2
srp 20
4649
3
říj 18
5085