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

Stock picking removes sale orders link

Subscribe

Get notified when there's activity on this post

This question has been flagged
stock_pickingsales.orderstock_move
2 Replies
5037 Views
Avatar
Zan Banko

Hello I am modifying the stock.picking view form by adding the pre-existing sale_id field, which will link the picking form to a sale order. When I add or change products in the Operations field and click save the Sale_id field is emptied and the link to the sale order is removed. I was wondering if anyone could help me locate which function in StockMove or StockPicking does this so I can override it. I am using Odoo v14.


This is my code if anyone wants to try:

from odoo import models, fields, api
from odoo.exceptions import ValidationError


class StockPickingInherit(models.Model):
_inherit = "stock.picking"


@api.onchange
('partner_id')
def onchange_partner_id(self):
return {'domain': {'sale_id': [('partner_id', 'in', self.get_partner_ids())]}}

def get_partner_ids(self):
res = []
root_id = self.partner_id
if self.partner_id.parent_id.id != False:
root_id = self.partner_id.parent_id
res.append(root_id.id)
for child_id in root_id.child_ids:
res.append(child_id.id)
return res



"id="stock_picking_form_view_inherit" model="ir.ui.view">
name="name">stock.picking.form.view.inherit
name="model">stock.picking
name="inherit_id" ref="stock.view_picking_form"/>
name="arch" type="xml">
name="origin" position="after">
name="sale_id"/>

name="product_uom_qty" position="attributes">
name="invisible">0


"

0
Avatar
Discard
Avatar
Samuddhan Joshi
Best Answer
After creating the stock.picking record, we attempt to link it back to the sale order by adding it to the picking_ids field of the sale order (order.picking_ids += picking).

​if any(line.product_id.is_receipt_require for line in order.order_line):

​        picking_vals = {

​            'picking_type_id': order.warehouse_id.in_type_id.id,

​            'partner_id': order.partner_id.id,

​            'location_dest_id': order.warehouse_id.lot_stock_id.id,

​            'origin': order.name,

​            'sale_id': order.id,

​            'location_id' : order.partner_id.property_stock_supplier.id,

​        }

​        picking = self.env['stock.picking'].create(picking_vals)

​

​        for line in order.order_line:

​            if line.product_id.is_receipt_require:

​                picking_line_vals = {

​                    'picking_id': picking.id,

​                    'product_id': line.product_id.receipt_product.id,

​                    'product_uom_qty': line.product_uom_qty,

​                    'product_uom' : line.product_id.receipt_product.uom_id.id,

​                    'name': line.name,

​                    'location_id' : order.partner_id.property_stock_supplier.id,

​                    'location_dest_id' : order.warehouse_id.lot_stock_id.id,

​                }

​                self.env['stock.move'].create(picking_line_vals)

​                

​        # Update the sale order to link it with the created picking

​        order.picking_ids += picking

​          return res

​    else: ​       

​ return res


1
Avatar
Discard
Avatar
Support GeminateCS
Best Answer

Hello Zan,

Please replace this code in your module. i hope your problem will be solved after adding this code. this is py file and xml file code. change in your xpath so your error will be solved.


py file code

from odoo import models, fields, api
from odoo.exceptions import ValidationError


class StockPickingInherit(models.Model)
_inherit = "stock.picking"

sale_id = fields.Char



Feel free for further assistance on contact@geminatecs.com

Thank you
Geminate Consultancy Services.

0
Avatar
Discard
Support GeminateCS

Hello Zan,

Please replace this code in your module. i hope your problem will be solved after adding this code. this is py file and xml file code. change in your xpath so your error will be solved.

py file code

from odoo import models, fields, api
from odoo.exceptions import ValidationError

class StockPickingInherit(models.Model)
_inherit = "stock.picking"

sale_id = fields.Char

// api onchange('partner_id')
// def onchange_partner_id(self):
// return {'domain': {'sale_id': [('partner_id', 'in', self.get_partner_ids())]}}
//
// def get_partner_ids(self):
// res = []
// root_id = self.partner_id
// if self.partner_id.parent_id.id != False:
// root_id = self.partner_id.parent_id
// res.append(root_id.id)
// for child_id in root_id.child_ids:
// res.append(child_id.id)
// return res

view file code

//record id="stock_picking_form_view_inherit" model="ir.ui.view"
// field name="name">stock.picking.form.view.inherit</field
// field name="model">stock.picking</field
// field name="inherit_id" ref="stock.view_picking_form"
// field name="arch" type="xml"
// xpath expr="//field[@name='origin']" position="after"
// field name="sale_id"
// xpath
//
// xpath expr="field[@name='product_uom_qty']" position="attributes"
// attribute name="invisible">True
// xpath
// field
//record

Feel free for further assistance on contact@geminatecs.com

Thank you
Geminate Consultancy Services.

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
Difference Between move_line_ids and move_line_nosuggest_ids
stock_picking stock_move
Avatar
Avatar
1
Aug 21
8625
Why am I getting "Extra Move" on picking transfers?
stock_picking stock_move
Avatar
0
Feb 17
6856
Use aggregated sum of stock moves in stock picking model Solved
stock_picking stock_move valueerror
Avatar
1
Apr 23
3363
[Routes] Automatic purchase orders --> Stock location wrong (missing)
stock_picking purchase_order stock_move
Avatar
Avatar
1
Jun 22
4102
Change quantity = 0 in PO Odoo 8
stock stock_picking stock_move
Avatar
0
Nov 17
4077
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