Skip to Content
Menu
This question has been flagged
2 Replies
1781 Views

I have a purchase order that contains 100 units of product A. 


The supplier executes the order, but sends 100 units of product B that has the same properties with product A (it's just from another firm, but otherwise has the same properties with product A).


When I receive the products in the order's corresponding stock picking I add another stock move to receive 100 units of product B and 0 units of product A.


What I would like is when I validate the stock picking to automatically update the order and add an extra line in order lines that includes the product B with ordered qty=0 and received qty=100.


In short, I want the order to be updated with the extra lines I add in the corresponding stock picking.

Avatar
Discard
Author Best Answer

I managed to achieve the result by overriding the validate_button script when validating the stock picking: 

def button_validate(self):
        for picking in self:
            if picking.purchase_id:
                picking.purchase_id.state="draft"
                for move in picking.move_ids_without_package:
                    if move.quantity_done > 0:
                    ​po_line = picking.purchase_id.order_line.filtered(lambda l: l.product_id == move.product_id)                                                ​if not po_line:
                      ​order_line_id =picking.purchase_id.order_line.create({
​                ​'order_id': move.purchase_line_id=order_line_id.id, ​'product_id': move.product_id.id,                        ​'name': move.product_id.display_name,                                'product_qty_uom': move.quantity_done,                                ​'product_qty':move.quantity_done,                                'product_uom': move.product_uom.id,                                'date_planned': picking.scheduled_date,})
​               picking.purchase_id.state="purchase"        
       
​res=super(StockPickingInherit,self).button_validate()
​​return res

before validation I modify the state of the purchase order to draft, I then add purchase order lines with the extra products that are in the stock picking but not in the order and finally I revert the state to purchase. It is important to link the stock picking line with the purchase order line through the stock.move.purchase_line_id field.



Avatar
Discard

Are you still using this solution . V17 or v18 ? i have the same issu with some delivery that have to be modified from PO

Best Answer

Odoo allows to receive products without any purchase order. In many business cases this is necessary. You would need to update the purchase order before the goods receipt if you want to have it in your purchase order.

If not in you purchase order, you would need to post the vendor invoice without reference to a purchase order.

But if product B have the same properties as product A, why don't you manage them as the same product on your end?  If you need traceability, set up lot number in the Inventory.

Avatar
Discard
Author

Product B has a different barcode, price and other minor differences which are not of importance. I consider it a variant, but nevertheless it is a different product.

General recommendation for internal logistics is to relabel everything at goods reciept with your own labels. With using Variants or manage as two different producst, you must know at the point where you register sales order to choose the correct. As long as customer can receive either or. Seems to me tricky to manage efficient.

Related Posts Replies Views Activity
3
Sep 18
9407
1
Dec 24
2152
2
Aug 22
4161
0
Sep 20
2582
2
Mar 19
4650