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



Dears, How can I hide conditionally the print button in menu bar, e.g. if state == draft: then hide print button .

Note that I have user fields_view_get() to remove the print menu, it works but I need to hide print for specific quotation (only draft). I cannot access the instance of quotation from api.model.

@api.model
def fields_view_get(..):

    res = super(sale_order_cust, self).fields_view_get(
            view_id=view_id,
            view_type=view_type,
            toolbar=toolbar,
            submenu=submenu)  
        #remove print from tree view to avoid download unapproved quote
        if view_type == 'tree':
            toolbar_dic = res['toolbar']
            del toolbar_dic['print']

return res










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

I think you would need to go for web/js code.

Tác giả Câu trả lời hay nhất

I have used the Wizard in order to have access to object instance (quotation: active_id), and add my additional control  before printing the report (if quotation is draft => don't allow to print), since it's very difficult to control the print menu bar button from python. However, I used the above function (def fields_view_get)  to remove the print button entirely from quotation page, since the printing the reports is moved to the wizard.

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

Hello  Salim,
please refer this Link

https://www.odoo.com/forum/help-1/question/view-or-hide-one-report-menu-based-on-condition-in-odoo-8-128946#answer-129476


it will help you.

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 1 20
15328
16
thg 8 19
10260
1
thg 1 19
5508
0
thg 9 17
2570
0
thg 2 17
3066