Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to add country, state and file attachment in my website form in odoo13, not by drag & drop?

Odoberať

Get notified when there's activity on this post

This question has been flagged
Odoo13.0Odoo13odoo13odoo13CE
3 Replies
6018 Zobrazenia
Avatar
Aishwarya

This is how my form looks

<? xml version = "1.0" encoding = "UTF-8"?>

<odoo>

    <template id = "tmp_customer_form" name = "Partner Form">

        <t t-call = "website.layout">

            <div id = "wrap" class = "alumni">

                <div class = "container">

                    <div class = "col-md-12">

                        <form action = "/ customer / form / submit">

                            <table border = "0" width = "100%" class = "table-sign">

                        <tbody>

                            <tr>

                                <th colspan = "3" style = "color: #ffffff;"> Identify Yourself </th>

                            </tr>

                            <tr>

                                <td width = "21%">

                                    <label for = "name"> Alumni Name (Full) </label>

                                </ Td>

                                <td width = "2%" align = "center">

                                    <B>: </ b>

                                </ td>

                                <td width = "77%">

                                    <input type = "text" name = "name" id = "name" size = "40" required = "" />

                                </ td>

                            </ tr>

                            <tr>

                                <td width = "21%">

                                    <label for = "date"> Date Of Birth [DD / MM / YY] </label>

                                </ td>

                                <td width = "2%" align = "center" valign = "top">

                                    <B>: </ b>

                                </ Td>

                                <td width = "77%" valign = "top">

                                    <input type = "date" name = "date" size = "10" maxlength = "10" required = "" />

                                </ td>

                            </ Tr>

                           

<Tr>

                                <td width = "21%"> </td>

                                <td width = "2%" align = "center">

                                    <B>: </ b>

                                </ Td>

                                <td width = "77%">

                                    <input type = "text" name = "my_teachers1" id = "my_teachers1" size = "20" />

                                </ td>

                            </ tr>

                            <tr>

                                <th colspan = "3" style = "color: #ffffff;"> Contact Details </th>

                            </tr>

                            <tr>

                                <td width = "21%">

                                    <label for = "city"> City </label>

                                </td>

                                <td width = "2%" align = "center">

                                    <b>: </ b>

                                </ td>

                                <td width = "77%">

                                    <input type = "text" name = "city" id = "city" size = "30" required = "" />

                                </ td>

                            </tr>

                            <tr>

                                <td width = "21%">

                                    <label for = "state_id"> State </label>

                                </td>

                                <td width = "2%" align = "center">

                                    <b>: </ b>

                                </ td>

                                <td width = "77%">

                                    <input type = "text" name = "state_id" id = "state_id" size = "30" required = "" />

                                </td>

                            </tr>

                            <tr>

                                <td width = "21%">

                                    <label for = "country_id"> Country </label>

                                </td>

                                <td width = "2%" align = "center">

                                    <b>: </ b>

                                </td>

                                <td width = "77%">

                                    <input type = "text" name = "country_id" id = "country_id" size = "30" required = "" />

                                </td>

                            </tr>

                            <tr>

                                <td width = "21%">

                                    <label for = "phone"> Mobile No. </label>

                                </td>

                                <td width = "2%" align = "center">

                                    <b>: </ b>

                                </td>

                                <td width = "77%">

                                    <input type = "text" name = "phone" id = "phone" />

                                </td>

                            </tr>

                            <tr>

                                <td width = "21%">

                                    <label for = "email"> Email </label>

                                </td>

                                <td width = "2%" align = "center">

                                    <b>: </ b>

                                </td>

                                <td width = "77%">

                                    <input type = "email" name = "email" id = "email" size = "30" />

                                </td>

                               <td width = "2%" align = "center">

                                    <b>: </ b>

                                </td>

                                <td width = "77%">

                                    <textarea name = "about" id = "about" rows = "5" cols = "50"> </textarea>

                                </td>

                            </tr>

                            <tr>

                                <td width = "21%">

                                    <label for = "image_1920"> Upload Photo </label>

                                </td>

                                <td width = "2%" align = "center">

                                    <b>: </ b>

                                </td>

                                <td width = "77%">

                                    <input type = "file" name = "image_1920" id = "image_1920" />

                                </td>

                            </tr>

                            <tr>

                                <td width = "21%"> </td>

                                <td width = "2%" align = "center">

                                    <b> </ b>

                                </td>

                                <td width = "77%">

                                    <input type = "submit" value = "Submit"> </input>

                                </dd>

                            </tr>

                        </tbody>

                    </table>

                 </ form>

                </div>

              </div>

          </t>

    </template>


    <template id = "tmp_customer_form_success" name = "Customer Form Successfully Submitted">

        <t t-call = "website.layout">

            <div id = "wrap">

                <div class = "container">

                    <div class = "col-md-12">

                        <div class = "alert alert-success">

                            <p> Thank You! </ P>

                            <p> Your form has registered successfully </p>

                        </div>

                    </ div>

                </div>

            </ div>

        </ t>

    </ template>

