Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

Get the current company in xml

By
Mind And Go
on 6/16/14, 5:24 PM 3,545 views

Hy,

I would like to filter datas with domain action and current company_id.
I tried many thinks without success :

<record id="action_tasks" model="ir.actions.act_window">
        <field name="name">tasks</field>
        <field name="res_model">project.task</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="context">{}</field>
        <field name="domain" >[('company_id','!=',context.get('company_id',False))]</field>
        </record>

More generally how to create an action linked on a menu that is filtered on current company.
Is there any way to dynamically associate the menu to an action and return a filtered action_window?

Thanks

In another way to Filter record using Record Rule

Prakash
on 6/18/14, 6:07 AM
1
Mariusz Rajfura
On 8/6/14, 6:20 PM

I tested it on runbot => no success ccould it be a bug?

I have the same problem. Ho add mandatory filter for company_id?

Mariusz Rajfura
on 8/6/14, 6:21 PM

Hy Ray, thanks fro reading my post, unfortunately, I have this message name : ``` NameError: name 'user' is not defined

Mariusz Rajfura
on 8/15/14, 7:32 PM

Thanks to @Ray and @atchuthan for advice. It works implemented in rule. Small drawback is that this setting does not apply to the admin. Only an ordinary user has limited access to the data filtered by "company_id" rule.

Mariusz Rajfura
on 8/15/14, 7:43 PM
0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3883
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 8/7/14, 1:47 AM

We already have a rule available for Project Task that was done for Multi-company

    <record model="ir.rule" id="task_comp_rule">
        <field name="name">Project/Task: multi-company</field>
        <field name="model_id" ref="model_project_task"/>
        <field name="global" eval="True"/>
        <field name="domain_force">['|',
                                        ('company_id', '=', False),
                                        ('company_id', 'child_of', [user.company_id.id]),
                                    ]</field>
    </record>

So, your requirement is to show the record for that particular company and not all its child company.  Then you need to change the RULE

<field name="domain_force">['|',
                                        ('company_id', '=', False),
                                        ('company_id', '=', [user.company_id.id]),
                                    ]</field>

But, functionally making this change is a wrong move.

0

Ben Bernard

--Ben Bernard--
1083
| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 8/6/14, 10:16 PM

    [ ("company_id", "=", base.main_company) ] if you rely on only one company (this usually works).

Is there any way to dynamically associate the menu to an action and return a filtered action_window?

Override the search method in your model.

Check also https://www.odoo.com/forum/help-1/question/how-to-append-a-domain-with-to-existing-domain-58308#answer-58389.

0

Ray Carnes

--Ray Carnes--
15687
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

Ray Carnes
On 6/18/14, 1:25 PM

[ ("company_id", "=", user.company_id.id) ]

I tried but result is

Uncaught Error: NameError: name 'user' is not defined

shameem@aχoncoms
on 10/19/16, 4:29 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 6/16/14, 5:24 PM
Seen: 3545 times
Last updated: 3/16/15, 8:10 AM