İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

ValueError: Expected singleton: as.product.brand(9, 10, 8)

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
modelswriteMethododoo16features
1 Cevapla
2633 Görünümler
Avatar
Sean Craig

So there's a Brand thing from our theme which is a model called as.product.brand. It has a Logo field, for, well, logo, and it's a binary field. We are trying to import the logos dynamically. I have prepared the below codes to loop over files and then figure out the Brand of the file and then update it. It works great when we're working with one file. But whenever I try this with multiple files I get this error: ValueError: Expected singleton: as.product.brand(9, 10, 8)​. 9, 10, 8 here are the brand IDs that were found. I am not sure how to resolve this, I am not even sure why its giving this error. I have added the full error and code below.

for ff in os.listdir(d):
​ff_path = d +'/'+ ff
​images =False               
​​with open(ff_path, "rb") as image_file:
​ ​bytes= image_file.read()                   
​ ​images = base64.b64encode(bytes)               
​ ​image_name = os.path.splitext(ff)[0]               
​ ​if(image_name.startswith("Logo")):                       
​ ​ ​prefix ="Logo_"                       
​ ​ ​suffix ="_"  # Assumes there is always an underscore after the prefix                       
​ ​ ​prefix_end = image_name.index(prefix) +len(prefix)                       
​ ​ ​suffix_start = image_name.index(suffix, prefix_end)                       
​ ​ ​image_name = image_name[prefix_end:suffix_start]                       
​ ​ ​domain = self.get_domain(image_name) # Returns [('name','=ilike',name)]         
​ ​ ​brands = brand_pool.search(domain, limit=1) # brand_pool = self.env['as.product.brand']    
​ ​ ​if not brands:           
​ ​ ​ ​note = note +'\n'+str(ff)                       
​ ​ ​​else:                           
​ ​ ​ ​note = note +'\n'+str(brands)                           
​ ​ ​ ​for brand in brands:                               
​ ​ ​ ​ ​brand.logo = images

Error Message:

Traceback (most recent call last):
  File "C:\Program Files\Odoo\server\odoo\models.py", line 5108, 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 "C:\Program Files\Odoo\server\odoo\http.py", line 1584, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "C:\Program Files\Odoo\server\odoo\service\model.py", line 134, in retrying
    result = func()
  File "C:\Program Files\Odoo\server\odoo\http.py", line 1613, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "C:\Program Files\Odoo\server\odoo\http.py", line 1810, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "C:\Program Files\Odoo\server\odoo\addons\website\models\ir_http.py", line 235, in _dispatch
    response = super()._dispatch(endpoint)
  File "C:\Program Files\Odoo\server\odoo\addons\base\models\ir_http.py", line 149, in _dispatch
    result = endpoint(**request.params)
  File "C:\Program Files\Odoo\server\odoo\http.py", line 699, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "C:\Program Files\Odoo\server\odoo\addons\web\controllers\dataset.py", line 46, in call_button
    action = self._call_kw(model, method, args, kwargs)
  File "C:\Program Files\Odoo\server\odoo\addons\web\controllers\dataset.py", line 33, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "C:\Program Files\Odoo\server\odoo\api.py", line 462, in call_kw
    model.env.flush_all()
  File "C:\Program Files\Odoo\server\odoo\api.py", line 732, in flush_all
    self._recompute_all()
  File "C:\Program Files\Odoo\server\odoo\api.py", line 728, in _recompute_all
    self[field.model_name]._recompute_field(field)
  File "C:\Program Files\Odoo\server\odoo\models.py", line 6152, in _recompute_field
    field.recompute(records)
  File "C:\Program Files\Odoo\server\odoo\fields.py", line 1325, in recompute
    self.compute_value(recs)
  File "C:\Program Files\Odoo\server\odoo\fields.py", line 1347, in compute_value
    records._compute_field_value(self)
  File "C:\Program Files\Odoo\server\odoo\models.py", line 4186, in _compute_field_value
    getattr(self, field.compute)()
  File "c:\program files\odoo\server\addons\atharva_theme_base\models\brands.py", line 26, in _get_logo
    self.image_1920 = self.logo
  File "C:\Program Files\Odoo\server\odoo\fields.py", line 1132, in __get__
    record.ensure_one()
  File "C:\Program Files\Odoo\server\odoo\models.py", line 5111, in ensure_one
    raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: as.product.brand(9, 10, 8)

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    at makeErrorFromResponse (http://localhost:8069/web/assets/2204-495f151/web.assets_backend.min.js:967:163)
    at XMLHttpRequest. (http://localhost:8069/web/assets/2204-495f151/web.assets_backend.min.js:975:13)
0
Avatar
Vazgeç
Avatar
Niyas Raphy (Walnut Software Solutions)
En İyi Yanıt

Hi,

From the shared traceback it seems the issue is with this line of code:  self.image_1920 = self.logo, where self is holding multiple records and thus you receive the single ton error.

You just need to iterate the self over a for loop and treat one record at a time.

For eg:
self.image_1920 = self.logo

Change to
for record in self:
 record.image_1920 = record.logo


Thanks

0
Avatar
Vazgeç
Enjoying the discussion? Don't just read, join in!

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

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
v16: custom model not created, what is error in py file Çözüldü
models odoo16features
Avatar
Avatar
1
Nis 24
2555
odoo 16: Model creation problem - not creating model Çözüldü
models odoo16features
Avatar
Avatar
1
May 23
4413
Odoo 16: Create Just one record for a model and asign it many childs
models one2many_list odoo16features
Avatar
Avatar
2
Oca 24
2247
how to fetch settings values Çözüldü
settings models odoo16features
Avatar
Avatar
Avatar
3
Tem 23
3673
Values entered in One2many field form disapper when clicked on "Save" button in V9.
models write writeMethod
Avatar
Avatar
1
Eki 16
7355
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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