</ odoo>

Here is my controller.py

from odoo import http

from odoo.http import request

class AlumniForm (http.Controller):

    #mention class name

    @ http.route (['/ customer / form'], type = 'http', auth = "public", website = True)

    #mention a url for redirection.

    #define the type of controller which in this case is 'http'.

    #mention the authentication to be either public or user.

    def alumni_form (self, ** post):

    #create method

    #this will load the form webpage

        return request.render ("sample.tmp_customer_form", {})

    @ http.route (['/ customer / form / submit'], type = 'http', auth = "public", website = True)

    #next controller with url for submitting data from the form #

    def alumni_form_submit (self, ** post):

        partner = request.env ['res.partner']. create ({

            'name': post.get ('name'),

            'date': post.get ('date'),

            'city': post.get ('city'),

            'state_id': post.get ('state_id'),

            'country_id': post.get ('country_id'),

            'phone': post.get ('phone'),

            'email': post.get ('email'),

            'image_1920': post.get ('image_1920'),

        })

        vals = {

            'partner': partner,

        }

        #inherited the model to pass the values ​​to the model from the form #

        return request.render ("sample.tmp_customer_form_success", vals)

Now, the coutry, state & the attachment file are not linking to the backend, what should I do?

0
Avatar
Zrušiť
Sehrish

File Attachment or Upload: http://learnopenerp.blogspot.com/2019/01/add-attachement-file-from-odoo-website.html

Aishwarya
Autor

Have you worked in that? It's not working for me

Avatar
Mustufa Rangwala
Best Answer

Hello,

You can try:

=======

<div t-attf-class="col-lg-6 o_website_form_custom_attchments">

                                            <label class="control-label" for="Attachments" >Attach Files</label>

                                            <input type="file" class="form-control o_website_form_input" name="attachment" multiple='multiple'/>

                                            <div>

                                                <label style="color:grey; font-size:12px;" >Multiple files Attachments</label>

                                            </div>

                                        </div>

=======

in controller you can write:

attachment_list = request.httprequest.files.getlist('attachment')

            for image in attachment_list:

                if post.get('attachment'):

                    attachments = {

                               'res_name': image.filename,

                               'res_model': 'machine.repair.support',

                               'res_id': support,

                               'datas': base64.encodestring(image.read()),

                               'type': 'binary',

                               # 'datas_fname': image.filename, odoo13

                               'name': image.filename,

                           }

                    attachment_obj = http.request.env['ir.attachment']

                    attach = attachment_obj.sudo().create(attachments)

====

Regards,

Mustufa Rangwala (Probuse)


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

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
How to put domain filter on One2Many Field on a from Solved
Odoo13.0 Odoo13 odoo13 odoo13CE
Avatar
1
nov 21
4557
Having trouble installing the website module in a fresh DB
Odoo13.0 odoo13.0 Odoo13 odoo13 odoo13CE
Avatar
0
nov 21
3242
Database problem
Odoo13.0 odoo13.0 Odoo13 odoo13 odoo13CE
Avatar
Avatar
Avatar
Avatar
8
mar 20
10370
Error with search content in elearning platform of Odoo 13
Odoo13.0 odoo13.0 Odoo13 odoo13 odoo13CE
Avatar
0
okt 19
3854
Error with newsletter block of website builder in ODOO 13
Odoo13.0 odoo13.0 Odoo13 odoo13 odoo13CE
Avatar
0
okt 19
4567
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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