Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Sociale media-marketing
    • E-mailmarketing
    • Sms-marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

how to fix issue in attachments file when i pass the file it will .bin file (odoo14 )

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
attach
1 Beantwoorden
2184 Weergaven
Avatar
M. Faizan

There is an issue with attachments not being correctly uploaded in the leave portal. The file moves to the bin, whether I convert it or not, and the result remains the same. code is 


@http.route('/request', type='json', auth='user', methods=['POST'], website=True, csrf=False)


    def submit(self, leave_reason, leave_type_select_name, date_from, date_to, duration, half_day, description, request_unit_half_name, exit_entry_check, attachment_id):


        leave_type_id = request.env['hr.leave.type'].sudo().search([('name', '=', leave_type_select_name),('state','=','Approved')])


        leave_type = employee.id,


                'holiday_status_id': leave_type,


                'date_from': date_from,


                'date_to': date_to,


                'number_of_days': duration,


                'request_unit_half': half_day,


                'request_date_from_period': request_unit_half_name,


                'name': description,


                'request_reason': leave_reason,


                'exit_re_entry': exit_entry,


                'attachment_ids': attach,


                'create_air_ticket_request': 'no'


            }


            leaves += request.env['hr.leave'].sudo().create(create_leave)




0
Avatar
Annuleer
Avatar
emizentech
Beste antwoord

Correct Attachment Handling:

  • Ensure the attachment_id parameter is processed correctly and linked to the leave request.

Upload the Attachment to ir.attachment:

  • Use the ir.attachment model to store the uploaded file and link it to the leave request.

from odoo import http
from odoo.http import request

class LeavePortal(http.Controller):

    @http.route('/request', type='json', auth='user', methods=['POST'], website=True, csrf=False)
    def submit(self, leave_reason, leave_type_select_name, date_from, date_to, duration, half_day, description, request_unit_half_name, exit_entry_check, attachment_id=None):
        try:
            employee = request.env.user.employee_id
            if not employee:
                return {'error': 'Employee record not found for the current user.'}

            # Search for leave type
            leave_type = request.env['hr.leave.type'].sudo().search([
                ('name', '=', leave_type_select_name),
                ('state', '=', 'Approved')
            ], limit=1)

            if not leave_type:
                return {'error': 'Leave type not found or not approved.'}

            # Handle attachment if provided
            attach_ids = []
            if attachment_id:
                attachment = request.env['ir.attachment'].sudo().create({
                    'name': attachment_id.filename,
                    'datas': attachment_id.read(),
                    'res_model': 'hr.leave',
                    'res_id': 0,  # Temporary res_id, will be updated later
                })
                attach_ids.append(attachment.id)

            # Create leave request
            leave_data = {
                'employee_id': employee.id,
                'holiday_status_id': leave_type.id,
                'date_from': date_from,
                'date_to': date_to,
                'number_of_days': duration,
                'request_unit_half': half_day,
                'request_date_from_period': request_unit_half_name,
                'name': description,
                'request_reason': leave_reason,
                'exit_re_entry': exit_entry_check,
                'attachment_ids': [(6, 0, attach_ids)],  # Link attachments
                'create_air_ticket_request': 'no',
            }
            leave_request = request.env['hr.leave'].sudo().create(leave_data)

            # Update attachment `res_id` to link it properly
            if attach_ids:
                request.env['ir.attachment'].sudo().browse(attach_ids).write({'res_id': leave_request.id})

            return {'success': True, 'message': 'Leave request submitted successfully.'}
       
        except Exception as e:
            return {'error': str(e)}

0
Avatar
Annuleer
M. Faizan
Auteur

When I attach file in any format on portal then it pass in to bin format but need it in exact format , when I debug then it show file in string

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
{(+56)Call center chile} ¿Cómo hablar con una persona en LATAM Airlines Chile?
attach
Avatar
0
nov. 25
7
{(!@Guia) ¿Cómo hablar con una persona en LATAM Airlines Chile?
attach
Avatar
0
nov. 25
5
[{$Guia#$}]((@United%Airlines%en% español))¿Cómo poner en español United?
attach
Avatar
0
nov. 25
3
𝓛𝓲𝓰𝓪𝓻 ⒷⓇ }Como falar com British Airways pelo exterior?
attach
Avatar
0
nov. 25
4
Set up the Project Customer Ratings Emails in V19
attach
Avatar
Avatar
1
nov. 25
359
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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