Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

Form using Controller dont work

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
formir_attachmentcontrollerpostodoo12
4254 Visualizzazioni
Avatar
Gabriel

Odoo version: 12

 Hello everyone, I am trying to create a form and send some images by POST method in a Module that I set up. 

I created the fields and the controlled and the xml, below.

Controller:

On the controller I didn't worry now about making it work perfectly yet I will implement it better

class PackagesEnhanced(http.Controller):
@http.route(['/my/account'], type='http', auth='user', website=True)
def account(self, redirect=None, **post):
  partner = request.env.user.partner_id
  Attachments = request.env['ir.attachment']
  name = post.get('attachment').filename
  file = post.get('attachment')
  attachment_id = Attachments.create({
'name': name,
'type': 'binary',
'datas': base64.b64encode(file.read()),
'res_model': partner._name,
'res_id': partner.id
  })
  partner.update({
'attachment': [(4, attachment_id.id)],
  })


Xml

<form string="Transfer" action="/my/account" method="post" class="s_website_form" enctype="multipart/form-data" >
<input type="file" name="attachment" class="file" multiple="true" data-show-upload="true" data-show-caption="true" lass="file" data-show-preview="true" id="project.id"></input>
<button type="submit" name="Upload" style="margin-top:20px;" class="fa fa-upload">
 Upload
</button>
</form>

Fields:

attachment = fields.Many2many('ir.attachment', 'attach_rel', 'doc_id', 'attach_id3',
string="Attachment",
help='You can attach the copy of your document', copy=False)


When I click Upload nothing happens.
When I try to directly access the link 127.0.0.1:8069/my/account I see that the system performs the function of the controller

I am not sure how Odoo generates his page, but I tried to see the code of the page to see if the <Form> field was showing, and I noticed that he is not on the page but the other fields are:

<div class="col-md-offset-5 col-sm-offset-4 col-sm-8 col-md-7" style="margin-top:30px;">
<div class="s_website_form">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()">
<input type="file" name="attachment" class="file" multiple="multiple" data-show-upload="true" data-show-caption="true" lass="file" data-show-preview="true" id="project.id">
<button type="button" name="Upload" style="margin-top:20px;" class="btn fa fa-upload" data-original-title="" title="">
Upload
</button></div></div>
I didn't try to venture too much, I just tried to copy the code and add it to mine with minor changes to work, but I can't find what I'm doing wrong. If anyone can help me thank you very much :)
0
Avatar
Abbandona
Oeil d'Horis

Hi, i have the same problem. Did you solve this ? if yes pls help me

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
How to take records from wizards to form in odoo?
wizard form odoo12
Avatar
Avatar
2
set 23
5533
How to change default form view in stock.picking model
form form_view odoo12
Avatar
Avatar
Avatar
2
set 22
6115
How to implement search box in odoo12 One2many tree view?
form one2many odoo12
Avatar
Avatar
1
giu 22
3873
sending JSON data with 400 status
controller python3 odoo12
Avatar
0
giu 21
4103
Hide Print Button base on states Odoo 12cc Risolto
form sale odoo12
Avatar
Avatar
Avatar
Avatar
Avatar
6
mag 19
7223
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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