Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

How to access sale.order from stock.picking

Subscribe

Get notified when there's activity on this post

This question has been flagged
pickingsale.orderwebkit_reportstock.picking
4 Replies
18448 Views
Avatar
Marek Toman

Hi,

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?

Thank you,

Marek

0
Avatar
Discard
Avatar
Ivan
Best Answer

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.

2
Avatar
Discard
Avatar
Ahmed Ababneh
Best Answer

Here is the code to access the stock move from sale order line on Odoo 8:

class xx_sale_order_line(models.Model):

_inherit = 'sale.order.line'

@api.multi

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])

])

return stock_moves        

1
Avatar
Discard
Avatar
TKF
Best Answer

Hello Ivan,

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).


Edit 25/04/2016

Thank you Ahmed Ababneh, with your answer I built a SQL request :


SELECT e.NAME

FROM stock_picking a

,stock_move b

,procurement_order c

,sale_order_line d

,sale_order e

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



Regards,

FTK

0
Avatar
Discard
Mathieu Laflamme

Some inner joins and more relevant aliases would look much better!

SELECT so.NAME

FROM stock_picking sp

INNER JOIN stock_move sm

ON sp.id = sm.picking_id

INNER JOIN procurement_order po

ON sm.procurement_id = po.id

INNER JOIN sale_order_line sol

ON po.sale_line_id = sol.id

INNER JOIN sale_order so

ON sol.order_id = so.id

Mathieu Laflamme

Apparently this forum doesn't like the leading spaces!

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Where are Stock Picking created from Sale Order?
sale.order stock.picking
Avatar
Avatar
1
Apr 25
2475
Confirm sale order without creating delivery in Odoo16
sale.order stock.picking
Avatar
0
May 23
3771
Multiple actions in one screen Solved
picking stock.picking
Avatar
Avatar
2
Mar 22
3184
Picking note created when validating a sale order
picking sale.order
Avatar
Avatar
3
Mar 18
5377
How can I find the 'create' method for stock.picking ?
sale.order 8.0 stock.picking
Avatar
Avatar
1
Jan 25
7967
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now