From dbc339825abd3127979cd712856524fe71f8bc70 Mon Sep 17 00:00:00 2001 From: Jorge Angel Naranjo Rogel Date: Fri, 26 Jul 2013 13:02:23 -0700 Subject: [PATCH 1/3] [IMP][account_financial_report] Validate vat for country for show in the report in the format Mexico and Venezuela. Added count of page in the report. --- .../report/balance_full.rml | 2 +- .../report/balance_full_13_cols.rml | 2 +- .../report/balance_full_2_cols.rml | 2 +- .../report/balance_full_4_cols.rml | 2 +- .../balance_full_4_cols_analytic_ledger.rml | 4 ++-- .../report/balance_full_5_cols.rml | 2 +- .../report/balance_full_qtr_cols.rml | 2 +- account_financial_report/report/parser.py | 20 +++++++++++++++++++ 8 files changed, 28 insertions(+), 8 deletions(-) diff --git a/account_financial_report/report/balance_full.rml b/account_financial_report/report/balance_full.rml index ff072615..4c100d9d 100644 --- a/account_financial_report/report/balance_full.rml +++ b/account_financial_report/report/balance_full.rml @@ -16,7 +16,7 @@ [[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]] - [[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]] + [[ get_vat_by_country(data['form']) ]] diff --git a/account_financial_report/report/balance_full_13_cols.rml b/account_financial_report/report/balance_full_13_cols.rml index 6a68b3e2..36b475da 100644 --- a/account_financial_report/report/balance_full_13_cols.rml +++ b/account_financial_report/report/balance_full_13_cols.rml @@ -17,7 +17,7 @@ [[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]] - [[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]] + [[ get_vat_by_country(data['form']) ]] diff --git a/account_financial_report/report/balance_full_2_cols.rml b/account_financial_report/report/balance_full_2_cols.rml index 86f8c54f..c8e07653 100644 --- a/account_financial_report/report/balance_full_2_cols.rml +++ b/account_financial_report/report/balance_full_2_cols.rml @@ -16,7 +16,7 @@ [[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]] - [[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]] + [[ get_vat_by_country(data['form']) ]] diff --git a/account_financial_report/report/balance_full_4_cols.rml b/account_financial_report/report/balance_full_4_cols.rml index 779b64ac..efd7219c 100644 --- a/account_financial_report/report/balance_full_4_cols.rml +++ b/account_financial_report/report/balance_full_4_cols.rml @@ -17,7 +17,7 @@ [[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]] - [[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]] + [[ get_vat_by_country(data['form']) ]] diff --git a/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml b/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml index 8852974f..478fe619 100644 --- a/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml +++ b/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml @@ -17,7 +17,7 @@ [[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]] - [[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]] + [[ get_vat_by_country(data['form']) ]] @@ -34,7 +34,7 @@ - Pag.: + Pag.: - diff --git a/account_financial_report/report/balance_full_5_cols.rml b/account_financial_report/report/balance_full_5_cols.rml index f29f7bdc..5a5342a5 100644 --- a/account_financial_report/report/balance_full_5_cols.rml +++ b/account_financial_report/report/balance_full_5_cols.rml @@ -17,7 +17,7 @@ [[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]] - [[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]] + [[ get_vat_by_country(data['form']) ]] diff --git a/account_financial_report/report/balance_full_qtr_cols.rml b/account_financial_report/report/balance_full_qtr_cols.rml index d2f8d01c..c806f0d8 100644 --- a/account_financial_report/report/balance_full_qtr_cols.rml +++ b/account_financial_report/report/balance_full_qtr_cols.rml @@ -17,7 +17,7 @@ [[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]] - [[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]] + [[ get_vat_by_country(data['form']) ]] diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 9963074a..b58749fd 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -59,8 +59,27 @@ class account_balance(report_sxw.rml_parse): 'get_informe_text': self.get_informe_text, 'get_month': self.get_month, 'exchange_name': self.exchange_name, + 'get_vat_by_country': self.get_vat_by_country, }) self.context = context + + + def get_vat_by_country(self, form): + """ + Return the vat of the partner by country + """ + rc_obj = self.pool.get('res.company') + country_code=rc_obj.browse(self.cr, self.uid, form['company_id'][0]).partner_id.country_id.code + string_vat= rc_obj.browse(self.cr, self.uid, form['company_id'][0]).partner_id.vat or '' + if string_vat: + if country_code=='MX': + return '%s' % (string_vat[2:]) + elif country_code=='VE': + return '- %s-%s-%s'%(string_vat[2:3],string_vat[3:11],string_vat[11:12]) + else: + return string_vat + else: + return _('\nVAT DE COMPANIA NO DISPONIBLE') def get_fiscalyear_text(self, form): """ @@ -250,6 +269,7 @@ class account_balance(report_sxw.rml_parse): ids2.append([aa_brw.id, True, True, aa_brw]) return ids2 + ############################################################################# # CONTEXT FOR ENDIND BALANCE # ####################################################################### From 163e9503d7acc3add1b279986e3da11a1867096f Mon Sep 17 00:00:00 2001 From: Jorge Angel Naranjo Rogel Date: Fri, 26 Jul 2013 13:18:27 -0700 Subject: [PATCH 2/3] [IMP][account_financial_report] Added traductions to VAT OF COMPANY NOT AVAILABLE --- account_financial_report/i18n/es.po | 8 ++++++++ account_financial_report/report/parser.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/account_financial_report/i18n/es.po b/account_financial_report/i18n/es.po index 81212bc3..c41b7c92 100644 --- a/account_financial_report/i18n/es.po +++ b/account_financial_report/i18n/es.po @@ -685,3 +685,11 @@ msgstr "12 Meses | YTD" msgid "Total" msgstr "Total" +#. module: account_financial_report +#: code:addons/account_financial_report/report/parser.py:82 +#, python-format +msgid "\n" +"VAT OF COMPANY NOT AVAILABLE" +msgstr "\n" +"VAT DE LA COMPAÑIA NO DISPONIBLE" + diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index b58749fd..c35e59a8 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -79,7 +79,7 @@ class account_balance(report_sxw.rml_parse): else: return string_vat else: - return _('\nVAT DE COMPANIA NO DISPONIBLE') + return _('\nVAT OF COMPANY NOT AVAILABLE') def get_fiscalyear_text(self, form): """ From d50ef4ef0bae7339c395fbc33dd547c996d3d2cb Mon Sep 17 00:00:00 2001 From: Jorge Angel Naranjo Rogel Date: Fri, 26 Jul 2013 15:03:23 -0700 Subject: [PATCH 3/3] [IMP][account_financial_report] Improvement function get_vat_by_country --- account_financial_report/report/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index c35e59a8..9ea487f2 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -69,7 +69,7 @@ class account_balance(report_sxw.rml_parse): Return the vat of the partner by country """ rc_obj = self.pool.get('res.company') - country_code=rc_obj.browse(self.cr, self.uid, form['company_id'][0]).partner_id.country_id.code + country_code=rc_obj.browse(self.cr, self.uid, form['company_id'][0]).partner_id.country_id.code or '' string_vat= rc_obj.browse(self.cr, self.uid, form['company_id'][0]).partner_id.vat or '' if string_vat: if country_code=='MX':