Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Form using Controller dont work

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
formir_attachmentcontrollerpostodoo12
4255 Visninger
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
Kassér
Oeil d'Horis

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

Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
How to take records from wizards to form in odoo?
wizard form odoo12
Avatar
Avatar
2
sep. 23
5535
How to change default form view in stock.picking model
form form_view odoo12
Avatar
Avatar
Avatar
2
sep. 22
6121
How to implement search box in odoo12 One2many tree view?
form one2many odoo12
Avatar
Avatar
1
jun. 22
3875
sending JSON data with 400 status
controller python3 odoo12
Avatar
0
jun. 21
4103
Hide Print Button base on states Odoo 12cc Løst
form sale odoo12
Avatar
Avatar
Avatar
Avatar
Avatar
6
maj 19
7226
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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