~camptocamp/openerp-swiss-localization/7.0-pending-merge

« back to all changes in this revision

Viewing changes to l10n_ch_payment_slip/report/webkit_parser.py

  • Committer: nicolas.bessi at camptocamp
  • Author(s): romain.deheele at camptocamp
  • Date: 2013-09-23 07:15:24 UTC
  • mfrom: (177.1.11 multi-payment-bvr)
  • Revision ID: nicolas.bessi@camptocamp.com-20130923071524-sv1b3qa46ocug3dr
[MRG]release 7.2 adds support of multi payments term BVR.
Adds a new report that will allows to print BVR from invoice using account.move.line So if there is many payment terms many BVR will be print per invoice.
The previous report is kept but deprecated.
A new field is addes on account.move.line transaction_ref.
Changes to manage bvr_reference and transaction_ref depending on payment terms are automatic

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Author: Romain Deheele. Copyright Camptocamp SA
 
5
#
 
6
#    This program is free software: you can redistribute it and/or modify
 
7
#    it under the terms of the GNU Affero General Public License as
 
8
#    published by the Free Software Foundation, either version 3 of the
 
9
#    License, or (at your option) any later version.
 
10
#
 
11
#    This program is distributed in the hope that it will be useful,
 
12
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
#    GNU Affero General Public License for more details.
 
15
#
 
16
#    You should have received a copy of the GNU Affero General Public License
 
17
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
#
 
19
##############################################################################
 
20
 
 
21
from openerp import pooler
 
22
from openerp.addons.report_webkit import webkit_report
 
23
 
 
24
class MultiBvrWebKitParser(webkit_report.WebKitParser):
 
25
 
 
26
    def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None):
 
27
        self.pool = pooler.get_pool(cursor.dbname)
 
28
        target_obj = 'account.move.line'
 
29
        move_line_obj = self.pool.get(target_obj)
 
30
        account_obj = self.pool.get('account.account')
 
31
        invoice_obj = self.pool.get('account.invoice')
 
32
        inv = invoice_obj.browse(cursor, uid, ids[0],context)
 
33
        tier_account_id = account_obj.search(cursor, uid, [('type', 'in', ['receivable', 'payable'])])
 
34
        move_lines = move_line_obj.search(cursor, uid, [('move_id', '=', inv.move_id.id), ('account_id', 'in', tier_account_id)])
 
35
        context['active_model'] = self.table = target_obj
 
36
        context['active_ids'] = ids = move_lines
 
37
        return super(MultiBvrWebKitParser, self).create_single_pdf(cursor, uid, ids, data, report_xml, context)
 
 
b'\\ No newline at end of file'