40
from mx.DateTime import *
41
# from mx.DateTime import *
42
class account_invoice_bvr(report_sxw.rml_parse):
43
class AccountInvoiceBvr(report_sxw.rml_parse):
43
44
"""Report class that Allows to print BVR payement vector"""
44
def __init__(self, cr, uid, name, context):
45
super(account_invoice_bvr, self).__init__(cr, uid, name, context)
45
def __init__(self, cursor, uid, name, context):
46
super(AccountInvoiceBvr, self).__init__(cursor, uid, name, context)
46
47
self.copyocrbfile('addons/l10n_ch/report/ocrbb.ttf')
47
48
self.localcontext.update({
49
'user':self.pool.get("res.users").browse(cr,uid,uid),
50
'user':self.pool.get("res.users").browse(cursor, uid, uid),
51
52
'_space': self._space,
52
53
'_get_ref': self._get_ref,
53
54
'comma_me': self.comma_me,
54
'format_date': self._get_and_change_date_format_for_swiss,
55
55
'police_absolute_path' : self.police_absolute_path,
56
56
'copyocrbfile': self.copyocrbfile
58
def _get_and_change_date_format_for_swiss (self,date_to_format):
62
date_formatted = strptime(date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
59
#will be fixed in 5.0.10
65
60
def police_absolute_path(self, inner_path) :
61
"""Will get the ocrb police absolute path"""
66
62
path = os.path.join(os.path.dirname(sys.argv[0]), inner_path)
69
def copyocrbfile(self,file):
70
src = self.police_absolute_path(file)
71
file = os.path.basename(src)
72
dest = os.path.join('/tmp/',file)
64
# will be fix in 5.0.10
65
def copyocrbfile(self, ttffile):
67
src = self.police_absolute_path(ttffile)
68
basefile = os.path.basename(src)
69
dest = os.path.join('/tmp/', basefile)
73
70
if not os.path.isfile(dest):
75
shutil.copyfile(src,dest)
72
shutil.copyfile(src, dest)
77
74
"""print ocrbfile was not copy in /tmp/ please
78
75
copy it manually from l10_ch/report"""
82
def comma_me(self,amount):
79
def comma_me(self, amount):
80
"""Fast swiss number formatting"""
83
81
if type(amount) is float :
84
82
amount = str('%.2f'%amount)
102
def _get_ref(self, o):
101
def _get_ref(self, inv):
102
"""Retrieve ESR/BVR reference form invoice in order to print it"""
104
if o.partner_bank.bvr_adherent_num:
105
res = o.partner_bank.bvr_adherent_num
104
if inv.partner_bank.bvr_adherent_num:
105
res = inv.partner_bank.bvr_adherent_num
106
106
invoice_number = ''
108
invoice_number = re.sub('[^0-9]', '0', o.number)
108
invoice_number = re.sub('[^0-9]', '', inv.number)
109
109
return mod10r(res + invoice_number.rjust(26-len(res), '0'))
111
111
report_sxw.report_sxw(
112
112
'report.l10n_ch.bvr',
113
113
'account.invoice',
114
'addons/l10n_ch/report/bvr.rml',
115
parser=account_invoice_bvr,
114
'addons/l10n_ch/report/bvr_report.rml',
115
parser=AccountInvoiceBvr,
118
118
report_sxw.report_sxw(
119
119
'report.l10n_ch.invoice.bvr',
120
120
'account.invoice',
121
'addons/l10n_ch/report/invoice.rml',
122
parser=account_invoice_bvr,
121
'addons/l10n_ch/report/invoice_report.rml',
122
parser=AccountInvoiceBvr,
125
125
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: