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

Subcontracting location doesn't unreserve stock when order is cancelled

Subscribe

Get notified when there's activity on this post

This question has been flagged
stockinventoryresupplyv15
2 Replies
3152 Views
Avatar
Kacper Kucharski

I'm working with v15. When order which requires resupply order is cancelled the stock that was initially reserved from subcontracting location stay reserved (the available quantity doesn't go up) which creates an overstocking of components on the supplier side. Cancelling the PO, MO and SO doesn't change it at all. On hand quantity doesn't change. How can the stock be unreserved when order is cancelled?

0
Avatar
Discard
Jaideep

To ensure understanding, is the reference to subcontract orders, that have been cancelled after the material has been transferred to supplier or prior to validating transfer?

Kacper Kucharski
Author

We keep some stock in the subcontracting location, available for the supplier to use when orders come in, so when it's available the resupply order isn't raised and the stock is taken from that location. So when the order is raised that stock is reserved and when cancelled it stays reserved, but the On hand quantity stays the same. Hope this explains.

Avatar
Midhun M M
Best Answer

Actually odoo have some resevation issues still they are not rectified. We are in Odoo 16 EE.

Whenever reservation issues are coming we need to run the server actions given by Odoo as temporoy solution.

There is no reply after that..!

Component Reservation Issue

------------------------------------

# Available variables:
#  - env: Odoo Environment on which the action is triggered
#  - model: Odoo Model of the record on which the action is triggered; is a void recordset
#  - record: record on which the action is triggered; may be void
#  - records: recordset of all records on which the action is triggered in multi-mode; may be void
#  - time, datetime, dateutil, timezone: useful Python libraries
#  - float_compare: Odoo function to compare floats based on specific precisions
#  - log: log(message, level='info'): logging function to record debug information in ir.logging table
#  - UserError: Warning Exception to use with raise
#  - Command: x2Many commands namespace
# To return an action, assign: action = {...}

quants = env["stock.quant"].search([])

move_line_ids = []

warning = ""

