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

Reverse Transfer - how to stop returning more than was delivered - Odoo.sh v16

Subscribe

Get notified when there's activity on this post

This question has been flagged
returnsodoo
1 Reply
3689 Views
Avatar
Roy Antunovich

How do I stop a reverse transfer from being done for more than the delivered quantity on the Sales Order? At the moment my team can change the quantity on the Reverse Transfer to more than was delivered, this then leave the sales order with a negative delivered quantity.

I have a simple Automated action that stops delivering more product than is ordered. This is run on the Stock Move model, matching all records, and executes the python code.

if record.product_uom_qty

  raise UserError("You can't transfer more than the Initial Demand!")


I can't work out how to write this for a Reverse Transfer (Return Picking model) where the quantity gets compared to the delivered quantity on the sales order.

Any help would be appreciated.

0
Avatar
Discard
Luis Jacobo

We are in the same page mate, can you share the server action for avoid delivering more product than is ordered?

Thanks.

Avatar
Gracious Joseph
Best Answer

To stop a reverse transfer in Odoo 16 from being done for more than the delivered quantity, you can implement an automated action or override the relevant Odoo method to enforce this restriction.

Here’s how you can implement this:

1. Understanding the Requirement

  • Reverse Transfer: This process is initiated from the original delivery picking to return goods.
  • Delivered Quantity: You need to ensure that the return quantity does not exceed the delivered quantity.

2. Automated Action Approach

You can create an Automated Action that validates the return picking quantity before confirmation.

Steps to Create Automated Action

  1. Activate Developer Mode:
    • Go to Settings > Activate Developer Mode.
  2. Navigate to Automated Actions:
    • Go to Settings > Technical > Automated Actions.
  3. Create a New Automated Action:
    • Model: stock.move
    • Trigger: On Creation & Update
    • Condition: Add a domain to target only reverse transfers:
      [('picking_type_id.code', '=', 'incoming'), ('origin_returned_move_id', '!=', False)]
      
    • Python Code:
      for record in records:
          if record.origin_returned_move_id:
              delivered_qty = record.origin_returned_move_id.quantity_done
              if record.quantity_done > delivered_qty:
                  raise UserError(
                      "You cannot return more than the delivered quantity! Delivered: %s, Trying to Return: %s" %
                      (delivered_qty, record.quantity_done)
                  )
      

3. Server-Side Method Override (Recommended)

If your team is familiar with Odoo development, overriding the button_validate method on the stock.picking model ensures this logic is enforced at the server level.

Steps to Implement

  1. Create a Custom Module: If you don’t have one already, create a custom module.
  2. Extend the stock.picking Model: Override the button_validate method to add validation for reverse transfers.
    Code Example:
    from odoo import models, api
    from odoo.exceptions import UserError
    
    class StockPicking(models.Model):
        _inherit = 'stock.picking'
    
        @api.model
        def button_validate(self):
            for move in self.move_ids_without_package:
                if move.origin_returned_move_id:
                    delivered_qty = move.origin_returned_move_id.quantity_done
                    if move.quantity_done > delivered_qty:
                        raise UserError(
                            "You cannot return more than the delivered quantity! Delivered: %s, Trying to Return: %s" %
                            (delivered_qty, move.quantity_done)
                        )
            return super(StockPicking, self).button_validate()
    
  3. Restart the Server and Upgrade the Module:
    • Restart the Odoo server.
    • Upgrade the module.
    ./odoo-bin -u your_custom_module_name
    

4. Testing

  • Create a sales order and confirm delivery.
  • Initiate a reverse transfer.
  • Try to input a return quantity greater than the delivered quantity.
  • The system should block the operation and raise an appropriate error message.

5. Additional Considerations

  • Multi-Line Validation: If reverse transfers have multiple lines, ensure the logic applies to all lines.
  • Negative Quantities: Check if your setup allows negative stock, as this can also affect the validation.
  • Customizable Messaging: You can improve user feedback by including the product name or other relevant details in the error message.

6. Advantages of the Method

  • Automated Action: Quick to implement with minimal technical involvement.
  • Server-Side Method: More robust and ensures the rule is enforced even if users bypass the UI (e.g., through API).

By implementing one of these approaches, you can effectively prevent your team from returning more items than were delivered, maintaining accurate stock and sales order records. Let me know if you need further clarification or help!

0
Avatar
Discard
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
Not returning list view Solved
returns odoo odoo12
Avatar
Avatar
Avatar
4
Jul 19
4736
邮箱无法正常使用
odoo
Avatar
Avatar
1
Nov 25
2223
SOC 1 Report
odoo
Avatar
0
Nov 25
146
How do I go about this error? I am trying to uninstall a module
odoo
Avatar
Avatar
1
Nov 25
3442
How to import product variants with my own external id when using dynamic creation mode Solved
odoo
Avatar
Avatar
2
Aug 25
4010
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