X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=addons%2Fl10n_ch%2Freport%2Fbvr_report.py;h=1d84dfd724e8b32de78d3a50c3cf30403321540f;hb=4c49629d1e5953f9c7a03235b79a542c2688dcea;hp=2abacc64ef92b5742af1d2c6e71a72262ea5f41c;hpb=0ca6e99f67d85abaf2272302141555f7d648e2b2;p=odoo%2Fodoo.git diff --git a/addons/l10n_ch/report/bvr_report.py b/addons/l10n_ch/report/bvr_report.py index 2abacc6..1d84dfd 100644 --- a/addons/l10n_ch/report/bvr_report.py +++ b/addons/l10n_ch/report/bvr_report.py @@ -65,15 +65,17 @@ class account_invoice_bvr(report_sxw.rml_parse): '_get_ref': self._get_ref, 'comma_me': self.comma_me, 'format_date': self._get_and_change_date_format_for_swiss, + 'bvr_format': self._bvr_format, }) def _get_and_change_date_format_for_swiss (self,date_to_format): date_formatted='' - print date_to_format - if date_to_format: + if date_to_format and date_to_format != 'False': # happens: str(False) date_formatted = time.strptime(date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y') return date_formatted def comma_me(self,amount): + if amount is False or amount is None : + return '' if type(amount) is float : amount = str('%.2f'%amount) else : @@ -102,6 +104,15 @@ class account_invoice_bvr(report_sxw.rml_parse): invoice_number = re.sub('[^0-9]', '0', o.number) return mod10r(res + invoice_number.rjust(26-len(res), '0')) + def _bvr_format(self, o): + bvr_number = o.partner_bank_id.bvr_number + if (not bvr_number) or '-' not in bvr_number: + return '**** *******' # FIXME, what is the official "n/a" string, + # should we raise exception instead? + return bvr_number.split('-')[0] + \ + (str(bvr_number.split('-')[1])).rjust(6,'0') + \ + bvr_number.split('-')[2] + report_sxw.report_sxw( 'report.l10n_ch.bvr', 'account.invoice',