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

I am working on 'stock.picking' there is a one2many field 'move_ids'. I need to add two more attributes in this field. But I need to show these two attributes in case of picking is returned. There is nothing in object to know if the picking is of return. neither in parent nor in child object.

So I made a selection field named 'type_return' with values 'return' and 'non_return' and two more fields ' attrib1' and 'attrib2' Now I need to show these fields in tree view* [ <tree editable="bottom"> ]* just in case of picking is returned. this I can know by value of 'type_return'.

I used: attrs="{'invisible':[('type_return', '!=', 'return')]}" .But it did not work for me.

Can someone help me, how to solve this issue?

Ảnh đại diện
Huỷ bỏ
Tác giả

what attrs="{'invisible':[('type_return', '!=', 'return')]}" it does is makes fields readonly when type is 'return' but doesn't make invisible from tree.

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

Look this:

http://vitraining.com/show-hide-columns-in-openerp-tree-view-xml

Works fine for me.

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

Hi Yogesh,

I am giving you a similar py code , here i used this to hide two field with a condition in account_invoice.py To hide few column in tree view of account invoice, may be it help to you .....

    if view_type == 'tree':
        partner_string = _('Customer')
        if context.get('type', 'out_invoice') in ('in_invoice', 'in_refund'):
            partner_string = _('Supplier')
            for node in doc.xpath("//field[@name='reference']"):
                node.set('invisible', '0')
        for node in doc.xpath("//field[@name='partner_id']"):
            node.set('string', partner_string)
            if partner_string =='Customer' :
                                    print "abhishek"
                                    for node in doc.xpath("//field[@name='s_invoice']"):
                                            node.set('invisible', 'True')
                                            doc.remove(node)
                                    for node in doc.xpath("//field[@name='origin']"):
                                            node.set('invisible', 'True')
                                            doc.remove(node)
                                            print "abhishek"#, stop 
        res['arch'] = etree.tostring(doc)
    return res

If this help then let me ..

Ảnh đại diện
Huỷ bỏ
Tác giả

@Abhishek: thanks for your reply but In my case fields_view_get never gets called because it is a child's object (o2m) tree view with editable="bottom"

Facing Same problem

@Abhishek: In case of Employees list when this function fields_view_get is called?

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

According to Mohamad Chamra in this post https://www.odoo.com/es_ES/forum/ayuda-1/how-to-add-a-field-conditional-to-tree-view-of-customer-14707#answer_198626

attrs="{'invisible':[('customer','!=',True)]}"


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

this module may help: https://apps.odoo.com/apps/modules/10.0/web_onchange_hide_columns/

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 21
5259
4
thg 3 15
11431
2
thg 4 20
12736
0
thg 4 17
3237
1
thg 9 15
3695