~account-core-editors/account-invoice-report/github-7.0

« back to all changes in this revision

Viewing changes to invoice_report_assemble/report_assembler.py

  • Committer: Guewen Baconnier
  • Author(s): Yannick Vaucher
  • Date: 2014-02-28 13:25:12 UTC
  • mfrom: (42.1.4)
  • Revision ID: git-v1:9ae9308cf51925d143ea7592c30ea015cb0e4084
[ADD] module invoice_report_assemble

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Author: Yannick Vaucher
 
5
#    Copyright 2013 Camptocamp SA
 
6
#
 
7
#    This program is free software: you can redistribute it and/or modify
 
8
#    it under the terms of the GNU Affero General Public License as
 
9
#    published by the Free Software Foundation, either version 3 of the
 
10
#    License, or (at your option) any later version.
 
11
#
 
12
#    This program is distributed in the hope that it will be useful,
 
13
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#    GNU Affero General Public License for more details.
 
16
#
 
17
#    You should have received a copy of the GNU Affero General Public License
 
18
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
#
 
20
##############################################################################
 
21
 
 
22
from openerp import pooler
 
23
from openerp.osv import orm
 
24
from openerp.tools.translate import _
 
25
from openerp.addons.base_report_assembler import report_assembler
 
26
 
 
27
 
 
28
class InvoicePDFReportAssembler(report_assembler.PDFReportAssembler):
 
29
    """InvoicePDFReportAssembler allows to merge multiple
 
30
    invoice reports into one pdf"""
 
31
 
 
32
    def _get_report_ids(self, cr, uid, ids, context=None):
 
33
        pool = pooler.get_pool(cr.dbname)
 
34
        user_obj = pool.get('res.users')
 
35
        company = user_obj.browse(cr, uid, uid, context=context).company_id
 
36
        report_ids = [r.report_id.id for r in company.assemble_invoice_report_ids]
 
37
        if not report_ids:
 
38
            msg = _("No report defined in Configuration -> Accounting for model invoice.")
 
39
            raise orm.except_orm(_('Error'), msg)
 
40
        return report_ids
 
41
 
 
42
InvoicePDFReportAssembler('report.invoice_report_assemblage',
 
43
                          'account.invoice',
 
44
                          None)