Odoo Help


Show a field if I am the author And hide if I'm not him. Can you HELP ME

on 1/23/15, 3:25 AM 695 views

THIS IS MY CODE, but it does not work !

class crm_lead(format_address, osv.osv):
    _name = "crm.lead"
    _inherit ="crm.lead"

    def _check_only_responsible(self, cr, uid, ids, field_name, arg, context=None):
             """ Checks if user is responsible for this field
             @return: boolean
          for req in self.browse(cr, uid, ids, context=context):
               if req.user_id == uid:
                     return True
                    return False

          _columns = {
                        'inv': fields.function(_check_only_responsible, type="boolean", methode=True),



      And in my view:

     <record model="ir.ui.view" id="crm_case_kanban_view_leads_inherit">
                <field name="name">CRM - Leads Kanban Inherit</field>
                <field name="model">crm.lead</field>
                <field name="inherit_id" ref="crm.crm_case_kanban_view_leads"/>
                <field name="arch" type="xml">
                    <xpath expr="//div[@class='oe_kanban_content']/div" position="replace">
                         <b><field name="name"/></b>
                          <t t-if="record.planned_revenue.raw_value">
                            - <i><t t-esc="record.planned_revenue.value"   attrs="{'invisible': [('inv', "!=", True)]}" />
                            <field name="company_currency"/></i>

My question is: How hide planned_revenue field, if we are not user who has created this field? Can you help me #Please

Thanks for advance

thanks for reply, But Ben I have this error  *Inv unknown field in the domain [["inv", "=", true]] when i apply your suggestion. ie:* I replace return True by res[req.id] = True and return false by res[req.id] = False, then I return res. Do you know where is the error?

on 1/23/15, 4:08 AM

You need to include inv in the view in order for this to work.

on 1/23/15, 4:15 AM

Thanks, Ivan, Now I have no error, what is left now to have the expected result

on 1/23/15, 4:45 AM

Ben Bernard

--Ben Bernard--
Ben Bernard
| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 1/23/15, 3:40 AM

In the function field you have to return dictionary { field_id: boolean }. In your case, something like { req.id: True }.



| 5 3 6
Jakarta, Indonesia
On 1/23/15, 4:17 AM

Why don't you use the following domain: [('user_id', '!=', user.id)] ? Just make sure that user_id is in the view.  You don't need to define the additional function field.

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: 1/23/15, 3:25 AM
Seen: 695 times
Last updated: 3/16/15, 8:10 AM