Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

How to validate multiple scrap orders at the same time, and change status from draft to done, with a server action

Naroči se

Get notified when there's activity on this post

This question has been flagged
stockscrapaction.servermultiple.scrap.ordersvalidate.scrap.orders
2 Odgovori
1848 Prikazi
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
Opusti
Avatar
ludivinagarcias@adhocsistemas.com.mx
Avtor 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
Opusti
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
Opusti
Enjoying the discussion? Don't just read, join in!

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Inserting new record in stock.scrap Solved
stock scrap create()
Avatar
Avatar
1
dec. 21
3436
Products for fairs, marketing purposes,..
stock stock_location scrap marketing.activity
Avatar
Avatar
1
nov. 25
1046
Scrap product new cost
stock inventory scrap Scrapping
Avatar
Avatar
1
avg. 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
11126
Inventory Valuation Odoo 15
stock
Avatar
Avatar
1
okt. 25
1802
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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