Skip to content

Commit

Permalink
Merge pull request #22 from nbessi/merge_release_73
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nbessi committed Jul 10, 2014
2 parents 28fac7c + e664082 commit a1583c2
Show file tree
Hide file tree
Showing 21 changed files with 500 additions and 824 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Change with 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

Change with release 7.2
L10n_ch_payment_slip pass to version 1.2 and now supports multi payment terms.

Expand Down
5 changes: 3 additions & 2 deletions l10n_ch_credit_control_payment_slip_report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import credit_control_communication
import credit_control_printer
from . import credit_control_communication
from . import credit_control_printer
from . import account
44 changes: 24 additions & 20 deletions l10n_ch_credit_control_payment_slip_report/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name" : "Print BVR credit control",
"description" : """Add possibility to print BVR of
related credit control lines
""",
"version" : "1.0",
"author" : "Camptocamp",
"category" : "Generic Modules/Others",
"website": "http://www.camptocamp.com",
"depends" : [
"account_credit_control",
"l10n_ch_payment_slip"
],
"data" :[
"credit_control_printer_view.xml",
"report.xml"
],
"active": False,
"installable": True
}
{"name": "Printing of dunning BVR",
"summary": "Print BVR/ESR slip related to credit control",
"description": """
Printing of dunning BVR
=======================
Add possibility to print BVR/ESR slip of related credit control lines.
The dunning fees are printed on ESR but they will not affect the amount
of move lines
""",
"version": "1.3.0",
"author": "Camptocamp",
"category": "Generic Modules/Others",
"website": "http://www.camptocamp.com",
"depends": ["account_credit_control",
"account_credit_control_dunning_fees",
"l10n_ch_payment_slip"
],
"data": ["credit_control_printer_view.xml",
"report.xml"
],
"active": False,
"installable": True
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier
# Author: Nicolas Bessi
# Copyright 2014 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
Expand All @@ -18,22 +18,23 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp.osv import orm


class account_invoice(orm.Model):
_inherit = 'account.invoice'
class account_move_line(orm.Model):
"""Overrride BVR amount to take in account dunning fees"""

_inherit = "account.move.line"

def _get_bvr_amount(self, cr, uid, move, rtype=None):
"""Hook to get amount in CHF for BVR
The amount must include dunning fees
:param move: move line report
:param rtype: report type string just in case
def _get_bvr_ref(self, cr, uid, invoice, context=None):
"""Retrieve ESR/BVR reference form invoice in order to print it
:returns: BVR float amount
Returns False when no BVR reference should be generated. No
reference is generated when a transaction ID already exists on
the invoice (likely generated by a payment service so BVR ref not
used).
"""
if invoice.transaction_id:
return ''
return super(account_invoice, self)._get_bvr_ref(cr, uid, invoice,
context=context)
fees = getattr(move, 'bvr_dunning_fees', 0.0)
return move.debit + fees
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,75 @@
#
##############################################################################
import netsvc
from openerp.osv.orm import TransientModel
from l10n_ch_payment_slip.report import webkit_parser
from openerp.report import report_sxw
from openerp.osv import orm
from openerp.tools.translate import _
from l10n_ch_payment_slip.report import multi_report_webkit_html


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

def _generate_report_bvr(self, cr, uid, lines, context=None):
def _generate_report_bvr(self, cr, uid, line_ids, context=None):
"""Will generate a report by inserting mako template
of Multiple BVR Report"""
service = netsvc.LocalService('report.invoice_bvr_webkit_multi_credit_control')
result, format = service.create(cr, uid, lines, {}, {})
result, format = service.create(cr, uid, line_ids, {}, {})
return result


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

def get_obj_reference(self, cursor, uid, ids, context=None):
return ids
def check_currency(self, line, company_curr, swiss_curr):

MultiBvrWebKitParserCreditControl('report.invoice_bvr_webkit_multi_credit_control',
'account.invoice',
'addons/l10n_ch_payment_slip/report/multi_bvr.mako',
parser=multi_report_webkit_html.L10nCHReportWebkitHtmlMulti)
curr = line.currency_id if line.currency_id else company_curr
if curr != swiss_curr:
raise orm.except_orm(
_('ERROR'),
_('BVR only support CHF currency')
)
return True

def get_company_currency(self):
cmp_model = self.pool['res.company']
c_id = cmp_model._company_default_get(self.cr, self.uid, 'res.currency')
comp = cmp_model.browse(self.cr, self.uid, c_id)
return comp.currency_id

def get_swiss_currency(self):
return self.pool['ir.model.data'].get_object(self.cr,
self.uid,
'base', 'CHF')

def set_context(self, objects, data, ids, report_type=None):
new_objects = []
new_ids = []
company_currency = self.get_company_currency()
swiss_currency = self.get_swiss_currency()
for credit_line in objects:
self.check_currency(credit_line, company_currency, swiss_currency)
ml = credit_line.move_line_id
ml.bvr_dunning_fees = credit_line.dunning_fees_amount
new_ids.append(ml.id)
new_objects.append(ml)
self._check(new_ids)
# We do not want to call L10nCHReportWebkitHtmlMulti set_context
return report_sxw.rml_parse.set_context(
self,
new_objects,
new_ids,
ids,
report_type=report_type
)

report_sxw.report_sxw('report.invoice_bvr_webkit_multi_credit_control',
'credit.control.line',
'addons/l10n_ch_payment_slip/report/multi_bvr.mako',
parser=MultiBvrWebKitParserCreditControl)
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
#
##############################################################################
import base64

from openerp.osv import orm
from openerp.osv import orm, fields
from openerp.tools.translate import _


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

def print_linked_bvr(self, cr, uid, wiz_id, context=None):
"""Print BVR from credit line"""
assert not (isinstance(wiz_id, list) and len(wiz_id) > 1), \
"wiz_id: only one id expected"
comm_obj = self.pool.get('credit.control.communication')
Expand All @@ -38,16 +38,13 @@ def print_linked_bvr(self, cr, uid, wiz_id, context=None):
if not form.line_ids and not form.print_all:
raise orm.except_orm(_('Error'),
_('No credit control lines selected.'))

move_line_ids = []
for line in form.line_ids:
if line.move_line_id:
move_line_ids.append(line.move_line_id.id)
credit_ids = [x.id for x in form.line_ids]
report_file = comm_obj._generate_report_bvr(cr, uid,
move_line_ids,
credit_ids,
context=context)

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

return {'type': 'ir.actions.act_window',
Expand Down
2 changes: 1 addition & 1 deletion l10n_ch_credit_control_payment_slip_report/report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<report auto="False"
menu="False"
id="report_bvr_html_multi_credit_control"
model="account.invoice"
model="credit.control.line"
name="invoice_bvr_webkit_multi_credit_control"
file="l10n_ch_payment_slip/report/multi_bvr.mako"
string="BVR/ESR multiple Credit control"
Expand Down
1 change: 0 additions & 1 deletion l10n_ch_payment_slip/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
'data': ["company_view.xml",
"bank_view.xml",
"account_invoice_view.xml",
"report/report_webkit_html_view.xml",
"report/multi_report_webkit_html_view.xml",
"wizard/bvr_import_view.xml",
"data.xml"],
Expand Down
2 changes: 1 addition & 1 deletion l10n_ch_payment_slip/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ResCompany(Model):
'bvr_scan_line_font_size': 11,
'bvr_scan_line_letter_spacing': 2.55,
'bvr_add_vert': 6,
'bvr_add_horz': 60,
'bvr_add_horz': 6,
}

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

0 comments on commit a1583c2

Please sign in to comment.