Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4396 Lượt xem

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

Ảnh đại diện
Huỷ bỏ

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.

Tác giả

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
How to hide fields? Đã xử lý
3
thg 3 15
29118
2
thg 3 15
4984
2
thg 9 23
10258
1
thg 6 23
3177
1
thg 8 22
2945