Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

customize file name for RML reports

Odebírat

Get notified when there's activity on this post

This question has been flagged
1 Odpovědět
5278 Zobrazení
Avatar
ASP

Hello Guys,

I've designed reports for my custom modules using openoffice and RML. But while printing/generating the PDF file of the report, it's opening or saving as the report name.pdf,as listed in settings>actions>reports.

My objective is to add some id or number to the file name of the corresponding report, Ex: "My Report - 123.pdf", "My Report - 234.pdf" etc.

To achieve the above, i've tried 2 approaches as mentioned below : 1. Edit report from front end and add python code to Add attachment box and select the Reload from Attachment checkbox.

  1. Added attributes like attachment, use_attachment, multi etc. under report tag in the module_view.xml file.

But no luck. Still the report PDF is opening/saving with the old name. Pls help me with this.

Any help would be appreciated. :)

Cheers

ASP :)

0
Avatar
Zrušit
Avatar
Evelb Tecnicas Y Sistemas Sl.
Nejlepší odpověď

Hi. I had the same problem. The only solution for me was to modify the OPENERP Kernel with a patch. Then you can control the name from you xml report configuration. Example:

<report
    id="sale_order_cyls_label_report"
    model="sale.order"        
    name="sale_order_cyls_label_report"
    file="OpenJobs/report/sale_order_cyls_label_report.rml"
    string="Cylinders Labels 2x2" 
    auto="True" 
    report_type="pdf"
    attachment="('CYL'+(object.job_id.job or ''))"
        usage="default"
        keyword="client_print_multi"
        menu="True"
        header="False"
    />

Then the file name was made from the attribute 'attachment' ex. 'CYL10024.pdf'. To patch, change the file 'openerp7/openerp-web/addons/web/controllers/main.py'. Search and find at the end of file the statement:

    file_name = '%s.%s' % (file_name, report_struct['format'])

Then insert next code just before:

 #Start code added
 ''' Code added by Raul Paz to set the default file_name like the attach_name
    The attach_name mach with the attachment expresion from your report_xml
    <report
        id="report_webkit.YourModule_report_id"
        model="YourModule.model"        
        name="Your_report_name"
        file="YOUR_MODULE/report/YOUR_MAKO_FILE.mako"
        string="Your Text in the print button" 
        auto="False" 
        report_type="webkit"
        attachment="'Valid_filename_expresion"
        usage="default"
/>
'''
try:
    if action['attachment']:
        model = context['active_model']
        cr = openerp.pooler.get_db(req.session._db).cursor()
        uid = context['uid']
        ids = context['active_ids']
        objects=openerp.pooler.get_pool(req.session._db).get(model).browse(cr,uid,ids,context=context)
        file_name=[eval(action['attachment'],{'object':x, 'time':time}) for x in objects][0]
        ''' Next code force to remake the report file on each request. 
            Remove if your want to send always the first report file.
            If attachment_use is set to false the report files are always generated and stored
        '''
        if action['attachment_use']:
            aids = openerp.pooler.get_pool(req.session._db).get('ir.attachment').search(cr, uid, [('datas_fname','=',file_name+'.pdf'),('res_model','=',model),('res_id','in',ids)])
            atts = openerp.pooler.get_pool(req.session._db).get('ir.attachment')
            res = atts.unlink(cr, uid, aids, context) 
            cr.commit()
            openerp.osv.orm.except_orm('Attach doc deleted',file_name)
except:
    openerp.osv.orm.except_orm('Attach doc not deleted',file_name)
finally:
    cr.close()
#end code added

This work for all report styles...

0
Avatar
Zrušit
ASP
Autor

Hi Raul,

Good to see your response. The issue has already been fixed at my end.

Please check this : http://help.openerp.com/question/42119/customize-file-name-for-rml-reports/

Cheers

ASP :)

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

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

Přihlásit se
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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