From 074619e274335723fe6a57cd11c383da00ac5b18 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 15 Apr 2014 13:28:13 +0200 Subject: [PATCH 01/19] [REFACTOR] l10n_ch_payment_slip_report * Removing deprecated BVR report from invoice * PEP8 * Replacing deprecated except_osv by except_orm * _space become a static method * DRY some code --- .../__openerp__.py | 43 +-- l10n_ch_payment_slip/company.py | 2 +- l10n_ch_payment_slip/invoice.py | 100 +++--- l10n_ch_payment_slip/report/__init__.py | 2 - l10n_ch_payment_slip/report/bvr.mako | 304 ------------------ l10n_ch_payment_slip/report/multi_bvr.mako | 3 +- .../report/multi_report_webkit_html.py | 133 +++++++- .../report/multi_report_webkit_html_view.xml | 112 ++++++- .../report/report_webkit_html.py | 141 -------- .../report/report_webkit_html_view.xml | 114 ------- l10n_ch_payment_slip/wizard/bvr_import.py | 127 +++++--- .../__init__.py | 2 - .../invoice.py | 39 --- 13 files changed, 371 insertions(+), 751 deletions(-) delete mode 100644 l10n_ch_payment_slip/report/bvr.mako delete mode 100644 l10n_ch_payment_slip/report/report_webkit_html.py delete mode 100644 l10n_ch_payment_slip_base_transaction_id/invoice.py diff --git a/l10n_ch_credit_control_payment_slip_report/__openerp__.py b/l10n_ch_credit_control_payment_slip_report/__openerp__.py index ffb5029f7..f2c158712 100644 --- a/l10n_ch_credit_control_payment_slip_report/__openerp__.py +++ b/l10n_ch_credit_control_payment_slip_report/__openerp__.py @@ -17,23 +17,26 @@ # along with this program. If not, see . # ############################################################################## -{ - "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": "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 this not affect the amount +of move lines + +""", + "version": "1.1.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 + } diff --git a/l10n_ch_payment_slip/company.py b/l10n_ch_payment_slip/company.py index ab3cbc6f5..5c5ea9bde 100644 --- a/l10n_ch_payment_slip/company.py +++ b/l10n_ch_payment_slip/company.py @@ -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: diff --git a/l10n_ch_payment_slip/invoice.py b/l10n_ch_payment_slip/invoice.py index c8a71a0c0..11b2e1a23 100644 --- a/l10n_ch_payment_slip/invoice.py +++ b/l10n_ch_payment_slip/invoice.py @@ -44,16 +44,18 @@ def get_bvr_ref(self, cursor, uid, move_line_id, context=None): if isinstance(move_line_id, (tuple, list)): assert len(move_line_id) == 1, "Only 1 ID expected" move_line_id = move_line_id[0] + move_line = self.browse(cursor, uid, move_line_id, context=context) - ## We check if the type is bvr, if not we return false + # We check if the type is bvr, if not we return false if move_line.invoice.partner_bank_id.state != 'bvr': return '' - ## if move_line.invoice.partner_bank_id.bvr_adherent_num: res = move_line.invoice.partner_bank_id.bvr_adherent_num move_number = '' + if move_line.invoice.number: - move_number = self._compile_get_ref.sub('', str(move_line.invoice.number) + str(move_line_id)) + compound = str(move_line.invoice.number) + str(move_line_id) + move_number = self._compile_get_ref.sub('', compound) reference = mod10r(res + move_number.rjust(26 - len(res), '0')) if (move_line.transaction_ref and move_line.transaction_ref != reference): @@ -71,8 +73,9 @@ class AccountInvoice(Model): _compile_get_ref = re.compile('[^0-9]') def _get_reference_type(self, cursor, user, context=None): - """Function use by the function field reference_type in order to initalise available - BVR Reference Types""" + """Function use by the function field reference_type + in order to initalise availabl BVR Reference Types + """ res = super(AccountInvoice, self)._get_reference_type(cursor, user, context=context) res.append(('bvr', 'BVR')) @@ -82,71 +85,51 @@ def _compute_full_bvr_name(self, cursor, uid, ids, field_names, arg, context=Non res = {} move_line_obj = self.pool.get('account.move.line') account_obj = self.pool.get('account.account') - tier_account_id = account_obj.search(cursor, uid, [('type', 'in', ['receivable', 'payable'])]) + tier_account_id = account_obj.search(cursor, uid, + [('type', 'in', ['receivable', 'payable'])]) for inv in self.browse(cursor, uid, ids, context=context): - move_lines = move_line_obj.search(cursor, uid, [('move_id', '=', inv.move_id.id), - ('account_id', 'in', tier_account_id)]) + move_lines = move_line_obj.search(cursor, uid, + [('move_id', '=', inv.move_id.id), + ('account_id', 'in', tier_account_id)]) if move_lines: - if len(move_lines) == 1: - res[inv.id] = self._space(inv.get_bvr_ref()) - else: - refs = [] - for move_line in move_line_obj.browse(cursor, uid, move_lines, context=context): - refs.append(self._space(move_line.get_bvr_ref())) - res[inv.id] = ' ; '.join(refs) + refs = [] + for move_line in move_line_obj.browse(cursor, uid, move_lines, context=context): + refs.append(AccountInvoice._space(move_line.get_bvr_ref())) + res[inv.id] = ' ; '.join(refs) return res _columns = { ### BVR reference type BVR or FREE 'reference_type': fields.selection(_get_reference_type, - 'Reference Type', required=True), + 'Reference Type', + required=True), + ### Partner bank link between bank and partner id - 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account', - help='The partner bank account to pay\nKeep empty to use the default'), - 'bvr_reference': fields.function(_compute_full_bvr_name, type="char", size=512, string="BVR REF.", - store=True, readonly=True) + 'partner_bank_id': fields.many2one('res.partner.bank', + 'Bank Account', + help='The partner bank account to pay\n' + 'Keep empty to use the default'), + + 'bvr_reference': fields.function(_compute_full_bvr_name, + type="char", + size=512, + string="BVR REF.", + store=True, + readonly=True) } - def _get_bvr_ref(self, cr, uid, invoice, context=None): - """Retrieve ESR/BVR reference form invoice in order to print it - - Receive a browse record so it can be overloaded without rebrowsing - the invoice. - """ - res = '' - ## We check if the type is bvr, if not we return false - if invoice.partner_bank_id.state != 'bvr': - return '' - ## - if invoice.partner_bank_id.bvr_adherent_num: - res = invoice.partner_bank_id.bvr_adherent_num - invoice_number = '' - if invoice.number: - invoice_number = self._compile_get_ref.sub('', invoice.number) - return mod10r(res + invoice_number.rjust(26 - len(res), '0')) - - def get_bvr_ref(self, cursor, uid, inv_id, context=None): - """Retrieve ESR/BVR reference form invoice in order to print it - - Returns False when no BVR reference should be generated. No - reference is generated when the invoice is not a BVR invoice. - """ - if isinstance(inv_id, (list, tuple)): - assert len(inv_id) == 1, "1 ID expected, got %s" % inv_id - inv_id = inv_id[0] - inv = self.browse(cursor, uid, inv_id, context=context) - return self._get_bvr_ref(cursor, uid, inv, context=context) - - def _space(self, nbr, nbrspc=5): + @staticmethod + def _space(nbr, nbrspc=5): """Spaces * 5. Example: - self._space('123456789012345') + AccountInvoice._space('123456789012345') '12 34567 89012 345' """ return ''.join([' '[(i - 2) % nbrspc:] + c for i, c in enumerate(nbr)]) def _update_ref_on_account_analytic_line(self, cr, uid, ref, move_id, context=None): + """Propagate reference on analytic line""" cr.execute('UPDATE account_analytic_line SET ref=%s' ' FROM account_move_line ' ' WHERE account_move_line.move_id = %s ' @@ -156,6 +139,7 @@ def _update_ref_on_account_analytic_line(self, cr, uid, ref, move_id, context=No def _action_bvr_number_move_line(self, cr, uid, invoice, move_line, ref, context=None): + """Propagate reference on move lines and analytic lines""" if not ref: return cr.execute('UPDATE account_move_line SET transaction_ref=%s' @@ -181,20 +165,15 @@ def action_number(self, cr, uid, ids, context=None): cr, uid, [('move_id', '=', inv.move_id.id), ('account_id', '=', inv.account_id.id)], - context=context) + context=context + ) if not move_line_ids: continue move_lines = move_line_obj.browse(cr, uid, move_line_ids, context=context) for move_line in move_lines: if inv.type in ('out_invoice', 'out_refund'): - if len(move_lines) == 1: - # We keep this branch for compatibility with single - # BVR report. - # This should be cleaned when porting to V8 - ref = inv.get_bvr_ref() - else: - ref = move_line.get_bvr_ref() + ref = move_line.get_bvr_ref() elif inv.reference_type == 'bvr' and inv.reference: ref = inv.reference else: @@ -218,4 +197,3 @@ class AccountTaxCode(Model): _columns = { 'code': fields.char('Case Code', size=512), } -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/l10n_ch_payment_slip/report/__init__.py b/l10n_ch_payment_slip/report/__init__.py index 930ba48b4..8398de9c3 100644 --- a/l10n_ch_payment_slip/report/__init__.py +++ b/l10n_ch_payment_slip/report/__init__.py @@ -28,8 +28,6 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## - -from . import report_webkit_html from . import webkit_parser from . import multi_report_webkit_html diff --git a/l10n_ch_payment_slip/report/bvr.mako b/l10n_ch_payment_slip/report/bvr.mako deleted file mode 100644 index 43c13739a..000000000 --- a/l10n_ch_payment_slip/report/bvr.mako +++ /dev/null @@ -1,304 +0,0 @@ -## -*- coding: utf-8 -*- - - - - - - - - %for inv in objects : - <% setLang(inv.partner_id.lang) %> - - - <% commercial_partner = inv.commercial_partner_id if hasattr(inv, 'commercial_partner_id') else inv.partner_id %> - %if inv.partner_id.id != commercial_partner.id: - - - %else: - - %endif - - - - %if inv.partner_id.country_id : - - %endif -
${commercial_partner.name or ''}
${inv.partner_id.title and inv.partner_id.title.name or ''} ${inv.partner_id.name }
${inv.partner_id.title and inv.partner_id.title.name or ''} ${inv.partner_id.name }
${inv.partner_id.street or ''|entity}
${inv.partner_id.street2 or ''|entity}
${inv.partner_id.zip or ''|entity} ${inv.partner_id.city or ''|entity}
${inv.partner_id.country_id.name or ''|entity}
- -
- ${_('Payment slip for:')} ${inv.number or ''|entity} -
-
- -
- -
- %if company.bvr_background: - bvr - %endif - -
- - - - - - -
${_space(_get_ref(inv))}
- %if inv.partner_id.id != commercial_partner.id: - ${commercial_partner.name or ''|entity} - %else: - ${inv.partner_id.name |entity} - %endif -
${inv.partner_id.street or ''|entity}
${inv.partner_id.street2 or ''|entity}
${inv.partner_id.zip or ''|entity} ${inv.partner_id.city or ''|entity}
-
- %if inv.partner_bank_id and inv.partner_bank_id.print_bank and inv.partner_bank_id.bank: -
- ${inv.partner_bank_id.bank_name or ''}
- ${inv.partner_bank_id.bank and inv.partner_bank_id.bank.zip or ''} ${inv.partner_bank_id.bank and inv.partner_bank_id.bank.city or ''} -
- %endif - - -
${inv.partner_bank_id.print_account and inv.partner_bank_id.get_account_number() or ''}
- -
${" ".join(_space(('%.2f' % inv.amount_total)[:-3], 1))} ${" ".join(_space(('%.2f' % inv.amount_total)[-2:], 1))}
- - %if inv.partner_bank_id.print_partner: -
- - - - - -
${user.company_id.partner_id.name}
${user.company_id.partner_id.street}
${user.company_id.partner_id.zip} ${user.company_id.partner_id.city}
-
- %endif - - -
${_space(_get_ref(inv))}
-
${" ".join(_space(('%.2f' % inv.amount_total)[:-3], 1))} ${" ".join(_space(('%.2f' % inv.amount_total)[-2:], 1))}
-
- - - - - -
- %if inv.partner_id.id != commercial_partner.id: - ${commercial_partner.name or ''|entity} - %else: - ${inv.partner_id.name |entity} - %endif -
${inv.partner_id.street or ''|entity}
${inv.partner_id.street2 or ''|entity}
${inv.partner_id.zip or ''|entity} ${inv.partner_id.city or ''|entity}
-
- - %if inv.partner_bank_id.print_partner: -
- - - - - -
${user.company_id.partner_id.name}
${user.company_id.partner_id.street}
${user.company_id.partner_id.zip} ${user.company_id.partner_id.city}
-
- %endif - - %if inv.partner_bank_id and inv.partner_bank_id.print_bank and inv.partner_bank_id.bank: -
- ${inv.partner_bank_id.bank_name or ''}
- ${inv.partner_bank_id.bank and inv.partner_bank_id.bank.zip or ''} ${inv.partner_bank_id.bank and inv.partner_bank_id.bank.city or ''} -
- %endif - -
${inv.partner_bank_id.print_account and inv.partner_bank_id.get_account_number() or ''}
- -
- <% - ref_start_left = 1.5 - ref_coef_space = company.bvr_scan_line_letter_spacing or 2.55 - tt = [ v for v in mod10r('01'+str('%.2f' % inv.amount_total).replace('.','').rjust(10,'0')) ] - tt.append('>') - tt += [v for v in _get_ref(inv)] - tt.append('+') - tt.append(' ') - tt += [v for v in inv.partner_bank_id.get_account_number().split('-')[0]+(str(inv.partner_bank_id.get_account_number().split('-')[1])).rjust(6,'0')+inv.partner_bank_id.get_account_number().split\ -('-')[2]] - tt.append('>') - %> - %for ii,c in enumerate(tt) : -
${c}
- %endfor -
- %endfor - - diff --git a/l10n_ch_payment_slip/report/multi_bvr.mako b/l10n_ch_payment_slip/report/multi_bvr.mako index bda1549fc..a45ad6eef 100644 --- a/l10n_ch_payment_slip/report/multi_bvr.mako +++ b/l10n_ch_payment_slip/report/multi_bvr.mako @@ -39,6 +39,7 @@ top:${str(company.bvr_add_vert or '0.0').replace(',','.')}mm; left:${str(company.bvr_add_horz or '0.0').replace(',','.')}mm; font-size:12; + text-align:left; } .slip_bank_acc { @@ -179,7 +180,7 @@ <% inv = move.invoice %> <% setLang(inv.partner_id.lang) %> - +
<% commercial_partner = inv.commercial_partner_id if hasattr(move.invoice, 'commercial_partner_id') else inv.partner_id %> %if inv.partner_id.id != commercial_partner.id: diff --git a/l10n_ch_payment_slip/report/multi_report_webkit_html.py b/l10n_ch_payment_slip/report/multi_report_webkit_html.py index a6b8b873d..92eee7352 100644 --- a/l10n_ch_payment_slip/report/multi_report_webkit_html.py +++ b/l10n_ch_payment_slip/report/multi_report_webkit_html.py @@ -17,31 +17,138 @@ # along with this program. If not, see . # ############################################################################## +import re +import time -from .report_webkit_html import L10nCHReportWebkitHtml -from .webkit_parser import MultiBvrWebKitParser +from openerp import addons +from openerp.report import report_sxw +from openerp.osv import orm -from openerp.osv.osv import except_osv +from openerp.tools import mod10r from openerp.tools.translate import _ +from openerp.osv import orm +from .webkit_parser import MultiBvrWebKitParser +from ..invoice import AccountInvoice + +class L10nCHReportWebkitHtmlMulti(report_sxw.rml_parse): + """Report that output single BVR from invoice. + This report is deprectated and will be merged + with multi payment term BVR report when porting to V8""" -class L10nCHReportWebkitHtmlMulti(L10nCHReportWebkitHtml): def __init__(self, cr, uid, name, context): - super(L10nCHReportWebkitHtmlMulti, self).__init__(cr, uid, name, context=context) + super(L10nCHReportWebkitHtmlMulti, self).__init__(cr, uid, name, + context=context) + self.localcontext.update({ + 'time': time, + 'cr': cr, + 'uid': uid, + 'user': self.pool.get("res.users").browse(cr, uid, uid), + 'mod10r': mod10r, + '_space': AccountInvoice._space, + '_get_ref': self._get_ref, + 'comma_me': self.comma_me, + 'police_absolute_path': self.police_absolute_path, + 'bvr_absolute_path': self.bvr_absolute_path, + 'headheight': self.headheight, + }) + + _compile_get_ref = re.compile('[^0-9]') + _compile_comma_me = re.compile("^(-?\d+)(\d{3})") + _compile_check_bvr = re.compile('[0-9][0-9]-[0-9]{3,6}-[0-9]') + _compile_check_bvr_add_num = re.compile('[0-9]*$') + + def set_context(self, objects, data, ids, report_type=None): + self._check(ids) + return super(L10nCHReportWebkitHtmlMulti, self).set_context(objects, + data, + ids, + report_type=report_type) + def _get_ref(self, move): + """Get BVR reference using move related to invoice""" + model = self.pool['account.move.line'] + return model.get_bvr_ref(self.cr, self.uid, move.id) + + def police_absolute_path(self, inner_path): + """Will get the ocrb police absolute path""" + path = addons.get_module_resource('l10n_ch_payment_slip', 'report', inner_path) + return path + + def bvr_absolute_path(self): + """Will get the ocrb police absolute path""" + path = addons.get_module_resource('l10n_ch_payment_slip', 'report', 'bvr1.jpg') + return path + + def headheight(self): + report_id = self.pool['ir.actions.report.xml'].search(self.cr, self.uid, + [('name', '=', 'BVR invoice')])[0] + report = self.pool['ir.actions.report.xml'].browse(self.cr, self.uid, report_id) + return report.webkit_header.margin_top + + def comma_me(self, amount): + """Fast swiss number formatting""" + if isinstance(amount, float): + amount = str('%.2f' % amount) + else: + amount = str(amount) + orig = amount + new = self._compile_comma_me.sub("\g<1>'\g<2>", amount) + if orig == new: + return new + else: + return self.comma_me(new) + + def _check_invoice(self, invoice_ids): + """Check if the invoice is ready to be printed""" + if not invoice_ids: + invoice_ids = [] + cursor = self.cr + invoice_obj = self.pool['account.invoice'] + ids = invoice_ids + for invoice in invoice_obj.browse(cursor, self.uid, ids): + invoice_name = "%s %s" % (invoice.name, invoice.number) + if not invoice.number: + raise orm.except_orm( + _('UserError'), + _('Your invoice should be validated to generate a BVR reference.') + ) + if not invoice.partner_bank_id: + raise orm.except_orm( + _('UserError'), + _('No bank specified on invoice:\n%s' % (invoice_name)) + ) + if not self._compile_check_bvr.match( + invoice.partner_bank_id.get_account_number() or ''): + raise orm.except_orm( + _('UserError'), + _(('Your bank BVR number should be of the form 0X-XXX-X! ' + 'Please check your company ' + 'information for the invoice:\n%s') % (invoice_name)) + ) + adherent_num = invoice.partner_bank_id.bvr_adherent_num + if invoice.partner_bank_id.bvr_adherent_num \ + and not self._compile_check_bvr_add_num.match(adherent_num): + raise orm.except_orm( + _('UserError'), + _(('Your bank BVR adherent number must contain only ' + 'digits!\nPlease check your company ' + 'information for the invoice:\n%s') % (invoice_name)) + ) + return '' def _check(self, move_ids): cursor = self.cr - pool = self.pool - move_line_obj = pool.get('account.move.line') + move_line_obj = self.pool['account.move.line'] if not move_ids: - raise except_osv(_('UserError'), - _('Your invoice should be validated to generate BVR references.')) - invoice_id = move_line_obj.read(cursor, self.uid, move_ids[0], ['invoice'])['invoice'][0] + raise orm.except_orm( + _('UserError'), + _('Your invoice should be validated to generate BVR reference.') + ) + invoice_id = move_line_obj.read(cursor, self.uid, move_ids[0], + ['invoice'])['invoice'][0] if invoice_id: - return super(L10nCHReportWebkitHtmlMulti, self)._check([invoice_id]) + self._check_invoice([invoice_id]) MultiBvrWebKitParser('report.invoice_bvr_webkit_multi', 'account.invoice', 'l10n_ch_payment_slip/report/multi_bvr.mako', parser=L10nCHReportWebkitHtmlMulti) - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/l10n_ch_payment_slip/report/multi_report_webkit_html_view.xml b/l10n_ch_payment_slip/report/multi_report_webkit_html_view.xml index 53f6273ab..9b3277c02 100644 --- a/l10n_ch_payment_slip/report/multi_report_webkit_html_view.xml +++ b/l10n_ch_payment_slip/report/multi_report_webkit_html_view.xml @@ -1,17 +1,121 @@ - - + + + Portrait + A4 + + + + + + ${_debug or ''|n} + + ]]> + + + + + + + BVR header + + - + True diff --git a/l10n_ch_payment_slip/report/report_webkit_html.py b/l10n_ch_payment_slip/report/report_webkit_html.py deleted file mode 100644 index e89864cd0..000000000 --- a/l10n_ch_payment_slip/report/report_webkit_html.py +++ /dev/null @@ -1,141 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Nicolas Bessi. Copyright Camptocamp SA -# Financial contributors: Hasa SA, Open Net SA, -# Prisme Solutions Informatique SA, Quod SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import re -import time - -from openerp import addons -from openerp.report import report_sxw -from openerp.osv.osv import except_osv - -from openerp.tools import mod10r -from openerp.tools.translate import _ - - -class L10nCHReportWebkitHtml(report_sxw.rml_parse): - """Report that output single BVR from invoice. - This report is deprectated and will be merged - with multi payment term BVR report when porting to V8""" - - def __init__(self, cr, uid, name, context): - super(L10nCHReportWebkitHtml, self).__init__(cr, uid, name, context=context) - self.localcontext.update({ - 'time': time, - 'cr': cr, - 'uid': uid, - 'user': self.pool.get("res.users").browse(cr, uid, uid), - 'mod10r': mod10r, - '_space': self._space, - '_get_ref': self._get_ref, - 'comma_me': self.comma_me, - 'police_absolute_path': self.police_absolute_path, - 'bvr_absolute_path': self.bvr_absolute_path, - 'headheight': self.headheight, - }) - - _compile_get_ref = re.compile('[^0-9]') - _compile_comma_me = re.compile("^(-?\d+)(\d{3})") - _compile_check_bvr = re.compile('[0-9][0-9]-[0-9]{3,6}-[0-9]') - _compile_check_bvr_add_num = re.compile('[0-9]*$') - - def set_context(self, objects, data, ids, report_type=None): - self._check(ids) - return super(L10nCHReportWebkitHtml, self).set_context(objects, data, ids, report_type=report_type) - - def police_absolute_path(self, inner_path): - """Will get the ocrb police absolute path""" - path = addons.get_module_resource('l10n_ch_payment_slip', 'report', inner_path) - return path - - def bvr_absolute_path(self): - """Will get the ocrb police absolute path""" - path = addons.get_module_resource('l10n_ch_payment_slip', 'report', 'bvr1.jpg') - return path - - def headheight(self): - report_id = self.pool.get('ir.actions.report.xml').search(self.cr, self.uid, - [('name', '=', 'BVR invoice')])[0] - report = self.pool.get('ir.actions.report.xml').browse(self.cr, self.uid, report_id) - return report.webkit_header.margin_top - - def comma_me(self, amount): - """Fast swiss number formatting""" - if isinstance(amount, float): - amount = str('%.2f' % amount) - else: - amount = str(amount) - orig = amount - new = self._compile_comma_me.sub("\g<1>'\g<2>", amount) - if orig == new: - return new - else: - return self.comma_me(new) - - def _space(self, nbr, nbrspc=5): - """Spaces * 5. - - Example: - >>> self._space('123456789012345') - '12 34567 89012 345' - """ - return ''.join([' '[(i - 2) % nbrspc:] + c for i, c in enumerate(nbr)]) - - def _get_ref(self, inv): - return inv.get_bvr_ref() - - def _check(self, invoice_ids): - """Check if the invoice is ready to be printed""" - if not invoice_ids: - invoice_ids = [] - cursor = self.cr - pool = self.pool - invoice_obj = pool.get('account.invoice') - ids = invoice_ids - for invoice in invoice_obj.browse(cursor, self.uid, ids): - invoice_name = "%s %s" % (invoice.name, invoice.number) - if not invoice.number: - raise except_osv(_('UserError'), - _('Your invoice should be validated to generate a BVR reference.')) - if not invoice.partner_bank_id: - raise except_osv(_('UserError'), - _('No bank specified on invoice:\n%s' % (invoice_name))) - if not self._compile_check_bvr.match( - invoice.partner_bank_id.get_account_number() or ''): - raise except_osv(_('UserError'), - _(('Your bank BVR number should be of the form 0X-XXX-X! ' - 'Please check your company ' - 'information for the invoice:\n%s') % (invoice_name))) - if invoice.partner_bank_id.bvr_adherent_num \ - and not self._compile_check_bvr_add_num.match(invoice.partner_bank_id.bvr_adherent_num): - raise except_osv(_('UserError'), - _(('Your bank BVR adherent number must contain only ' - 'digits!\nPlease check your company ' - 'information for the invoice:\n%s') % (invoice_name))) - return '' - - -report_sxw.report_sxw('report.invoice_bvr_webkit', - 'account.invoice', - 'l10n_ch_payment_slip/report/bvr.mako', - parser=L10nCHReportWebkitHtml) - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/l10n_ch_payment_slip/report/report_webkit_html_view.xml b/l10n_ch_payment_slip/report/report_webkit_html_view.xml index 190c2b57a..1f3e2ea96 100644 --- a/l10n_ch_payment_slip/report/report_webkit_html_view.xml +++ b/l10n_ch_payment_slip/report/report_webkit_html_view.xml @@ -1,118 +1,4 @@ - - - Portrait - A4 - - - - - - - ]]> - - - - - - - BVR header - - - - diff --git a/l10n_ch_payment_slip/wizard/bvr_import.py b/l10n_ch_payment_slip/wizard/bvr_import.py index 48996aa22..7d58d14a1 100644 --- a/l10n_ch_payment_slip/wizard/bvr_import.py +++ b/l10n_ch_payment_slip/wizard/bvr_import.py @@ -25,7 +25,7 @@ from openerp.tools.translate import _ from openerp.osv.orm import TransientModel, fields -from openerp.osv.osv import except_osv +from openerp.osv import orm from openerp.tools import mod10r REF = re.compile('[^0-9]') @@ -79,12 +79,12 @@ def _parse_lines(self, cursor, uid, inlines, context=None): record = {} if line[0:3] in ('999', '995'): if find_total: - raise except_osv(_('Error'), - _('Too much total record found!')) + raise orm.except_orm(_('Error'), + _('Too much total record found!')) find_total = True if lines: - raise except_osv(_('Error'), - _('Record found after total record!')) + raise orm.except_orm(_('Error'), + _('Record found after total record!')) amount = float(line[39:49]) + (float(line[49:51]) / 100) cost = float(line[69:76]) + (float(line[76:78]) / 100) if line[2] == '5': @@ -93,11 +93,15 @@ def _parse_lines(self, cursor, uid, inlines, context=None): if round(amount - total_amount, 2) >= 0.01 \ or round(cost - total_cost, 2) >= 0.01: - raise except_osv(_('Error'), - _('Total record different from the computed!')) + raise orm.except_orm( + _('Error'), + _('Total record different from the computed!') + ) if int(line[51:63]) != len(records): - raise except_osv(_('Error'), - _('Number record different from the computed!')) + raise orm.except_orm( + _('Error'), + _('Number record different from the computed!') + ) else: record = { 'reference': line[12:39], @@ -107,8 +111,10 @@ def _parse_lines(self, cursor, uid, inlines, context=None): } if record['reference'] != mod10r(record['reference'][:-1]): - raise except_osv(_('Error'), - _('Recursive mod10 is invalid for reference: %s') % record['reference']) + raise orm.except_orm( + _('Error'), + _('Recursive mod10 is invalid for reference: %s') % record['reference'] + ) if line[2] == '5': record['amount'] *= -1 @@ -139,11 +145,13 @@ def _create_voucher_from_record(self, cursor, uid, record, 'receipt', statement.date, context=context) + default_account_id = statement.journal_id.default_credit_account_id.id voucher_res = {'type': 'receipt', 'name': record['reference'], 'partner_id': partner_id, 'journal_id': statement.journal_id.id, - 'account_id': result.get('account_id', statement.journal_id.default_credit_account_id.id), + 'account_id': result.get('account_id', + default_account_id), 'company_id': statement.company_id.id, 'currency_id': statement.currency.id, 'date': record['date'] or time.strftime('%Y-%m-%d'), @@ -177,8 +185,10 @@ def _get_account(self, cursor, uid, line_ids, record, context=None): name = "property_account_payable" account_id = property_obj.get(cursor, uid, name, 'res.partner', context=context).id if not account_id: - raise except_osv(_('Error'), - _('The properties account payable account receivable are not set')) + raise orm.except_orm( + _('Error'), + _('The properties account payable account receivable are not set') + ) return account_id def _prepare_line_vals(self, cursor, uid, statement, record, @@ -194,26 +204,34 @@ def _prepare_line_vals(self, cursor, uid, statement, record, 'type': (record['amount'] >= 0 and 'customer') or 'supplier', 'statement_id': statement.id, } - line_ids = move_line_obj.search(cursor, uid, - [('ref', '=', reference), - ('reconcile_id', '=', False), - ('account_id.type', 'in', ['receivable', 'payable']), - ('journal_id.type', '=', 'sale')], - order='date desc', context=context) + line_ids = move_line_obj.search( + cursor, uid, + [('ref', '=', reference), + ('reconcile_id', '=', False), + ('account_id.type', 'in', ['receivable', 'payable']), + ('journal_id.type', '=', 'sale')], + order='date desc', + context=context + ) #for multiple payments if not line_ids: - line_ids = move_line_obj.search(cursor, uid, - [('transaction_ref', '=', reference), - ('reconcile_id', '=', False), - ('account_id.type', 'in', ['receivable', 'payable']), - ('journal_id.type', '=', 'sale')], - order='date desc', context=context) + line_ids = move_line_obj.search( + cursor, uid, + [('transaction_ref', '=', reference), + ('reconcile_id', '=', False), + ('account_id.type', 'in', ['receivable', 'payable']), + ('journal_id.type', '=', 'sale')], + order='date desc', + context=context + ) if not line_ids: line_ids = self._reconstruct_invoice_ref(cursor, uid, reference, None) if line_ids and voucher_enabled: - values['voucher_id'] = self._create_voucher_from_record(cursor, uid, record, - statement, line_ids, - context=context) + values['voucher_id'] = self._create_voucher_from_record( + cursor, uid, record, + statement, line_ids, + context=context + ) account_id = self._get_account(cursor, uid, line_ids, record, context=context) values['account_id'] = account_id @@ -228,41 +246,52 @@ def import_v11(self, cursor, uid, ids, data, context=None): """Import v11 file and transfor it into statement lines""" if context is None: context = {} module_obj = self.pool['ir.module.module'] - voucher_enabled = module_obj.search(cursor, uid, [('name', '=', 'account_voucher'), - ('state', '=', 'installed')]) + voucher_enabled = module_obj.search(cursor, + uid, + [('name', '=', 'account_voucher'), + ('state', '=', 'installed')]) # if module installed we check ir.config_parameter to force disable of voucher if voucher_enabled: - para = self.pool['ir.config_parameter'].get_param(cursor, - uid, - 'l10n_ch_payment_slip_voucher_disable', - default = '0') - if para.lower() not in ['0', 'false']: # if voucher is disabled + para = self.pool['ir.config_parameter'].get_param( + cursor, + uid, + 'l10n_ch_payment_slip_voucher_disable', + default='0' + ) + if para.lower() not in ['0', 'false']: # If voucher is disabled voucher_enabled = False statement_line_obj = self.pool.get('account.bank.statement.line') attachment_obj = self.pool.get('ir.attachment') statement_obj = self.pool.get('account.bank.statement') file = data['form']['file'] if not file: - raise except_osv(_('UserError'), - _('Please select a file first!')) + raise orm.except_orm(_('UserError'), + _('Please select a file first!')) statement_id = data['id'] lines = base64.decodestring(file).split("\n") records = self._parse_lines(cursor, uid, lines, context=context) - statement = statement_obj.browse(cursor, uid, statement_id, context=context) + statement = statement_obj.browse(cursor, + uid, + statement_id, + context=context) for record in records: - values = self._prepare_line_vals(cursor, uid, statement, - record, voucher_enabled, + values = self._prepare_line_vals(cursor, uid, + statement, + record, + voucher_enabled, context=context) statement_line_obj.create(cursor, uid, values, context=context) - attachment_obj.create(cursor, uid, - {'name': 'BVR %s' % time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime()), - 'datas': file, - 'datas_fname': 'BVR %s.txt' % time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime()), - 'res_model': 'account.bank.statement', - 'res_id': statement_id, - }, - context=context) + attachment_obj.create( + cursor, uid, + {'name': 'BVR %s' % time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime()), + 'datas': file, + 'datas_fname': 'BVR %s.txt' % time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime()), + 'res_model': 'account.bank.statement', + 'res_id': statement_id, + }, + context=context + ) return {} diff --git a/l10n_ch_payment_slip_base_transaction_id/__init__.py b/l10n_ch_payment_slip_base_transaction_id/__init__.py index 1814a6a03..017287e8e 100644 --- a/l10n_ch_payment_slip_base_transaction_id/__init__.py +++ b/l10n_ch_payment_slip_base_transaction_id/__init__.py @@ -18,5 +18,3 @@ # along with this program. If not, see . # ############################################################################## - -from . import invoice diff --git a/l10n_ch_payment_slip_base_transaction_id/invoice.py b/l10n_ch_payment_slip_base_transaction_id/invoice.py deleted file mode 100644 index 26a212e2d..000000000 --- a/l10n_ch_payment_slip_base_transaction_id/invoice.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Guewen Baconnier -# Copyright 2014 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp.osv import orm - - -class account_invoice(orm.Model): - _inherit = 'account.invoice' - - def _get_bvr_ref(self, cr, uid, invoice, context=None): - """Retrieve ESR/BVR reference form invoice in order to print it - - 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) From 781e069e10f37016fb4f889665eb2e02634b9a67 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 15 Apr 2014 14:41:06 +0200 Subject: [PATCH 02/19] [ADD] hook to allows to override BVR/ERS report total amount --- l10n_ch_payment_slip/invoice.py | 4 ++++ l10n_ch_payment_slip/report/multi_bvr.mako | 6 +++--- l10n_ch_payment_slip/report/multi_report_webkit_html.py | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/l10n_ch_payment_slip/invoice.py b/l10n_ch_payment_slip/invoice.py index 11b2e1a23..3455e8cc8 100644 --- a/l10n_ch_payment_slip/invoice.py +++ b/l10n_ch_payment_slip/invoice.py @@ -33,6 +33,10 @@ class AccountMoveLine(Model): 'transaction_ref': fields.char('Transaction Ref.', size=128), } + def _get_bvr_amount(self, move, rtype=None): + """Hook to get amount in CHF for BVR""" + return move.debit + def get_bvr_ref(self, cursor, uid, move_line_id, context=None): """Retrieve ESR/BVR reference from move line in order to print it diff --git a/l10n_ch_payment_slip/report/multi_bvr.mako b/l10n_ch_payment_slip/report/multi_bvr.mako index a45ad6eef..7192305cd 100644 --- a/l10n_ch_payment_slip/report/multi_bvr.mako +++ b/l10n_ch_payment_slip/report/multi_bvr.mako @@ -233,7 +233,7 @@
${inv.partner_bank_id.print_account and inv.partner_bank_id.get_account_number() or ''}
-
${" ".join(_space(('%.2f' % move.debit)[:-3], 1))} ${" ".join(_space(('%.2f' % move.debit)[-2:], 1))}
+
${" ".join(_space(('%.2f' % amount(move))[:-3], 1))} ${" ".join(_space(('%.2f' % amount(move))[-2:], 1))}
%if inv.partner_bank_id.print_partner:
@@ -248,7 +248,7 @@
${_space(_get_ref(move))}
-
${" ".join(_space(('%.2f' % move.debit)[:-3], 1))} ${" ".join(_space(('%.2f' % move.debit)[-2:], 1))}
+
${" ".join(_space(('%.2f' % amount(move))[:-3], 1))} ${" ".join(_space(('%.2f' % amount(move))[-2:], 1))}
${commercial_partner.name or ''}
@@ -288,7 +288,7 @@ <% ref_start_left = 1.5 ref_coef_space = company.bvr_scan_line_letter_spacing or 2.55 - tt = [ v for v in mod10r('01'+str('%.2f' % move.debit).replace('.','').rjust(10,'0')) ] + tt = [ v for v in mod10r('01'+str('%.2f' % amount(move)).replace('.','').rjust(10,'0')) ] tt.append('>') tt += [v for v in _get_ref(move)] tt.append('+') diff --git a/l10n_ch_payment_slip/report/multi_report_webkit_html.py b/l10n_ch_payment_slip/report/multi_report_webkit_html.py index 92eee7352..f7b7afb3d 100644 --- a/l10n_ch_payment_slip/report/multi_report_webkit_html.py +++ b/l10n_ch_payment_slip/report/multi_report_webkit_html.py @@ -50,6 +50,7 @@ def __init__(self, cr, uid, name, context): 'police_absolute_path': self.police_absolute_path, 'bvr_absolute_path': self.bvr_absolute_path, 'headheight': self.headheight, + 'amount': self.amount, }) _compile_get_ref = re.compile('[^0-9]') @@ -63,6 +64,10 @@ def set_context(self, objects, data, ids, report_type=None): data, ids, report_type=report_type) + + def amount(self, move, rtype=None): + return self.pool['account.move.line']._get_bvr_amount(move, rtype=rtype) + def _get_ref(self, move): """Get BVR reference using move related to invoice""" model = self.pool['account.move.line'] From 7d2583d05712debaa1f788679510d3ebf7c28505 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Wed, 16 Apr 2014 10:22:55 +0200 Subject: [PATCH 03/19] [REFACTOR] following fix of bug lp:1308364 --- l10n_ch_payment_slip/invoice.py | 2 +- l10n_ch_payment_slip/report/__init__.py | 4 -- .../report/multi_report_webkit_html.py | 46 ++++++++++++++----- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/l10n_ch_payment_slip/invoice.py b/l10n_ch_payment_slip/invoice.py index 3455e8cc8..c4007ce9e 100644 --- a/l10n_ch_payment_slip/invoice.py +++ b/l10n_ch_payment_slip/invoice.py @@ -33,7 +33,7 @@ class AccountMoveLine(Model): 'transaction_ref': fields.char('Transaction Ref.', size=128), } - def _get_bvr_amount(self, move, rtype=None): + def _get_bvr_amount(self, cr, uid, move, rtype=None): """Hook to get amount in CHF for BVR""" return move.debit diff --git a/l10n_ch_payment_slip/report/__init__.py b/l10n_ch_payment_slip/report/__init__.py index 8398de9c3..2943f265c 100644 --- a/l10n_ch_payment_slip/report/__init__.py +++ b/l10n_ch_payment_slip/report/__init__.py @@ -28,8 +28,4 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## -from . import webkit_parser from . import multi_report_webkit_html - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/l10n_ch_payment_slip/report/multi_report_webkit_html.py b/l10n_ch_payment_slip/report/multi_report_webkit_html.py index f7b7afb3d..b333aa947 100644 --- a/l10n_ch_payment_slip/report/multi_report_webkit_html.py +++ b/l10n_ch_payment_slip/report/multi_report_webkit_html.py @@ -27,7 +27,6 @@ from openerp.tools import mod10r from openerp.tools.translate import _ from openerp.osv import orm -from .webkit_parser import MultiBvrWebKitParser from ..invoice import AccountInvoice class L10nCHReportWebkitHtmlMulti(report_sxw.rml_parse): @@ -59,14 +58,39 @@ def __init__(self, cr, uid, name, context): _compile_check_bvr_add_num = re.compile('[0-9]*$') def set_context(self, objects, data, ids, report_type=None): - self._check(ids) - return super(L10nCHReportWebkitHtmlMulti, self).set_context(objects, - data, - ids, - report_type=report_type) + ml_ids = self.get_obj_reference(ids) + self._check(ml_ids) + objects = self.pool['account.move.line'].browse(self.cr, self.uid, + ml_ids) + import pdb; pdb.set_trace() + + return super(L10nCHReportWebkitHtmlMulti, self).set_context( + objects, + data, + ids, + report_type=report_type + ) + + def get_obj_reference(self, ids, context=None): + cursor, uid = self.cr, self.uid + move_line_obj = self.pool.get('account.move.line') + account_obj = self.pool.get('account.account') + invoice_obj = self.pool.get('account.invoice') + inv = invoice_obj.browse(cursor, uid, ids[0], context=context) + tier_account_ids = account_obj.search( + cursor, uid, + [('type', 'in', ['receivable', 'payable'])], + context=context) + move_line_ids = move_line_obj.search( + cursor, uid, + [('move_id', '=', inv.move_id.id), + ('account_id', 'in', tier_account_ids)], + context=context) + return move_line_ids def amount(self, move, rtype=None): - return self.pool['account.move.line']._get_bvr_amount(move, rtype=rtype) + ml_model = self.pool['account.move.line'] + return ml_model._get_bvr_amount(self.cr, self.uid, move, rtype=rtype) def _get_ref(self, move): """Get BVR reference using move related to invoice""" @@ -76,16 +100,16 @@ def _get_ref(self, move): def police_absolute_path(self, inner_path): """Will get the ocrb police absolute path""" path = addons.get_module_resource('l10n_ch_payment_slip', 'report', inner_path) - return path + return path def bvr_absolute_path(self): """Will get the ocrb police absolute path""" path = addons.get_module_resource('l10n_ch_payment_slip', 'report', 'bvr1.jpg') - return path + return path def headheight(self): report_id = self.pool['ir.actions.report.xml'].search(self.cr, self.uid, - [('name', '=', 'BVR invoice')])[0] + [('name', '=', 'BVR invoice')])[0] report = self.pool['ir.actions.report.xml'].browse(self.cr, self.uid, report_id) return report.webkit_header.margin_top @@ -153,7 +177,7 @@ def _check(self, move_ids): if invoice_id: self._check_invoice([invoice_id]) -MultiBvrWebKitParser('report.invoice_bvr_webkit_multi', +report_sxw.report_sxw('report.invoice_bvr_webkit_multi', 'account.invoice', 'l10n_ch_payment_slip/report/multi_bvr.mako', parser=L10nCHReportWebkitHtmlMulti) From 15d26a152ea92e0ea26d3859ea47dc04b6328eb6 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Wed, 16 Apr 2014 10:23:44 +0200 Subject: [PATCH 04/19] [RM] dead code --- l10n_ch_payment_slip/report/webkit_parser.py | 53 -------------------- 1 file changed, 53 deletions(-) delete mode 100644 l10n_ch_payment_slip/report/webkit_parser.py diff --git a/l10n_ch_payment_slip/report/webkit_parser.py b/l10n_ch_payment_slip/report/webkit_parser.py deleted file mode 100644 index bd76bf9c4..000000000 --- a/l10n_ch_payment_slip/report/webkit_parser.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Romain Deheele. Copyright Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp import pooler -from openerp.addons.report_webkit import webkit_report - - -class MultiBvrWebKitParser(webkit_report.WebKitParser): - - def create_single_pdf(self, cursor, uid, ids, - data, report_xml, context=None): - self.pool = pooler.get_pool(cursor.dbname) - target_obj = 'account.move.line' - move_line_ids = self.get_obj_reference(cursor, uid, ids, context=context) - ctx_multi_bvr = context.copy() - ctx_multi_bvr['active_model'] = self.table = target_obj - ctx_multi_bvr['active_ids'] = move_line_ids - return super(MultiBvrWebKitParser, self - ).create_single_pdf(cursor, uid, move_line_ids, - data, report_xml, ctx_multi_bvr) - - def get_obj_reference(self, cursor, uid, ids, context=None): - move_line_obj = self.pool.get('account.move.line') - account_obj = self.pool.get('account.account') - invoice_obj = self.pool.get('account.invoice') - inv = invoice_obj.browse(cursor, uid, ids[0], context=context) - tier_account_ids = account_obj.search( - cursor, uid, - [('type', 'in', ['receivable', 'payable'])], - context=context) - move_line_ids = move_line_obj.search( - cursor, uid, - [('move_id', '=', inv.move_id.id), - ('account_id', 'in', tier_account_ids)], - context=context) - return move_line_ids From 453a4ede8c581dbe07ca2ca4fe6ae9fd5d880c38 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Wed, 16 Apr 2014 10:31:14 +0200 Subject: [PATCH 05/19] [RM] forgotten pdb --- l10n_ch_payment_slip/report/multi_report_webkit_html.py | 1 - 1 file changed, 1 deletion(-) diff --git a/l10n_ch_payment_slip/report/multi_report_webkit_html.py b/l10n_ch_payment_slip/report/multi_report_webkit_html.py index b333aa947..5d5277699 100644 --- a/l10n_ch_payment_slip/report/multi_report_webkit_html.py +++ b/l10n_ch_payment_slip/report/multi_report_webkit_html.py @@ -62,7 +62,6 @@ def set_context(self, objects, data, ids, report_type=None): self._check(ml_ids) objects = self.pool['account.move.line'].browse(self.cr, self.uid, ml_ids) - import pdb; pdb.set_trace() return super(L10nCHReportWebkitHtmlMulti, self).set_context( objects, From 539760b4796326b0f668ed884ece21e5c769a00c Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Wed, 16 Apr 2014 16:25:35 +0200 Subject: [PATCH 06/19] [REFATOR] credit control payment slip to support crdit.control.line and move line relation cardinality --- .../__init__.py | 5 +- .../account.py | 40 ++++++++++++ .../credit_control_communication.py | 64 +++++++++++++++---- .../credit_control_printer.py | 9 +-- .../report.xml | 2 +- 5 files changed, 99 insertions(+), 21 deletions(-) create mode 100644 l10n_ch_credit_control_payment_slip_report/account.py diff --git a/l10n_ch_credit_control_payment_slip_report/__init__.py b/l10n_ch_credit_control_payment_slip_report/__init__.py index f3327d1b1..aa76b11b5 100644 --- a/l10n_ch_credit_control_payment_slip_report/__init__.py +++ b/l10n_ch_credit_control_payment_slip_report/__init__.py @@ -17,5 +17,6 @@ # along with this program. If not, see . # ############################################################################## -import credit_control_communication -import credit_control_printer +from . import credit_control_communication +from . import credit_control_printer +from . import account diff --git a/l10n_ch_credit_control_payment_slip_report/account.py b/l10n_ch_credit_control_payment_slip_report/account.py new file mode 100644 index 000000000..3decef7de --- /dev/null +++ b/l10n_ch_credit_control_payment_slip_report/account.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Nicolas Bessi +# Copyright 2014 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import orm + + +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 + + :returns: BVR float amount + + """ + fees = getattr(move, 'bvr_dunning_fees', 0.0) + return move.debit + fees diff --git a/l10n_ch_credit_control_payment_slip_report/credit_control_communication.py b/l10n_ch_credit_control_payment_slip_report/credit_control_communication.py index 354f25d9a..cd06c8b7f 100644 --- a/l10n_ch_credit_control_payment_slip_report/credit_control_communication.py +++ b/l10n_ch_credit_control_payment_slip_report/credit_control_communication.py @@ -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) diff --git a/l10n_ch_credit_control_payment_slip_report/credit_control_printer.py b/l10n_ch_credit_control_payment_slip_report/credit_control_printer.py index 2bf4e327d..163685d69 100644 --- a/l10n_ch_credit_control_payment_slip_report/credit_control_printer.py +++ b/l10n_ch_credit_control_payment_slip_report/credit_control_printer.py @@ -28,6 +28,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') @@ -38,13 +39,9 @@ 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), diff --git a/l10n_ch_credit_control_payment_slip_report/report.xml b/l10n_ch_credit_control_payment_slip_report/report.xml index a42ef315a..19b87f08c 100644 --- a/l10n_ch_credit_control_payment_slip_report/report.xml +++ b/l10n_ch_credit_control_payment_slip_report/report.xml @@ -4,7 +4,7 @@ Date: Wed, 16 Apr 2014 16:29:02 +0200 Subject: [PATCH 07/19] [FIX] cleaning tree of unused files --- l10n_ch_payment_slip/__openerp__.py | 1 - l10n_ch_payment_slip/report/report_webkit_html_view.xml | 4 ---- 2 files changed, 5 deletions(-) delete mode 100644 l10n_ch_payment_slip/report/report_webkit_html_view.xml diff --git a/l10n_ch_payment_slip/__openerp__.py b/l10n_ch_payment_slip/__openerp__.py index 17cac7e6e..79bf57944 100644 --- a/l10n_ch_payment_slip/__openerp__.py +++ b/l10n_ch_payment_slip/__openerp__.py @@ -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"], diff --git a/l10n_ch_payment_slip/report/report_webkit_html_view.xml b/l10n_ch_payment_slip/report/report_webkit_html_view.xml deleted file mode 100644 index 1f3e2ea96..000000000 --- a/l10n_ch_payment_slip/report/report_webkit_html_view.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - From be0788cd311861b58b33f96dd2f7a597dca2024c Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 29 Apr 2014 17:13:14 +0200 Subject: [PATCH 08/19] [IMP] file name to use datetime --- .../credit_control_printer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/l10n_ch_credit_control_payment_slip_report/credit_control_printer.py b/l10n_ch_credit_control_payment_slip_report/credit_control_printer.py index 163685d69..401575607 100644 --- a/l10n_ch_credit_control_payment_slip_report/credit_control_printer.py +++ b/l10n_ch_credit_control_payment_slip_report/credit_control_printer.py @@ -18,8 +18,7 @@ # ############################################################################## import base64 - -from openerp.osv import orm +from openerp.osv import orm, fields from openerp.tools.translate import _ @@ -45,6 +44,7 @@ def print_linked_bvr(self, cr, uid, wiz_id, context=None): 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', From 1d625de6bb67859c2c61e69c5b89e43bb86ef054 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Wed, 7 May 2014 14:14:34 +0200 Subject: [PATCH 09/19] [FIX] addons version --- l10n_ch_credit_control_payment_slip_report/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_ch_credit_control_payment_slip_report/__openerp__.py b/l10n_ch_credit_control_payment_slip_report/__openerp__.py index f2c158712..be27b49b9 100644 --- a/l10n_ch_credit_control_payment_slip_report/__openerp__.py +++ b/l10n_ch_credit_control_payment_slip_report/__openerp__.py @@ -26,7 +26,7 @@ of move lines """, - "version": "1.1.0", + "version": "1.2.0", "author": "Camptocamp", "category": "Generic Modules/Others", "website": "http://www.camptocamp.com", From d611fa12b391a9c4288c19e274ac14a51549eae7 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Wed, 7 May 2014 14:17:23 +0200 Subject: [PATCH 10/19] [FIX] addons description et version --- l10n_ch_credit_control_payment_slip_report/__openerp__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/l10n_ch_credit_control_payment_slip_report/__openerp__.py b/l10n_ch_credit_control_payment_slip_report/__openerp__.py index be27b49b9..cda45d968 100644 --- a/l10n_ch_credit_control_payment_slip_report/__openerp__.py +++ b/l10n_ch_credit_control_payment_slip_report/__openerp__.py @@ -22,11 +22,11 @@ Printing of dunning BVR ======================= Add possibility to print BVR/ESR slip of related credit control lines. -The dunning fees are printed on ESR but this not affect the amount +The dunning fees are printed on ESR but they will not affect the amount of move lines """, - "version": "1.2.0", + "version": "1.3.0", "author": "Camptocamp", "category": "Generic Modules/Others", "website": "http://www.camptocamp.com", From 9f7422798d94403c36a47b343967b234e899b594 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Wed, 7 May 2014 14:33:38 +0200 Subject: [PATCH 11/19] [IMP] Change log --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index ac5e26f6b..e8c031282 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. From 1044cfccdb3ec4dfd337b2923f3679535a5278d3 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Wed, 7 May 2014 14:39:49 +0200 Subject: [PATCH 12/19] [FIX] community conventions --- l10n_ch_payment_slip/partner.py | 4 ++-- l10n_ch_payment_slip/wizard/bvr_import.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/l10n_ch_payment_slip/partner.py b/l10n_ch_payment_slip/partner.py index 8855b0ca2..97f201518 100644 --- a/l10n_ch_payment_slip/partner.py +++ b/l10n_ch_payment_slip/partner.py @@ -19,10 +19,10 @@ # along with this program. If not, see . # ############################################################################## +from openerp.osv import orm, fields -from openerp.osv.orm import Model, fields -class ResPartner(Model): +class ResPartner(orm.Model): _inherit = 'res.partner' _columns = { diff --git a/l10n_ch_payment_slip/wizard/bvr_import.py b/l10n_ch_payment_slip/wizard/bvr_import.py index 7d58d14a1..a16947a21 100644 --- a/l10n_ch_payment_slip/wizard/bvr_import.py +++ b/l10n_ch_payment_slip/wizard/bvr_import.py @@ -24,14 +24,13 @@ import re from openerp.tools.translate import _ -from openerp.osv.orm import TransientModel, fields -from openerp.osv import orm +from openerp.osv import orm, fields from openerp.tools import mod10r REF = re.compile('[^0-9]') -class BvrImporterWizard(TransientModel): +class BvrImporterWizard(orm.TransientModel): _name = 'bvr.import.wizard' From 73d20730877eeb5959976c4701c9adb5034ac38b Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 25 Jun 2014 16:05:11 +0200 Subject: [PATCH 13/19] add a summary --- l10n_ch_credit_control_payment_slip_report/__openerp__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/l10n_ch_credit_control_payment_slip_report/__openerp__.py b/l10n_ch_credit_control_payment_slip_report/__openerp__.py index cda45d968..063ad6cae 100644 --- a/l10n_ch_credit_control_payment_slip_report/__openerp__.py +++ b/l10n_ch_credit_control_payment_slip_report/__openerp__.py @@ -17,7 +17,8 @@ # along with this program. If not, see . # ############################################################################## -{"name": "Print BVR/ESR slip related to credit control", +{"name": "Printing of dunning BVR", + "summary": "Print BVR/ESR slip related to credit control", "description": """ Printing of dunning BVR ======================= From 7d5edb93a2a0f3117f21f077f059c73dc5c5bb8f Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 25 Jun 2014 16:17:39 +0200 Subject: [PATCH 14/19] TYPO --- l10n_ch_payment_slip/invoice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/l10n_ch_payment_slip/invoice.py b/l10n_ch_payment_slip/invoice.py index c4007ce9e..dcaa3ce3a 100644 --- a/l10n_ch_payment_slip/invoice.py +++ b/l10n_ch_payment_slip/invoice.py @@ -77,8 +77,8 @@ class AccountInvoice(Model): _compile_get_ref = re.compile('[^0-9]') def _get_reference_type(self, cursor, user, context=None): - """Function use by the function field reference_type - in order to initalise availabl BVR Reference Types + """Function used by the function field 'reference_type' + in order to initalise available BVR Reference Types """ res = super(AccountInvoice, self)._get_reference_type(cursor, user, context=context) From 8b5bb1ac658a3f61160f163feef7639d5f7414ea Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 25 Jun 2014 16:20:30 +0200 Subject: [PATCH 15/19] add missing contexts --- l10n_ch_payment_slip/invoice.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/l10n_ch_payment_slip/invoice.py b/l10n_ch_payment_slip/invoice.py index dcaa3ce3a..c5f69bd8f 100644 --- a/l10n_ch_payment_slip/invoice.py +++ b/l10n_ch_payment_slip/invoice.py @@ -90,14 +90,17 @@ def _compute_full_bvr_name(self, cursor, uid, ids, field_names, arg, context=Non move_line_obj = self.pool.get('account.move.line') account_obj = self.pool.get('account.account') tier_account_id = account_obj.search(cursor, uid, - [('type', 'in', ['receivable', 'payable'])]) + [('type', 'in', ['receivable', 'payable'])], + context=context) for inv in self.browse(cursor, uid, ids, context=context): move_lines = move_line_obj.search(cursor, uid, [('move_id', '=', inv.move_id.id), - ('account_id', 'in', tier_account_id)]) + ('account_id', 'in', tier_account_id)], + context=context) if move_lines: refs = [] - for move_line in move_line_obj.browse(cursor, uid, move_lines, context=context): + for move_line in move_line_obj.browse(cursor, uid, move_lines, + context=context): refs.append(AccountInvoice._space(move_line.get_bvr_ref())) res[inv.id] = ' ; '.join(refs) return res From 1d63cb65cb2d2975a760a4319d1eed515018ad0b Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 25 Jun 2014 16:24:19 +0200 Subject: [PATCH 16/19] fix indent --- l10n_ch_payment_slip/partner.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/l10n_ch_payment_slip/partner.py b/l10n_ch_payment_slip/partner.py index 97f201518..4238b5559 100644 --- a/l10n_ch_payment_slip/partner.py +++ b/l10n_ch_payment_slip/partner.py @@ -26,9 +26,7 @@ class ResPartner(orm.Model): _inherit = 'res.partner' _columns = { - 'ref_companies': fields.one2many('res.company', 'partner_id', - 'Companies that refers to partner'), + 'ref_companies': fields.one2many( + 'res.company', 'partner_id', + 'Companies that refers to partner'), } - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 686fb30d48c631ae805baf18a92d0daba2acabd3 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 25 Jun 2014 16:26:42 +0200 Subject: [PATCH 17/19] remove import of orm imported twice --- l10n_ch_payment_slip/report/multi_report_webkit_html.py | 1 - 1 file changed, 1 deletion(-) diff --git a/l10n_ch_payment_slip/report/multi_report_webkit_html.py b/l10n_ch_payment_slip/report/multi_report_webkit_html.py index 5d5277699..a7bdd7ff4 100644 --- a/l10n_ch_payment_slip/report/multi_report_webkit_html.py +++ b/l10n_ch_payment_slip/report/multi_report_webkit_html.py @@ -26,7 +26,6 @@ from openerp.tools import mod10r from openerp.tools.translate import _ -from openerp.osv import orm from ..invoice import AccountInvoice class L10nCHReportWebkitHtmlMulti(report_sxw.rml_parse): From 5efa56f85c0bdf9ca2b58825216e97b85bb80c7e Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 25 Jun 2014 16:28:29 +0200 Subject: [PATCH 18/19] [PEP8] in multi_report_webkit_html.py --- l10n_ch_payment_slip/report/multi_report_webkit_html.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/l10n_ch_payment_slip/report/multi_report_webkit_html.py b/l10n_ch_payment_slip/report/multi_report_webkit_html.py index a7bdd7ff4..7683ccf30 100644 --- a/l10n_ch_payment_slip/report/multi_report_webkit_html.py +++ b/l10n_ch_payment_slip/report/multi_report_webkit_html.py @@ -28,6 +28,7 @@ from openerp.tools.translate import _ from ..invoice import AccountInvoice + class L10nCHReportWebkitHtmlMulti(report_sxw.rml_parse): """Report that output single BVR from invoice. This report is deprectated and will be merged @@ -60,7 +61,7 @@ def set_context(self, objects, data, ids, report_type=None): ml_ids = self.get_obj_reference(ids) self._check(ml_ids) objects = self.pool['account.move.line'].browse(self.cr, self.uid, - ml_ids) + ml_ids) return super(L10nCHReportWebkitHtmlMulti, self).set_context( objects, @@ -153,7 +154,7 @@ def _check_invoice(self, invoice_ids): ) adherent_num = invoice.partner_bank_id.bvr_adherent_num if invoice.partner_bank_id.bvr_adherent_num \ - and not self._compile_check_bvr_add_num.match(adherent_num): + and not self._compile_check_bvr_add_num.match(adherent_num): raise orm.except_orm( _('UserError'), _(('Your bank BVR adherent number must contain only ' From e0182e45989553d01b7304798764753c78b959a3 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 25 Jun 2014 16:31:32 +0200 Subject: [PATCH 19/19] newish style for self.pool --- l10n_ch_payment_slip/report/multi_report_webkit_html.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/l10n_ch_payment_slip/report/multi_report_webkit_html.py b/l10n_ch_payment_slip/report/multi_report_webkit_html.py index 7683ccf30..f069c9423 100644 --- a/l10n_ch_payment_slip/report/multi_report_webkit_html.py +++ b/l10n_ch_payment_slip/report/multi_report_webkit_html.py @@ -41,7 +41,8 @@ def __init__(self, cr, uid, name, context): 'time': time, 'cr': cr, 'uid': uid, - 'user': self.pool.get("res.users").browse(cr, uid, uid), + 'user': self.pool['res.users'].browse(cr, uid, uid, + context=context), 'mod10r': mod10r, '_space': AccountInvoice._space, '_get_ref': self._get_ref, @@ -72,9 +73,9 @@ def set_context(self, objects, data, ids, report_type=None): def get_obj_reference(self, ids, context=None): cursor, uid = self.cr, self.uid - move_line_obj = self.pool.get('account.move.line') - account_obj = self.pool.get('account.account') - invoice_obj = self.pool.get('account.invoice') + move_line_obj = self.pool['account.move.line'] + account_obj = self.pool['account.account'] + invoice_obj = self.pool['account.invoice'] inv = invoice_obj.browse(cursor, uid, ids[0], context=context) tier_account_ids = account_obj.search( cursor, uid,