Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Im trying to create webkit report for stock.picking (eg. Picking Slip) and I cannot access customer nor product for this picking list. I know picking has sale_id and purchase_order_id and even product_id but these values are empty. How to access sale.order from low level stock.picking?
If the stock.picking (in this case it should be Delivery Order) is created from Sale Order, then the sale_id field should be populated.
Another path that you might want to check is going through the relationship between stock.move (which has picking_id of the parent stock.picking) which is related to sale.order.line from stock.move's sale_line_id. sale.order.line is related to sale.order through it's order_id.
The relationship from stock.move is more beneficial if you are searching stock.pickings for a sale.order (the reverse of what you need) due to partial shipments, splitting of DO, returns, etc.
Here is the code to access the stock move from sale order line on Odoo 8:
_inherit = 'sale.order.line'
def get_stock_moves(self, stock_picking_type_codes=['outgoing', 'internal'], values=None):
stock_picking_types = self.env['stock.picking.type'].search( [('code','in',stock_picking_type_codes)])
procurement_orders = self.env['procurement.order'].search([('sale_line_id','=',self.id)])
stock_moves = self.env['stock.move'].search([('procurement_id','in',[procurement_order.id for procurement_order in procurement_orders]),
('picking_type_id','in',[stock_picking_type.id for stock_picking_type in stock_picking_types])
Thank you for your reply.
Unfortunately, in Odoo V9, there is no more reference of sale_xxx in stock_picking or stock_move tables ...
So you can't link sale and stock.
I want to do that, because I would like to get discount (from sale_order_line) to print it on delivery order (from stock.picking).
Thank you Ahmed Ababneh, with your answer I built a SQL request :
FROM stock_picking a
WHERE a.id = b.picking_id
AND b.procurement_id = c.id
AND c.sale_line_id = d.id
AND d.order_id = e.id
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 12/4/14, 3:43 PM|
|Seen: 3567 times|
|Last updated: 3/8/16, 3:47 AM|