Skip to content

Commit a1583c2

Browse files
committed
Merge pull request #22 from nbessi/merge_release_73
Release 7.3 - Remove compatibility code for BVR/ESR only Multi BVR/ESR is supported - Add credit control integration with ESR - Add intergation with account bank reconciliation addons https://launchpad.net/banking-addons/bank-statement-reconcile-7.0 with module l10n_ch_payment_slip_base_transaction_id - Uniformize management of reference
2 parents 28fac7c + e664082 commit a1583c2

21 files changed

+500
-824
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Change with release 7.3
2+
*) Remove compatibility code for BVR/ESR only Multi BVR/ESR is supported
3+
*) Add credit control integration with ESR
4+
*) Add intergation with account bank reconciliation addons https://launchpad.net/banking-addons/bank-statement-reconcile-7.0 with module l10n_ch_payment_slip_base_transaction_id
5+
*) Uniformize management of reference
6+
17
Change with release 7.2
28
L10n_ch_payment_slip pass to version 1.2 and now supports multi payment terms.
39

l10n_ch_credit_control_payment_slip_report/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
#
1919
##############################################################################
20-
import credit_control_communication
21-
import credit_control_printer
20+
from . import credit_control_communication
21+
from . import credit_control_printer
22+
from . import account

l10n_ch_credit_control_payment_slip_report/__openerp__.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,27 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
#
1919
##############################################################################
20-
{
21-
"name" : "Print BVR credit control",
22-
"description" : """Add possibility to print BVR of
23-
related credit control lines
24-
""",
25-
"version" : "1.0",
26-
"author" : "Camptocamp",
27-
"category" : "Generic Modules/Others",
28-
"website": "http://www.camptocamp.com",
29-
"depends" : [
30-
"account_credit_control",
31-
"l10n_ch_payment_slip"
32-
],
33-
"data" :[
34-
"credit_control_printer_view.xml",
35-
"report.xml"
36-
],
37-
"active": False,
38-
"installable": True
39-
}
20+
{"name": "Printing of dunning BVR",
21+
"summary": "Print BVR/ESR slip related to credit control",
22+
"description": """
23+
Printing of dunning BVR
24+
=======================
25+
Add possibility to print BVR/ESR slip of related credit control lines.
26+
The dunning fees are printed on ESR but they will not affect the amount
27+
of move lines
28+
29+
""",
30+
"version": "1.3.0",
31+
"author": "Camptocamp",
32+
"category": "Generic Modules/Others",
33+
"website": "http://www.camptocamp.com",
34+
"depends": ["account_credit_control",
35+
"account_credit_control_dunning_fees",
36+
"l10n_ch_payment_slip"
37+
],
38+
"data": ["credit_control_printer_view.xml",
39+
"report.xml"
40+
],
41+
"active": False,
42+
"installable": True
43+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
##############################################################################
33
#
4-
# Author: Guewen Baconnier
4+
# Author: Nicolas Bessi
55
# Copyright 2014 Camptocamp SA
66
#
77
# This program is free software: you can redistribute it and/or modify
@@ -18,22 +18,23 @@
1818
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
#
2020
##############################################################################
21-
2221
from openerp.osv import orm
2322

2423

25-
class account_invoice(orm.Model):
26-
_inherit = 'account.invoice'
24+
class account_move_line(orm.Model):
25+
"""Overrride BVR amount to take in account dunning fees"""
26+
27+
_inherit = "account.move.line"
28+
29+
def _get_bvr_amount(self, cr, uid, move, rtype=None):
30+
"""Hook to get amount in CHF for BVR
31+
The amount must include dunning fees
32+
33+
:param move: move line report
34+
:param rtype: report type string just in case
2735
28-
def _get_bvr_ref(self, cr, uid, invoice, context=None):
29-
"""Retrieve ESR/BVR reference form invoice in order to print it
36+
:returns: BVR float amount
3037
31-
Returns False when no BVR reference should be generated. No
32-
reference is generated when a transaction ID already exists on
33-
the invoice (likely generated by a payment service so BVR ref not
34-
used).
3538
"""
36-
if invoice.transaction_id:
37-
return ''
38-
return super(account_invoice, self)._get_bvr_ref(cr, uid, invoice,
39-
context=context)
39+
fees = getattr(move, 'bvr_dunning_fees', 0.0)
40+
return move.debit + fees

l10n_ch_credit_control_payment_slip_report/credit_control_communication.py

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,75 @@
1818
#
1919
##############################################################################
2020
import netsvc
21-
from openerp.osv.orm import TransientModel
22-
from l10n_ch_payment_slip.report import webkit_parser
21+
from openerp.report import report_sxw
22+
from openerp.osv import orm
23+
from openerp.tools.translate import _
2324
from l10n_ch_payment_slip.report import multi_report_webkit_html
2425

2526

26-
class CreditCommunication(TransientModel):
27+
class CreditCommunication(orm.TransientModel):
2728
"""Shell class used to provide a base model to email template
2829
and reporting.
2930
Il use this approche in version 7 a browse record will
3031
exist even if not saved"""
3132
_inherit = "credit.control.communication"
3233

33-
def _generate_report_bvr(self, cr, uid, lines, context=None):
34+
def _generate_report_bvr(self, cr, uid, line_ids, context=None):
3435
"""Will generate a report by inserting mako template
3536
of Multiple BVR Report"""
3637
service = netsvc.LocalService('report.invoice_bvr_webkit_multi_credit_control')
37-
result, format = service.create(cr, uid, lines, {}, {})
38+
result, format = service.create(cr, uid, line_ids, {}, {})
3839
return result
3940

4041

41-
class MultiBvrWebKitParserCreditControl(webkit_parser.MultiBvrWebKitParser):
42+
class MultiBvrWebKitParserCreditControl(multi_report_webkit_html.L10nCHReportWebkitHtmlMulti):
4243
"""We define a new parser because this report take move line
4344
In parameter insted of an invoice, so the function get_obj_reference
4445
return directly ids"""
4546

46-
def get_obj_reference(self, cursor, uid, ids, context=None):
47-
return ids
47+
def check_currency(self, line, company_curr, swiss_curr):
4848

49-
MultiBvrWebKitParserCreditControl('report.invoice_bvr_webkit_multi_credit_control',
50-
'account.invoice',
51-
'addons/l10n_ch_payment_slip/report/multi_bvr.mako',
52-
parser=multi_report_webkit_html.L10nCHReportWebkitHtmlMulti)
49+
curr = line.currency_id if line.currency_id else company_curr
50+
if curr != swiss_curr:
51+
raise orm.except_orm(
52+
_('ERROR'),
53+
_('BVR only support CHF currency')
54+
)
55+
return True
56+
57+
def get_company_currency(self):
58+
cmp_model = self.pool['res.company']
59+
c_id = cmp_model._company_default_get(self.cr, self.uid, 'res.currency')
60+
comp = cmp_model.browse(self.cr, self.uid, c_id)
61+
return comp.currency_id
62+
63+
def get_swiss_currency(self):
64+
return self.pool['ir.model.data'].get_object(self.cr,
65+
self.uid,
66+
'base', 'CHF')
67+
68+
def set_context(self, objects, data, ids, report_type=None):
69+
new_objects = []
70+
new_ids = []
71+
company_currency = self.get_company_currency()
72+
swiss_currency = self.get_swiss_currency()
73+
for credit_line in objects:
74+
self.check_currency(credit_line, company_currency, swiss_currency)
75+
ml = credit_line.move_line_id
76+
ml.bvr_dunning_fees = credit_line.dunning_fees_amount
77+
new_ids.append(ml.id)
78+
new_objects.append(ml)
79+
self._check(new_ids)
80+
# We do not want to call L10nCHReportWebkitHtmlMulti set_context
81+
return report_sxw.rml_parse.set_context(
82+
self,
83+
new_objects,
84+
new_ids,
85+
ids,
86+
report_type=report_type
87+
)
88+
89+
report_sxw.report_sxw('report.invoice_bvr_webkit_multi_credit_control',
90+
'credit.control.line',
91+
'addons/l10n_ch_payment_slip/report/multi_bvr.mako',
92+
parser=MultiBvrWebKitParserCreditControl)

l10n_ch_credit_control_payment_slip_report/credit_control_printer.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
#
1919
##############################################################################
2020
import base64
21-
22-
from openerp.osv import orm
21+
from openerp.osv import orm, fields
2322
from openerp.tools.translate import _
2423

2524

@@ -28,6 +27,7 @@ class CreditControlPrinter(orm.TransientModel):
2827
_inherit = 'credit.control.printer'
2928

3029
def print_linked_bvr(self, cr, uid, wiz_id, context=None):
30+
"""Print BVR from credit line"""
3131
assert not (isinstance(wiz_id, list) and len(wiz_id) > 1), \
3232
"wiz_id: only one id expected"
3333
comm_obj = self.pool.get('credit.control.communication')
@@ -38,16 +38,13 @@ def print_linked_bvr(self, cr, uid, wiz_id, context=None):
3838
if not form.line_ids and not form.print_all:
3939
raise orm.except_orm(_('Error'),
4040
_('No credit control lines selected.'))
41-
42-
move_line_ids = []
43-
for line in form.line_ids:
44-
if line.move_line_id:
45-
move_line_ids.append(line.move_line_id.id)
41+
credit_ids = [x.id for x in form.line_ids]
4642
report_file = comm_obj._generate_report_bvr(cr, uid,
47-
move_line_ids,
43+
credit_ids,
4844
context=context)
4945

5046
form.write({'report_file': base64.b64encode(report_file),
47+
'report_name': 'credit_control_esr_bvr_%s.pdf' % fields.datetime.now(),
5148
'state': 'done'})
5249

5350
return {'type': 'ir.actions.act_window',

l10n_ch_credit_control_payment_slip_report/report.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<report auto="False"
55
menu="False"
66
id="report_bvr_html_multi_credit_control"
7-
model="account.invoice"
7+
model="credit.control.line"
88
name="invoice_bvr_webkit_multi_credit_control"
99
file="l10n_ch_payment_slip/report/multi_bvr.mako"
1010
string="BVR/ESR multiple Credit control"

l10n_ch_payment_slip/__openerp__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
'data': ["company_view.xml",
5050
"bank_view.xml",
5151
"account_invoice_view.xml",
52-
"report/report_webkit_html_view.xml",
5352
"report/multi_report_webkit_html_view.xml",
5453
"wizard/bvr_import_view.xml",
5554
"data.xml"],

l10n_ch_payment_slip/company.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ResCompany(Model):
6060
'bvr_scan_line_font_size': 11,
6161
'bvr_scan_line_letter_spacing': 2.55,
6262
'bvr_add_vert': 6,
63-
'bvr_add_horz': 60,
63+
'bvr_add_horz': 6,
6464
}
6565

6666
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

0 commit comments

Comments
 (0)