Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

ValueError: forbidden opcode(s) in 'lambda': STORE_ATTR

Odoberať

Get notified when there's activity on this post

This question has been flagged
computed-fields
1 Odpoveď
17404 Zobrazenia
Avatar
ALEXANDRU RAILEANU


I have this error because a Computed x_text_field filed I am trying to use.

The following code:

def _compute_first (self):
for record in self:
if len(record.x_text_field) >1:
record.x_text_field = u"\u00A0"+ record.x_text_field [1]+"."
else:
record.x_text_field = "empty"
x_text_field = fields.Char(string="x_name", required=True)
initials_first = fields.Char(compute='_compute_first',string="name initials first")


Error:
Odoo Server Error

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 944, in __get__
value = record.env.cache.get(record, self)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 960, in get
value = self._data[field][record.id][key]
KeyError: <odoo.api.Environment object at 0x7fe6d02a1358>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 646, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 307, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/usr/lib/python3/dist-packages/odoo/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 339, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 332, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 927, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 512, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 920, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 912, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 689, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 680, in call_kw_multi
result = method(recs, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4976, in onchange
value = record[name]
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4660, in __getitem__
return self._fields[key].__get__(self, type(self))
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 950, in __get__
self.determine_draft_value(record)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1070, in determine_draft_value
self._compute_value(record)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1008, in _compute_value
self.compute(records)
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_model.py", line 30, in <lambda>
func = lambda self: safe_eval(text, SAFE_EVAL_BASE, {'self': self}, mode="exec")
File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 346, in safe_eval
c = test_expr(expr, _SAFE_OPCODES, mode=mode)
File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 211, in test_expr
assert_valid_codeobj(allowed_codes, code_obj, expr)
File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 191, in assert_valid_codeobj
assert_valid_codeobj(allowed_codes, const, 'lambda')
File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 187, in assert_valid_codeobj
raise ValueError("forbidden opcode(s) in %r: %s" % (expr, ', '.join(opname[x] for x in codes)))
ValueError: forbidden opcode(s) in 'lambda': STORE_ATTR


What I did wrong?

1
Avatar
Zrušiť
Avatar
D Enterprise
Best Answer

Hii,

Here is updated code

@api.depends('x_text_field')

    def _compute_first(self):

        for record in self:

            if record.x_text_field and len(record.x_text_field) > 1:

                record.initials_first = u"\u00A0" + record.x_text_field[1] + "."

            else:

                record.initials_first = "empty"

x_text_field = fields.Char(string="x_name", required=True)

initials_first = fields.Char(compute='_compute_first',string="name initials first",store=True )


i hope it is use full



0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Make stored compute filed recompute after changing it logic but not depedencies.
computed-fields
Avatar
Avatar
Avatar
Avatar
3
apr 25
7985
Compute Fields Solved
computed-fields
Avatar
Avatar
2
júl 24
9522
Odoo computed field
computed-fields
Avatar
Avatar
1
jan 24
2925
Compute field odoo 14
computed-fields
Avatar
Avatar
1
júl 22
3077
Adding Sum attributes on Float fields, which are computed fields, but not saved into database.
computed-fields
Avatar
Avatar
Avatar
Avatar
4
mar 24
12269
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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