This question has been flagged

Hello,

I want to to show discount, price sell, etc. in delivery order. So I have to connect sale.order.line with stock.pack.operation.
Unfortunately, there is no easy and proper way to do that.
In fact, there is a link between them :

stock_pack_operation---(picking_id+produc_id)--->stock_move--(procurement_id)--->procurement_order---(sale_line_id)--->sale_order_line

Here my SQL request (notice that I had state='assigned' for stock_move):

SELECT DISTINCT
    a.id, a.product_qty, a.state, a.procurement_id, a.product_id, a.picking_id,
    b.id, b.product_qty, b.picking_id,
    c.id, c.sale_line_id, c.origin, c.product_qty,
    d.id, d.product_uom_qty, d.price_unit, d.price_subtotal, d.discount
FROM stock_move a,
            stock_pack_operation b,
            procurement_order c,
            sale_order_line d
WHERE a.picking_id = b.picking_id
             AND a.product_id = b.product_id
             AND a.state = 'assigned'
             AND a.procurement_id = c.id
             AND c.sale_line_id = d.id

Here, I could show price and discount on delivery order, even if there are 2 same products on the sale order : for example 1 "Mac ref1"  at 500€ and 1 "Mac ref1" at 250€ (50% because it's already used/broken).

I got 2 questions:

  1. Is there an easy way to connect sale.order.line and stock.pack.operation ?

  2. How could I use my request to inherit model "stock_pack_operation" and use it on delivery order ?


Thank you.

FTK





Avatar
Discard

I also want to do the same, working with stock_pack_operation, I want to know how it is related to moves and how it is working with Qaunts.!

Any answer will be appreciated!

Best Answer

Hi,

I was also facing the same issue. Firstly when you confirm sale order it will create Draft Delivery Order and its line. Now, line object would be stock.move, after that when you perform any kind of operation on that DO, you will see object changed. It is now stock.pack.operation.


It is coming from this method:

do_prepare_partial() of class stock_picking

you will find this line.:  pack_operation_obj.create(cr, uid, vals, context=context) 

It is creating pack operation from move, and where pack_operation_obj = self.pool.get('stock.pack.operation')

Now, You can use your query through pack operation object via stock.move. If reverse is there u have to work with stock.quant.package.

Thanks,

Chandni


Avatar
Discard