for quant in quants:

    move_lines = env["stock.move.line"].search(

        [

            ("product_id", "=", quant.product_id.id),

            ("location_id", "=", quant.location_id.id),

            ("lot_id", "=", quant.lot_id.id),

            ("package_id", "=", quant.package_id.id),

            ("owner_id", "=", quant.owner_id.id),

            ("reserved_qty", "!=", 0),

        ]

    )

    move_line_ids += move_lines.ids

    reserved_on_move_lines = sum(move_lines.mapped("reserved_qty"))

    move_line_str = str.join(

        ", ", [str(move_line_id) for move_line_id in move_lines.ids]

    )



    if quant.location_id.should_bypass_reservation():

        # If a quant is in a location that should bypass the reservation, its `reserved_quantity` field

        # should be 0.

        if quant.reserved_quantity != 0:

            quant.write({"reserved_quantity": 0})

    else:

        # If a quant is in a reservable location, its `reserved_quantity` should be exactly the sum

        # of the `reserved_qty` of all the partially_available / assigned move lines with the same

        # characteristics.

        if quant.reserved_quantity == 0:

            if move_lines:

                move_lines.with_context(bypass_reservation_update=True).write(

                    {"reserved_uom_qty": 0}

                )

        elif quant.reserved_quantity
            quant.write({"reserved_quantity": 0})

            if move_lines:

                move_lines.with_context(bypass_reservation_update=True).write(

                    {"reserved_uom_qty": 0}

                )

        else:

            if reserved_on_move_lines != quant.reserved_quantity:

                move_lines.with_context(bypass_reservation_update=True).write(

                    {"reserved_uom_qty": 0}

                )

                quant.write({"reserved_quantity": 0})

            else:

                if any(move_line.reserved_qty
                    move_lines.with_context(bypass_reservation_update=True).write(

                        {"reserved_uom_qty": 0}

                    )

                    quant.write({"reserved_quantity": 0})



move_lines = env["stock.move.line"].search(

    [

        ("product_id.type", "=", "product"),

        ("reserved_qty", "!=", 0),

        ("id", "not in", move_line_ids),

    ]

)



move_lines_to_unreserve = []



for move_line in move_lines:

    if not move_line.location_id.should_bypass_reservation():

        move_lines_to_unreserve.append(move_line.id)



if len(move_lines_to_unreserve) > 1:

    env.cr.execute(

        """

            UPDATE stock_move_line SET reserved_uom_qty = 0, reserved_qty = 0 WHERE id in %s ;

        """

        % (tuple(move_lines_to_unreserve),)

    )

elif len(move_lines_to_unreserve) == 1:

    env.cr.execute(

        """

        UPDATE stock_move_line SET reserved_uom_qty = 0, reserved_qty = 0 WHERE id = %s ;

        """

        % (move_lines_to_unreserve[0])

    )



Unreserve Quont

---------------------

# Available variables:
#  - env: Odoo Environment on which the action is triggered
#  - model: Odoo Model of the record on which the action is triggered; is a void recordset
#  - record: record on which the action is triggered; may be void
#  - records: recordset of all records on which the action is triggered in multi-mode; may be void
#  - time, datetime, dateutil, timezone: useful Python libraries
#  - float_compare: Odoo function to compare floats based on specific precisions
#  - log: log(message, level='info'): logging function to record debug information in ir.logging table
#  - UserError: Warning Exception to use with raise
#  - Command: x2Many commands namespace
# To return an action, assign: action = {...}

for record in records:
  if record.reserved_quantity > 0:
    record.write({'reserved_quantity':0})


FG Lot Generation Issue

--------------------------

# Available variables:
#  - env: Odoo Environment on which the action is triggered
#  - model: Odoo Model of the record on which the action is triggered; is a void recordset
#  - record: record on which the action is triggered; may be void
#  - records: recordset of all records on which the action is triggered in multi-mode; may be void
#  - time, datetime, dateutil, timezone: useful Python libraries
#  - float_compare: Odoo function to compare floats based on specific precisions
#  - log: log(message, level='info'): logging function to record debug information in ir.logging table
#  - UserError: Warning Exception to use with raise
#  - Command: x2Many commands namespace
# To return an action, assign: action = {...}

env.cr.execute("""UPDATE stock_move_line sml SET reserved_uom_qty = 0, reserved_qty = 0 WHERE sml.move_id in (select a.move_id from (select production_id,sm.id as move_id from stock_move sm JOIN mrp_production mp on mp.id = sm.production_id where mp.state in ('to_close','progress','confirmed'))a) ;""")



0
Avatar
Discard
Kacper Kucharski
Author

That's very interesting so it could not be related to our setup after all. I'll try this and see if it helps. Thanks a lot.

Avatar
Jaideep
Best Answer

Did create  use case and tested, it seems to work as intended. 

Created 2 PO's for subcontract product and then validated the component transfers to subcontract location. Post that went out to cancel one of the orders (the PO and also ensured the associated Inventory receipt were cancelled). 




The products (components) in sub-contract location were no longer reserved. The on-hand qty wouldn't change as the component didn't get consumed, however the available qty were updated.


From your post it seems the expectation is for on hand Qty to increase. Could you confirm if you mean the on-hand qty in WH/Stock or Sub-contract location to increase? On cancelling an order there are no transfers generated only reservation is impacted.


Could you also confirm if you are using odoo default routes and locations or they have been modified? With default routes, the resupply route is always triggered irrespective of available component stocks in subcontract location.

0
Avatar
Discard
Kacper Kucharski
Author

Thank you for your answer. I'm referring to the Available qty, the On Hand qty stay the same as it should. The routes were modified quite a lot by a person who worked here before and I'm trying to bring them back to the default settings as it's causing other problems as well. It's very helpful to know that this works fine with default routes. From what I can see comparing our current setup to runbot, Resupply Subcontractor on Order supply method was changed to 'Take from Stock, if unavailable trigger another rule' and Resupply Subcontractor Source location was changed from WH/Stock to WH/Output. Possibly one of them changes is the source of the issue.

Jaideep

If the available qty does not update in subcontract location then I would look at the receipt operation (for the finished product from sub contractor), this is the operation that is reserving the components.

If the available qty does not update in WH/ Stock location (in the event order was cancelled prior to components being transferred to subcontractor) then I would look at re-supply subcontractor operation. Additionally since your modified route is output and in the event of unavailability at output location it is likely another operation is triggered Stock to Output.

Change of supply method and source location on the resupply route still doesn't explain how an operation is not triggered if components are available at subcontract location.
- The rule
>>> When products are needed in Physical Locations/Subcontracting Location, Resupply Subcontractor are created from WH/Stock to fulfill the need.
If the products are not available in WH/Stock, a rule will be triggered to bring products in this location.<<<

Each time a subcontract order is created this route would be triggered, to reserve product in WH/stock. If you wish Odoo to reserve the component already at subcontract location, then the source location needs to be Physical Locations/Subcontracting Location and if unavailable trigger another rule.

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
Reabastecimiento de almacenes que no compran
inventory resupply v15
Avatar
0
Jun 23
2755
Allocate a quantity of stock for my sellers Solved
stock inventory v15
Avatar
Avatar
2
Dec 21
3549
Issue with quantity available - Odoo 15
stock inventory stock_picking v15
Avatar
Avatar
Avatar
2
Jun 23
3522
Inventory adjustment Solved
stock inventory adjustment v15
Avatar
Avatar
2
Aug 24
3551
How to solve this error Field `show_check_availability` does not exist ?
stock inventory
Avatar
0
Jul 24
2805
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