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 validate multiple scrap orders at the same time, and change status from draft to done, with a server action

Subscribe

Get notified when there's activity on this post

This question has been flagged
stockscrapaction.servermultiple.scrap.ordersvalidate.scrap.orders
2 Replies
1836 Views
Avatar
ludivinagarcias@adhocsistemas.com.mx

Hello! 
I hope someone could help me .. 

I'd like to find the best way to validate multiple scrap orders at the same time. 

Thanks in advance...! 

v16E
There are a large number of scrap orders (previously imported with Excel),  so we need to validate them and change their status from draft to done, en masse and not one by one.






To validate all the orders at the same time, I created an Action Server, 


When one scrap order is selected, sometimes works (it is validated and change from draft to done) and other times doesn't work, and got this error:

 


When multiple scrap orders are selected, never works. 



and got this error: 

RPC_ERROR

Odoo Server Error

Traceback (most recent call last):

  File "/home/odoo/src/odoo/odoo/models.py", line 5174, in ensure_one

    _id, = self._ids

ValueError: too many values to unpack (expected 1)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/home/odoo/src/odoo/odoo/tools/safe_eval.py", line 383, in safe_eval

    return unsafe_eval(c, globals_dict, locals_dict)

  File "ir.actions.server(901,)", line 1, in

  File "/home/odoo/src/odoo/addons/stock/models/stock_scrap.py", line 187, in action_validate

    self.ensure_one()

  File "/home/odoo/src/odoo/odoo/models.py", line 5177, in ensure_one

    raise ValueError("Expected singleton: %s" % self)

ValueError: Expected singleton: stock.scrap(5, 4)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/home/odoo/src/odoo/odoo/http.py", line 1638, in _serve_db

    return service_model.retrying(self._serve_ir_http, self.env)

  File "/home/odoo/src/odoo/odoo/service/model.py", line 133, in retrying

    result = func()

  File "/home/odoo/src/odoo/odoo/http.py", line 1665, in _serve_ir_http

    response = self.dispatcher.dispatch(rule.endpoint, args)

  File "/home/odoo/src/odoo/odoo/http.py", line 1869, in dispatch

    result = self.request.registry['ir.http']._dispatch(endpoint)

  File "/home/odoo/src/odoo/addons/website/models/ir_http.py", line 237, in _dispatch

    response = super()._dispatch(endpoint)

  File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch

    result = endpoint(**request.params)

  File "/home/odoo/src/odoo/odoo/http.py", line 700, in route_wrapper

    result = endpoint(self, *args, **params_ok)

  File "/home/odoo/src/odoo/addons/web/controllers/action.py", line 42, in run

    result = action.run()

  File "/home/odoo/src/odoo/odoo/addons/base/models/ir_actions.py", line 674, in run

    res = runner(run_self, eval_context=eval_context)

  File "/home/odoo/src/odoo/addons/website/models/ir_actions_server.py", line 61, in _run_action_code_multi

    res = super(ServerAction, self)._run_action_code_multi(eval_context)

  File "/home/odoo/src/odoo/odoo/addons/base/models/ir_actions.py", line 544, in _run_action_code_multi

    safe_eval(self.code.strip(), eval_context, mode="exec", nocopy=True, filename=str(self))  # nocopy allows to return 'action'

  File "/home/odoo/src/odoo/odoo/tools/safe_eval.py", line 397, in safe_eval

    raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))

ValueError: : "Expected singleton: stock.scrap(5, 4)" while evaluating

'records.action_validate()'


The above server error caused the following client error:

RPC_ERROR: Odoo Server Error

    at makeErrorFromResponse (https://mybd-test-12773407.dev.odoo.com/web/assets/42953-a4ee3f4/web.assets_backend.min.js:993:163)

    at XMLHttpRequest. (https://mybd-test-12773407.dev.odoo.com/web/assets/42953-a4ee3f4/web.assets_backend.min.js:1001:13)

I appreciate a lot your help to find the best way to validate multiple scrap orders. 

Thank you!!!

LG

0
Avatar
Discard
Avatar
ludivinagarcias@adhocsistemas.com.mx
Author Best Answer

Hello! Thank you... 
I made the change 
from records.action_validate() -> rec.action_validate()


but doesn't work, I get this error: 
RPC_ERROR

Odoo Server Error

Traceback (most recent call last):

  File "/home/odoo/src/odoo/odoo/tools/https://test-12773407.dev.odoo.com/web/assets/43048-2a8d7a1/web.assets_backend.min.js:1002:13)

0
Avatar
Discard
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

Try the following code,

for rec in records:     

rec.action_validate()


Hope it helps

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
Inserting new record in stock.scrap Solved
stock scrap create()
Avatar
Avatar
1
Dec 21
3431
Products for fairs, marketing purposes,..
stock stock_location scrap marketing.activity
Avatar
Avatar
1
Nov 25
1044
Scrap product new cost
stock inventory scrap Scrapping
Avatar
Avatar
1
Aug 20
4146
How can I configure Odoo to post Inventory Adjustments and Scrap Operations to different GL accounts? Solved
stock accounting scrap v11 adjustment
Avatar
Avatar
1
Jan 22
11116
Inventory Valuation Odoo 15
stock
Avatar
Avatar
1
Oct 25
1800
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