Odoo Help

0

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

By
tansadio
on 1/23/15, 3:25 AM 774 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
               else:
                    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">
                        <div>
                         <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>
                          </t>    
                        </div>                              
                    </xpath>
                </field>
            </record>

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?

tansadio
on 1/23/15, 4:08 AM

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

Ivan
on 1/23/15, 4:15 AM

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

tansadio
on 1/23/15, 4:45 AM
0

Ben Bernard

--Ben Bernard--
1083
| 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 }.

0

Ivan

--Ivan--
3255
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
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.

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.

Register

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)

Stats

Asked: 1/23/15, 3:25 AM
Seen: 774 times
Last updated: 3/16/15, 8:10 AM