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

Hi,

  1. I have created this field in product.product: 'stock_by_location' : fields.one2many('report.stock.inventory', 'product_id', 'Stock by Location', domain=[('product_qty','>',0)]),

  2. Then I created this field in stock.move module: 'inventory' : fields.related('product_id', 'stock_location', type='one2many', relation='report.stock.inventory', string='Stock Location'),

  3. Now whenever I open an existing stock.move entry from Warehouse->Stock Move I can see the current quantity of that selected product per its location. But whenever I create a new stock move entry and select a product, it never gets updated unless I save the form first. From what I know, I need to create an on_change event for this.

The product_id field on stock.move had already an on_change event. How can I insert an on_change event function to update the inventory field which is a related field of product_id and is also a one2many type.

Any help pls.?

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

You need add to existing on_change method code, that recalculate your filed. And add to return value dictionary your field with recalculated value.

How define o2m value you can check here.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
10
thg 6 16
33056
1
thg 10 15
9262
4
thg 8 15
3604
5
thg 3 15
12088
1
thg 3 15
3808