Friday 18 September 2015

Invoice number into the pdf file name in odoo | OpenERP

You can give 'name': 'Invoice ' + 'today date' in return from wizard to print report.

for example: this is function is call from print button in wizard.
def print_report(self,cr, uid, ids, context=None):
        if context is None:
           context = {}
        data = self.read(cr, uid, ids)[0]
        self_browse = self.browse(cr, uid, ids)
     
        datas = {
            'ids': [data.get('id')],
            'model': 'sale.order',
            'form': data
            }
        return {
            'type': 'ir.actions.report.xml',
            'report_name': 'custom.invvoice.report',
            'datas': datas,
            'name': 'Invoice ' + self_browse[0].start_date + ' To ' + self_browse[0].end_date
            }

3 comments:

  1. give me xml file . i can't this datas view in xml

    ReplyDelete
  2. What should I do if I want to name the outgoing pdf? For example Quotation_SO230.pdf

    ReplyDelete
  3. Hello,
    If you dont want to code like this then, you can also install this module find below.
    https://www.odoo.com/apps/modules/8.0/report_custom_filename/

    this module helps you to change the name of report .
    Thanks

    ReplyDelete