Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

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

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
listobjectattributeerrorgetattribute
8342 Vues
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
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
AttributeError: 'int' object has no attribute 'get'?
attributeerror get no attribute
Avatar
0
mars 15
8809
How can I solve this AttributeError?
object attributeerror
Avatar
0
mars 15
6452
AttributeError: 'str' object has no attribute 'get' error
object attributeerror get str AttributeError: 'str'
Avatar
Avatar
1
juil. 24
5068
I got this error AttributeError: 'list' object has no attribute 'id' Résolu
list attributeerror odooV8
Avatar
Avatar
1
déc. 23
54615
Odoo-v14.0 | AttributeError: 'super' object has no attribute 'home'
object attributeerror home customer_portal
Avatar
Avatar
1
mai 21
11397
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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