Odoo Help


How to access uid in xml

on 5/30/13, 5:19 AM 7,118 views


Please Do me a favour..




| 4 4 8
Ahmedabad, India

Odoo Expert

On 5/30/13, 6:50 AM

Hi Jack, there are two ways to use uid in xml:

(1) You can use uid in xml by domain

Here is the example,

    <filter string="My Entries" domain="[('user_id','=',uid)]" icon="terp-personal"/>

Or you can refer addons modules,

Here is the link for version 6.0 example and version 7.0 example

(2) You can pass uid as context in action

<record id="my_action" model="ir.actions.act_window">
    <field name="name">My Action</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">my.model</field>
    <field name="view_type">form</field>
    <field name="context">{"search_default_user_id":uid}</field>
    <field name="view_id" ref="my_tree_view"/>

You can hide Confirm Sale button by assigning group to them. And assign only those users to that group to whom you want to show confirm sale button.

<button name="order_confirm" states="draft" string="Confirm Order" groups="your_module.your_group"/>

So it will show to only those users which are assigned to your_group.

First make user in your xml file

Like this:

    <record id="your_module.captain_jack" model="res.users">
        <field name="login">jakes</field>
        <field name="password">captainjake007</field>
        <field name="name">Jakes Sparrow</field>
        <field name="signature">Captain Jakes Sparrow</field>

So now user is created. Now make a group and assign this user to your new group

Like this:

    <record model="res.groups" id="your_group">
        <field name="name">Group of Pirates</field>
        <field name="users" eval="[(4,ref('your_module.captain_jack'))]"/>


hiiiiiiii.................how we can make groups?

on 5/30/13, 7:58 AM

Check my updated answer.

on 5/30/13, 8:34 AM
On 5/30/13, 6:53 AM

I want to remove the "Confirm Sale" button from the sales order for some user.....For this i want the uid to acces in xml by which i can put "attrs" for "Confirm Sale" button.....


Andreas Maertens

--Andreas Maertens--
Andreas Maertens
| 5 5 7
Finsterwalde, Germany
--Andreas Maertens--

I develop odoo8.0 modules

Andreas Maertens
On 5/30/13, 6:25 AM

Some more informations would be great.

You may need to add a function to your model to get the uid. What are you trying to do?

I want to remove the "Confirm Sale" button from the sales order for some user.....For this i want the uid to acces in xml by which i can put "attrs" for "Confirm Sale" button.....

on 5/30/13, 6:41 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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/30/13, 5:19 AM
Seen: 7118 times
Last updated: 3/16/15, 8:10 AM