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

We need to be able to query the number of a given product currently in quotations. In other words, take inventory of a given SKU, and get a number back which is the total no. of them currently in active (not cancelled) quotations.

I understand that Odoo's logic is to count inventory once it is on a sales order. But for our needs, we also need to be able to get a quick take of how many are in quotations.

What database model/field do I need to look for here?

I've looked around and cannot seem to find it - even in developer mode.

Perhaps I'm missing it.  

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

Hello Hibou,

I wrote this script within a scheduled action and seems to work:

internal_reference = "DESK0004"

sale_order_lines_quantity = sum(

  env["sale.order.line"].search

  (

    ["&", ("product_id.default_code", "=", internal_reference), ("order_id.state", "=", "draft")]

  ).mapped("product_uom_qty")

)


raise Warning(sale_order_lines_quantity)


The idea behind it is that you are searching for all sales orders lines where the order_id (related sales order) is in the draft stage (quotation). You then search on the product_id.default_code to check that the sales order line is the product you are looking for. You then map by the quantity and get the sum. 

I hope this helps.

Thanks, 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 21
2972
2
thg 6 19
3253
1
thg 7 25
2728
1
thg 11 24
2950
2
thg 10 24
2818