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

I would like to add a button to the Sale Order view (similar to the Delivery button) with the number of related Purchase Orders, and linking to the filtered view. If getting the number is too difficult (seems like a query), then just a link to the filtered purchase orders list view.


I know how to created an extended view of the sale.order.form view.

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

Hi

You may do like this

def action_view_purchase_order(self):
for rec in self:
        your_so_related_purchase_orders = []
if len(your_so_related_purchase_orders) > 1:
return {
'name': 'Purchase Order',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'purchase.order',
'view_id': False,
'type': 'ir.actions.act_window',
'domain': [('id', 'in', your_so_related_purchase_orders)],


}
if len(your_so_related_purchase_orders) == 1:
return {
'name': 'Purchase Order',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'purchase.order',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id': your_so_related_purchase_orders[0],
}
@api.depends('your_field')
def _compute_count(self):
for record in self:
    record.purchase_order_count = len(your_so_related_purchase_orders)


<button name="action_view_purchase_order" type="object" class="oe_stat_button"
icon="fa-pencil-square-o" attrs="{'invisible': [('purchase_order_count', '=', 0)]}">
<field name="purchase_order_count" widget="statinfo" string="Purchase Order"/>
</button>

Hope This will help you
Thanks
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
Hi Odox SoftHub LLP how can we do v14 thanks for all
Ảnh đại diện
Huỷ bỏ

Same way as shown in his example

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 21
4238
1
thg 12 19
2971
1
thg 7 25
1712
1
thg 5 25
1708
1
thg 4 25
2281