Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

list object has no attribute get, Migrating web/binary/saveas to v10 api need HELP

Odebírat

Get notified when there's activity on this post

This question has been flagged
listobjectattributeerrorgetattribute
8334 Zobrazení
Avatar
Eugen Don

HI Guys im trying to migrate the old web/binary/saveas controller from v8 into v10 since id like to have access to my attachments via website url and attachment_id like this: http://localhost/8069/web/binary/saveas?filename_field=datas_fname&field=datas&model=ir.attachment&id=220


Heres my code:

class Binary(http.Controller):

    @http.route('/web/binary/saveas', type='http', auth="public") @serialize_exception def saveas(self, model, field, id=None, filename_field=None, context=None, **kw):

        """ Download link for files stored as binary fields.

        If the ``id`` parameter is omitted, fetches the default value for the binary field (via ``default_get``), otherwise fetches the field for that precise record.

        :param str model: name of the model to fetch the binary from :param str field: binary field :param str id: id of the record from which to fetch the binary :param str filename_field: field holding the file's name, if any :returns: :class:`werkzeug.wrappers.Response` """ if context is None:

            context = {} Model = request.env[model] cr, uid, context = request.cr, request.uid, request.context fields = [field] content_type = 'application/octet-stream' if filename_field:

            fields.append(filename_field) if id:

            fields.append('file_type') res = Model.read([int(id)], fields) if res.get('file_type'):

                content_type = res['file_type'] else:

            res = Model.default_get(fields) filecontent = base64.b64decode(res.get(field) or '') if not filecontent:

            return request.not_found() else:

            filename = '%s_%s' % (model.replace('.', '_'), id) if filename_field:

                filename = res.get(filename_field, '') or filename return request.make_response( filecontent, [('Content-Type', content_type), ('Content-Disposition', content_disposition(filename))])


Heres the Error I get:

> /opt/odoo/10/custom/testing/website_doc/controllers/main.py(93)saveas()-> if res.get('file_type'): (Pdb) nextTraceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 508, in handle_one_response self.run_application() File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 494, in run_application self.result = self.application(self.environ, self.start_response) File "/opt/odoo/10/srv/odoo/service/wsgi_server.py", line 184, in application return application_unproxied(environ, start_response) File "/opt/odoo/10/srv/odoo/service/wsgi_server.py", line 170, in application_unproxied result = handler(environ, start_response) File "/opt/odoo/10/srv/odoo/http.py", line 1306, in __call__ return self.dispatch(environ, start_response) File "/opt/odoo/10/srv/odoo/http.py", line 1280, in __call__ return self.app(environ, start_wrapped) File "/usr/local/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 588, in __call__ return self.app(environ, start_response) File "/opt/odoo/10/srv/odoo/http.py", line 1471, in dispatch result = ir_http._dispatch() File "/opt/odoo/10/srv/addons/website_sale/models/ir_http.py", line 15, in _dispatch return super(IrHttp, cls)._dispatch() File "/opt/odoo/10/srv/addons/website/models/ir_http.py", line 209, in _dispatch resp = super(Http, cls)._dispatch() File "/opt/odoo/10/srv/addons/web_editor/models/ir_http.py", line 21, in _dispatch return super(IrHttp, cls)._dispatch() File "/opt/odoo/10/srv/addons/utm/models/ir_http.py", line 20, in _dispatch response = super(IrHttp, cls)._dispatch() File "/opt/odoo/10/srv/odoo/addons/base/ir/ir_http.py", line 199, in _dispatch return cls._handle_exception(e) File "/opt/odoo/10/srv/addons/website/models/ir_http.py", line 261, in _handle_exception return super(Http, cls)._handle_exception(exception) File "/opt/odoo/10/srv/odoo/addons/base/ir/ir_http.py", line 169, in _handle_exception return request._handle_exception(exception) File "/opt/odoo/10/srv/odoo/http.py", line 766, in _handle_exception return super(HttpRequest, self)._handle_exception(exception) File "/opt/odoo/10/srv/odoo/addons/base/ir/ir_http.py", line 195, in _dispatch result = request.dispatch() File "/opt/odoo/10/srv/odoo/http.py", line 825, in dispatch r = self._call_function(**self.params) File "/opt/odoo/10/srv/odoo/http.py", line 331, in _call_function return checked_call(self.db, *args, **kwargs) File "/opt/odoo/10/srv/odoo/service/model.py", line 119, in wrapper return f(dbname, *args, **kwargs) File "/opt/odoo/10/srv/odoo/http.py", line 324, in checked_call result = self.endpoint(*a, **kw) File "/opt/odoo/10/srv/odoo/http.py", line 933, in __call__ return self.method(*args, **kw) File "/opt/odoo/10/srv/odoo/http.py", line 504, in response_wrap response = f(*args, **kw) File "/opt/odoo/10/custom/testing/website_doc/controllers/main.py", line 93, in saveas if res.get('file_type'): AttributeError: 'list' object has no attribute 'get'{'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate, sdch', 'HTTP_ACCEPT_LANGUAGE': 'de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'website_lang=en_US; _ga=GA1.1.1642433694.1483291085; planner_crm_last_page=Welcome0; session_id=5a17190397517d6fe8be8de0e1b84a301622e4c9; planner_website_last_page=Welcome0', 'HTTP_DNT': '1', 'HTTP_HOST': 'hp1:8020', 'HTTP_REFERER': 'http://hp1:8020/doc/how-to/formulare-711/externe-formulare-492', 'HTTP_UPGRADE_INSECURE_REQUESTS': '1', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36', 'PATH_INFO': '/web/binary/saveas', 'QUERY_STRING': 'filename_field=datas_fname&field=datas&model=ir.attachment&id=222', 'REMOTE_ADDR': '192.168.0.10', 'REMOTE_PORT': '49785', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'SERVER_NAME': 'hp1.don-it-service.de', 'SERVER_PORT': '8020', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'gevent/1.0 Python/2.7', 'werkzeug.request': <Request 'http://hp1:8020/web/binary/saveas?filename_field=datas_fname&field=datas&model=ir.attachment&id=222' [GET]>, 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fb3775cf1e0>, 'wsgi.input': <gevent.pywsgi.Input object at 0x7fb36519f0d0>, 'wsgi.multiprocess': False, 'wsgi.multithread': False, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)} failed with AttributeError 192.168.0.10 - - [2017-01-06 11:32:15] "GET /web/binary/saveas?filename_field=datas_fname&field=datas&model=ir.attachment&id=222 HTTP/1.1" 500 161 4.483348


can anyone provide a hint on what im doing wrong?



Best Regards

Eugen


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

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
AttributeError: 'int' object has no attribute 'get'?
attributeerror get no attribute
Avatar
0
bře 15
8808
How can I solve this AttributeError?
object attributeerror
Avatar
0
bře 15
6448
AttributeError: 'str' object has no attribute 'get' error
object attributeerror get str AttributeError: 'str'
Avatar
Avatar
1
čvc 24
5064
I got this error AttributeError: 'list' object has no attribute 'id' Vyřešeno
list attributeerror odooV8
Avatar
Avatar
1
pro 23
54613
Odoo-v14.0 | AttributeError: 'super' object has no attribute 'home'
object attributeerror home customer_portal
Avatar
Avatar
1
kvě 21
11394
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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