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

i want to add smart button which is show sale order for res.partner i got all record but i want only record which name is selected by me 


thanks you advance

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

thank you mehjabin

can you give me the xml code for this

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

Hi,

For adding smart button, you can inherit the corresponding view and add the button, then trigger a python function from the button by setting the button type as object, then you can return the view/records from this function. Below added is a sample of returning employee records from python code, here you can make necessary changes and filter the records by adjusting the domain.

For example:

return {
'name': _('Sale Orders'),
'type': 'ir.actions.act_window',
'res_model': 'sale.order',
'view_mode': 'kanban,tree,form',
'domain': [('partner_id', '=', your_partner_id)],
}

For More: https://www.youtube.com/watch?v=I3aq2Shcj-E


Thanks 

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

Hi,

You can try refer the following blog.

https://www.cybrosys.com/blog/how-to-add-smart-buttons-in-odoo-15

Hope it helps

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
Hi @Ra_one_1_11
here are the XML and python code for your help,

XML: Inherit the corresponding view and add this following code
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
<button name="action_view_so" type="object" class="oe_stat_button" icon="fa-shopping-bag">
<div class="o_stat_info o_field_widget">
<span class="o_stat_text">Salespan>
<span class="o_stat_text">Ordersspan>
div>
button>xpath>

PYTHON:
def action_view_so(self):
       self.ensure_one()
       result = {'name': _('Sale Orders'),
                      'type': 'ir.actions.act_window',
                      'res_model': 'sale.order',
                      'view_mode': 'kanban,tree,form',
                      'domain': [('partner_id', '=', your_partner_id)],
                     }
        return result

 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 22
2206
0
thg 5 25
165
1
thg 5 25
551
4
thg 5 25
1853
2
thg 5 25
2017