콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
4409 화면

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?

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

작성자

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

베스트 답변

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

아바타
취소
베스트 답변

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.

아바타
취소
관련 게시물 답글 화면 활동
How to hide fields? 해결 완료
3
3월 15
29132
2
3월 15
5000
2
9월 23
10269
1
6월 23
3187
1
8월 22
2949