Browse Source

Merge pull request #352 from hbrunn/8.0-add-aged_partner_balance_xls

[8.0] [account_financial_report_webkit_xls] add aged partner balance & aged open invoices xls
pull/370/merge
Stefan Rijnhart (Opener) 6 years ago
committed by GitHub
parent
commit
fb8500469e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 69
      account_financial_report/report/parser.py
  2. 32
      account_financial_report/wizard/wizard.py
  3. 1
      account_financial_report_webkit/README.rst
  4. 2
      account_financial_report_webkit/__init__.py
  5. 4
      account_financial_report_webkit/__openerp__.py
  6. 2
      account_financial_report_webkit/data/financial_webkit_header.xml
  7. 35
      account_financial_report_webkit/hooks.py
  8. 22
      account_financial_report_webkit/models/account.py
  9. 1
      account_financial_report_webkit/models/account_move_line.py
  10. 1
      account_financial_report_webkit/report/aged_open_invoices.py
  11. 1
      account_financial_report_webkit/report/aged_partner_balance.py
  12. 2
      account_financial_report_webkit/report/common_balance_reports.py
  13. 2
      account_financial_report_webkit/report/common_partner_balance_reports.py
  14. 2
      account_financial_report_webkit/report/common_partner_reports.py
  15. 12
      account_financial_report_webkit/report/common_reports.py
  16. 3
      account_financial_report_webkit/report/general_ledger.py
  17. 14
      account_financial_report_webkit/report/open_invoices.py
  18. 4
      account_financial_report_webkit/report/partner_balance.py
  19. 7
      account_financial_report_webkit/report/partners_ledger.py
  20. 3
      account_financial_report_webkit/report/print_journal.py
  21. 3
      account_financial_report_webkit/report/trial_balance.py
  22. 3
      account_financial_report_webkit/report/webkit_parser_header_fix.py
  23. 11
      account_financial_report_webkit/tests/__init__.py
  24. 24
      account_financial_report_webkit/tests/test_aged_open_invoices.py
  25. 26
      account_financial_report_webkit/tests/test_aged_partner_balance.py
  26. 44
      account_financial_report_webkit/tests/test_common.py
  27. 23
      account_financial_report_webkit/tests/test_general_leger.py
  28. 27
      account_financial_report_webkit/tests/test_journal.py
  29. 24
      account_financial_report_webkit/tests/test_open_invoices.py
  30. 23
      account_financial_report_webkit/tests/test_partner_balance.py
  31. 23
      account_financial_report_webkit/tests/test_partner_ledger.py
  32. 23
      account_financial_report_webkit/tests/test_trial_balance.py
  33. 23
      account_financial_report_webkit/wizard/__init__.py
  34. 12
      account_financial_report_webkit/wizard/aged_open_invoices_wizard.py
  35. 1
      account_financial_report_webkit/wizard/aged_open_invoices_wizard.xml
  36. 74
      account_financial_report_webkit/wizard/aged_partner_balance_wizard.py
  37. 1
      account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml
  38. 78
      account_financial_report_webkit/wizard/balance_common.py
  39. 54
      account_financial_report_webkit/wizard/general_ledger_wizard.py
  40. 1
      account_financial_report_webkit/wizard/general_ledger_wizard_view.xml
  41. 28
      account_financial_report_webkit/wizard/open_invoices_wizard.py
  42. 1
      account_financial_report_webkit/wizard/open_invoices_wizard_view.xml
  43. 1
      account_financial_report_webkit/wizard/partner_balance_wizard.py
  44. 1
      account_financial_report_webkit/wizard/partner_balance_wizard_view.xml
  45. 48
      account_financial_report_webkit/wizard/partners_ledger_wizard.py
  46. 1
      account_financial_report_webkit/wizard/partners_ledger_wizard_view.xml
  47. 24
      account_financial_report_webkit/wizard/print_journal.py
  48. 1
      account_financial_report_webkit/wizard/print_journal_view.xml
  49. 8
      account_financial_report_webkit/wizard/trial_balance_wizard.py
  50. 1
      account_financial_report_webkit/wizard/trial_balance_wizard_view.xml
  51. 64
      account_financial_report_webkit_xls/README.rst
  52. 23
      account_financial_report_webkit_xls/__init__.py
  53. 49
      account_financial_report_webkit_xls/__openerp__.py
  54. 2
      account_financial_report_webkit_xls/report/__init__.py
  55. 281
      account_financial_report_webkit_xls/report/aged_open_invoices_xls.py
  56. 281
      account_financial_report_webkit_xls/report/aged_partner_balance_xls.py
  57. 8
      account_financial_report_webkit_xls/report/general_ledger_xls.py
  58. 6
      account_financial_report_webkit_xls/report/open_invoices_xls.py
  59. 8
      account_financial_report_webkit_xls/report/partner_ledger_xls.py
  60. 8
      account_financial_report_webkit_xls/report/partners_balance_xls.py
  61. 29
      account_financial_report_webkit_xls/report/trial_balance_xls.py
  62. 556
      account_financial_report_webkit_xls/static/description/icon.svg
  63. 0
      account_financial_report_webkit_xls/test/general_ledger.yml
  64. 0
      account_financial_report_webkit_xls/test/open_invoices.yml
  65. 0
      account_financial_report_webkit_xls/test/partner_balance.yml
  66. 0
      account_financial_report_webkit_xls/test/partner_ledger.yml
  67. 0
      account_financial_report_webkit_xls/test/trial_balance.yml
  68. 8
      account_financial_report_webkit_xls/tests/__init__.py
  69. 33
      account_financial_report_webkit_xls/tests/test_aged_open_invoices_xls.py
  70. 31
      account_financial_report_webkit_xls/tests/test_aged_partner_balance_xls.py
  71. 60
      account_financial_report_webkit_xls/tests/test_common_xls.py
  72. 28
      account_financial_report_webkit_xls/tests/test_general_leger_xls.py
  73. 29
      account_financial_report_webkit_xls/tests/test_open_invoices_xls.py
  74. 28
      account_financial_report_webkit_xls/tests/test_partner_balance_xls.py
  75. 28
      account_financial_report_webkit_xls/tests/test_partner_ledger_xls.py
  76. 28
      account_financial_report_webkit_xls/tests/test_trial_balance_xls.py
  77. 25
      account_financial_report_webkit_xls/wizard/__init__.py
  78. 27
      account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py
  79. 17
      account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.xml
  80. 27
      account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py
  81. 18
      account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml
  82. 35
      account_financial_report_webkit_xls/wizard/general_ledger_wizard.py
  83. 20
      account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml
  84. 35
      account_financial_report_webkit_xls/wizard/open_invoices_wizard.py
  85. 20
      account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml
  86. 35
      account_financial_report_webkit_xls/wizard/partners_balance_wizard.py
  87. 18
      account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml
  88. 43
      account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py
  89. 20
      account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml
  90. 35
      account_financial_report_webkit_xls/wizard/trial_balance_wizard.py
  91. 22
      account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml
  92. 2
      account_journal_report_xls/__init__.py
  93. 2
      account_journal_report_xls/__openerp__.py
  94. 11
      account_journal_report_xls/account_journal.py
  95. 16
      account_journal_report_xls/report/nov_account_journal.py
  96. 34
      account_journal_report_xls/report/nov_account_journal_xls.py
  97. 23
      account_journal_report_xls/wizard/__init__.py
  98. 48
      account_journal_report_xls/wizard/print_journal_wizard.py
  99. 10
      account_journal_report_xls/wizard/print_journal_wizard.xml

69
account_financial_report/report/parser.py

@ -165,10 +165,11 @@ class account_balance(report_sxw.rml_parse):
def exchange_name(self, form):
self.from_currency_id = self.\
get_company_currency(form['company_id']
and type(form['company_id']) in (list, tuple)
and form['company_id'][0]
or form['company_id'])
get_company_currency(
form['company_id'] and
type(form['company_id']) in (list, tuple) and
form['company_id'][0] or form['company_id']
)
if not form['currency_id']:
self.to_currency_id = self.from_currency_id
else:
@ -543,17 +544,18 @@ class account_balance(report_sxw.rml_parse):
self.context['state'] = form['target_move'] or 'posted'
self.from_currency_id = self.\
get_company_currency(form['company_id']
and type(form['company_id']) in (list, tuple)
and form['company_id'][0]
or form['company_id'])
get_company_currency(
form['company_id'] and
type(form['company_id']) in (list, tuple) and
form['company_id'][0] or form['company_id']
)
if not form['currency_id']:
self.to_currency_id = self.from_currency_id
else:
self.to_currency_id = form['currency_id'] \
and type(form['currency_id']) in (list, tuple) \
and form['currency_id'][0] \
or form['currency_id']
self.to_currency_id = form['currency_id'] and\
type(form['currency_id']) in (list, tuple) and\
form['currency_id'][0] or\
form['currency_id']
if 'account_list' in form and form['account_list']:
account_ids = form['account_list']
@ -561,16 +563,18 @@ class account_balance(report_sxw.rml_parse):
del form['account_list']
credit_account_ids = self.\
get_company_accounts(form['company_id']
and type(form['company_id']) in (list, tuple)
and form['company_id'][0]
or form['company_id'], 'credit')
get_company_accounts(
form['company_id'] and
type(form['company_id']) in (list, tuple) and
form['company_id'][0] or form['company_id'], 'credit'
)
debit_account_ids = self.\
get_company_accounts(form['company_id']
and type(form['company_id']) in (list, tuple)
and form['company_id'][0]
or form['company_id'], 'debit')
get_company_accounts(
form['company_id'] and
type(form['company_id']) in (list, tuple) and
form['company_id'][0] or form['company_id'], 'debit'
)
if form.get('fiscalyear'):
if type(form.get('fiscalyear')) in (list, tuple):
@ -587,9 +591,8 @@ class account_balance(report_sxw.rml_parse):
account_ids = _get_children_and_consol(
self.cr, self.uid, account_ids,
form['display_account_level']
and form['display_account_level']
or 100, self.context)
form['display_account_level'] and form['display_account_level'] or
100, self.context)
credit_account_ids = _get_children_and_consol(
self.cr, self.uid, credit_account_ids, 100, self.context,
@ -622,16 +625,16 @@ class account_balance(report_sxw.rml_parse):
('special', '=', False)],
order='date_start asc')
a = 0
l = []
l1 = []
p = []
for x in period_ids:
a += 1
if a < 3:
l.append(x)
l1.append(x)
else:
l.append(x)
p.append(l)
l = []
l1.append(x)
p.append(l1)
l1 = []
a = 0
tot_bal1 = 0.0
tot_bal2 = 0.0
@ -845,15 +848,14 @@ class account_balance(report_sxw.rml_parse):
'id': id,
'type': aa_id[3].type,
'code': aa_id[3].code,
'name': (aa_id[2] and not aa_id[1])
and 'TOTAL %s' % (aa_id[3].name.upper())
or aa_id[3].name,
'name': (aa_id[2] and not aa_id[1]) and
'TOTAL %s' % (aa_id[3].name.upper()) or aa_id[3].name,
'parent_id': aa_id[3].parent_id and aa_id[3].parent_id.id,
'level': aa_id[3].level,
'label': aa_id[1],
'total': aa_id[2],
'change_sign': credit_account_ids
and (id in credit_account_ids and -1 or 1) or 1
'change_sign': credit_account_ids and
(id in credit_account_ids and -1 or 1) or 1
}
if form['columns'] == 'qtr':
@ -1174,6 +1176,7 @@ class account_balance(report_sxw.rml_parse):
result_acc.append(res2)
return result_acc
report_sxw.report_sxw(
'report.afr.1cols',
'wizard.report',

32
account_financial_report/wizard/wizard.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
@ -25,13 +25,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##############################################################################
from openerp.osv import osv, fields
from openerp import _, fields, models
import time
from openerp.tools.translate import _
class wizard_report(osv.osv_memory):
class WizardReport(models.TransientModel):
_name = "wizard.report"
_columns = {
@ -208,20 +206,20 @@ class wizard_report(osv.osv_memory):
return res
afr_brw = self.pool.get('afr').browse(cr, uid, afr_id, context=context)
res['value'].update({
'currency_id': afr_brw.currency_id
and afr_brw.currency_id.id
or afr_brw.company_id.currency_id.id})
'currency_id': afr_brw.currency_id and afr_brw.currency_id.id or
afr_brw.company_id.currency_id.id,
})
res['value'].update({'inf_type': afr_brw.inf_type or 'BS'})
res['value'].update({'columns': afr_brw.columns or 'five'})
res['value'].update({
'display_account': afr_brw.display_account
or 'bal_mov'})
'display_account': afr_brw.display_account or 'bal_mov',
})
res['value'].update({
'display_account_level': afr_brw.
display_account_level or 0})
'display_account_level': afr_brw.display_account_level or 0
})
res['value'].update({
'fiscalyear': afr_brw.fiscalyear_id
and afr_brw.fiscalyear_id.id})
'fiscalyear': afr_brw.fiscalyear_id and afr_brw.fiscalyear_id.id
})
res['value'].update({'account_list': [
acc.id for acc in afr_brw.account_ids]})
res['value'].update({'periods': [p.id for p in afr_brw.period_ids]})
@ -270,8 +268,8 @@ class wizard_report(osv.osv_memory):
res = cr.dictfetchall()
if res:
if (data['form']['date_to'] > res[0]['date_stop']
or data['form']['date_from'] < res[0]['date_start']):
if data['form']['date_to'] > res[0]['date_stop'] or\
data['form']['date_from'] < res[0]['date_start']):
raise osv.except_osv(_('UserError'),
'Las fechas deben estar entre %s y %s'
% (res[0]['date_start'],
@ -369,5 +367,3 @@ class wizard_report(osv.osv_memory):
return {'type': 'ir.actions.report.xml',
'report_name': name,
'datas': data}
wizard_report()

1
account_financial_report_webkit/README.rst

@ -165,6 +165,7 @@ Contributors
* Nicolas Bessi
* Guewen Baconnier
* David Dufresne <david.dufresne@savoirfairelinux.com>
* Luc De Meyer <luc.demeyer@noviat.com>
Maintainer
----------

2
account_financial_report_webkit/__init__.py

@ -21,3 +21,5 @@
from . import models
from . import wizard
from . import report
from . import hooks
from .hooks import pre_init_hook

4
account_financial_report_webkit/__openerp__.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Authors: Nicolas Bessi, Guewen Baconnier
@ -57,7 +57,7 @@
'test/open_invoices.yml',
'test/aged_trial_balance.yml'],
# 'tests/account_move_line.yml'
'active': False,
'installable': True,
'application': True,
'pre_init_hook': 'pre_init_hook',
}

2
account_financial_report_webkit/data/financial_webkit_header.xml

@ -394,7 +394,7 @@ act_as_colgroup {
.account_level_consol {
font-weight: normal;
font-style: italic;
font-style: italic;
}
.overflow_ellipsis {

35
account_financial_report_webkit/hooks.py

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from .models.account_move_line import AccountMoveLine
def pre_init_hook(cr):
with cr.savepoint():
# don't break if column exists
cr.execute(
'alter table account_move_line add column last_rec_date date',
)
cr.execute(
'comment on column account_move_line.last_rec_date is %s',
(AccountMoveLine.last_rec_date.string,),
)
cr.execute(
'create index account_move_line_last_rec_date_index '
'on account_move_line (last_rec_date)',
)
# but still do the initialization
cr.execute(
"""update account_move_line
set last_rec_date=ml_fr.date
from account_move_line ml
left join account_move_reconcile fr on ml.reconcile_id=fr.id
join (
select
coalesce(reconcile_id, reconcile_partial_id) as reconcile_id,
max(date) as date
from account_move_line
group by coalesce(reconcile_id, reconcile_partial_id)
) ml_fr on ml_fr.reconcile_id=fr.id
where ml.id=account_move_line.id"""
)

22
account_financial_report_webkit/models/account.py

@ -27,21 +27,15 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from openerp import models, fields
from openerp.osv import fields, orm
class AccountAccount(orm.Model):
class AccountAccount(models.Model):
_inherit = 'account.account'
_columns = {
'centralized': fields.boolean(
'Centralized',
help="If flagged, no details will be displayed in "
"the General Ledger report (the webkit one only), "
"only centralized amounts per period."),
}
_defaults = {
'centralized': False,
}
centralized = fields.Boolean(
'Centralized', default=False,
help="If flagged, no details will be displayed in "
"the General Ledger report (the webkit one only), "
"only centralized amounts per period."
)

1
account_financial_report_webkit/models/account_move_line.py

@ -18,6 +18,7 @@ class AccountMoveLine(models.Model):
last_rec_date = fields.Date(
compute='_compute_last_rec_date',
store=True,
index=True,
string='Last reconciliation date',
help="The date of the last reconciliation (full or partial) "
"account move line."

1
account_financial_report_webkit/report/aged_open_invoices.py

@ -71,6 +71,7 @@ class AccountAgedOpenInvoicesWebkit(PartnersOpenInvoicesWebkit):
"""Compute Aged Open Invoices based on result of Open Invoices"""
# pylint: disable=old-api7-method-defined
def __init__(self, cursor, uid, name, context=None):
"""Constructor,
refer to :class:`openerp.report.report_sxw.rml_parse`"""

1
account_financial_report_webkit/report/aged_partner_balance.py

@ -69,6 +69,7 @@ class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit):
"""Compute Aged Partner Balance based on result of Open Invoices"""
# pylint: disable=old-api7-method-defined
def __init__(self, cursor, uid, name, context=None):
"""Constructor,
refer to :class:`openerp.report.report_sxw.rml_parse`"""

2
account_financial_report_webkit/report/common_balance_reports.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier

2
account_financial_report_webkit/report/common_partner_balance_reports.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier

2
account_financial_report_webkit/report/common_partner_reports.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Guewen Baconnier

12
account_financial_report_webkit/report/common_reports.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Guewen Baconnier
@ -24,7 +24,7 @@
import logging
from openerp.osv import osv
from openerp.exceptions import except_orm
from openerp.tools.translate import _
from openerp.addons.account.report.common_report_header \
import common_report_header
@ -361,7 +361,7 @@ class CommonReportHeaderWebkit(common_report_header):
limit=1,
order='date_start %s' % (order,))
if not p_id:
raise osv.except_osv(_('No period found'), '')
raise except_orm(_('No period found'), '')
return period_obj.browse(self.cursor, self.uid, p_id[0])
###############################
@ -404,7 +404,7 @@ class CommonReportHeaderWebkit(common_report_header):
opening_period_selected = self.get_included_opening_period(
start_period)
if not opening_period_selected:
raise osv.except_osv(
raise except_orm(
_('Error'),
_('No opening period found to compute the opening balances.\n'
'You have to configure a period on the first of January'
@ -490,7 +490,7 @@ class CommonReportHeaderWebkit(common_report_header):
target_move, mode='include_opening'):
"""Get account move lines base on form data"""
if mode not in ('include_opening', 'exclude_opening'):
raise osv.except_osv(
raise except_orm(
_('Invalid query mode'),
_('Must be in include_opening, exclude_opening'))
@ -502,7 +502,7 @@ class CommonReportHeaderWebkit(common_report_header):
return self._get_move_ids_from_dates(account_id, start, stop,
target_move)
else:
raise osv.except_osv(
raise except_orm(
_('No valid filter'), _('Please set a valid time filter'))
def _get_move_line_datas(self, move_line_ids,

3
account_financial_report_webkit/report/general_ledger.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Guewen Baconnier
@ -32,6 +32,7 @@ from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
# pylint: disable=old-api7-method-defined
def __init__(self, cursor, uid, name, context):
super(GeneralLedgerWebkit, self).__init__(
cursor, uid, name, context=context)

14
account_financial_report_webkit/report/open_invoices.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Guewen Baconnier
@ -27,7 +27,7 @@ from mako.template import Template
from openerp.modules.registry import RegistryManager
from openerp.osv import osv
from openerp.exceptions import except_orm
from openerp.report import report_sxw
from openerp.tools.translate import _
from openerp.addons.report_webkit import report_helper
@ -46,7 +46,7 @@ report_helper.WebKitHelper.get_mako_template = get_mako_template
class PartnersOpenInvoicesWebkit(report_sxw.rml_parse,
CommonPartnersReportHeaderWebkit):
# pylint: disable=old-api7-method-defined
def __init__(self, cursor, uid, name, context):
super(PartnersOpenInvoicesWebkit, self).__init__(
cursor, uid, name, context=context)
@ -136,7 +136,7 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse,
new_ids, exclude_type=['view'], only_type=filter_type)
if not account_ids:
raise osv.except_osv(_('Error'), _('No accounts to print.'))
raise except_orm(_('Error'), _('No accounts to print.'))
# computation of ledeger lines
if main_filter == 'filter_date':
@ -213,9 +213,9 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse,
date_until_match = (stop == date_until)
else:
raise osv.except_osv(_('Unsuported filter'),
_('Filter has to be in filter date, period, \
or none'))
raise except_orm(
_('Unsuported filter'),
_('Filter has to be in filter date, period, or none'))
initial_move_lines_per_account = {}
if main_filter in ('filter_period', 'filter_no'):

4
account_financial_report_webkit/report/partner_balance.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier
@ -32,7 +32,7 @@ from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
class PartnerBalanceWebkit(report_sxw.rml_parse,
CommonPartnerBalanceReportHeaderWebkit):
# pylint: disable=old-api7-method-defined
def __init__(self, cursor, uid, name, context):
super(PartnerBalanceWebkit, self).__init__(
cursor, uid, name, context=context)

7
account_financial_report_webkit/report/partners_ledger.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Guewen Baconnier
@ -23,7 +23,7 @@ from collections import defaultdict
from datetime import datetime
from openerp.modules.registry import RegistryManager
from openerp.osv import osv
from openerp.exceptions import except_orm
from openerp.report import report_sxw
from openerp.tools.translate import _
from .common_partner_reports import CommonPartnersReportHeaderWebkit
@ -33,6 +33,7 @@ from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
class PartnersLedgerWebkit(report_sxw.rml_parse,
CommonPartnersReportHeaderWebkit):
# pylint: disable=old-api7-method-defined
def __init__(self, cursor, uid, name, context):
super(PartnersLedgerWebkit, self).__init__(
cursor, uid, name, context=context)
@ -118,7 +119,7 @@ class PartnersLedgerWebkit(report_sxw.rml_parse,
only_type=filter_type)
if not accounts:
raise osv.except_osv(_('Error'), _('No accounts to print.'))
raise except_orm(_('Error'), _('No accounts to print.'))
if main_filter == 'filter_date':
start = start_date

3
account_financial_report_webkit/report/print_journal.py

@ -34,6 +34,7 @@ from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
# pylint: disable=old-api7-method-defined
def __init__(self, cursor, uid, name, context):
super(PrintJournalWebkit, self).__init__(cursor, uid, name,
context=context)
@ -165,5 +166,3 @@ HeaderFooterTextWebKitParser(
'addons/account_financial_report_webkit/report/templates/\
account_report_print_journal.mako',
parser=PrintJournalWebkit)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

3
account_financial_report_webkit/report/trial_balance.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier
@ -36,6 +36,7 @@ def sign(number):
class TrialBalanceWebkit(report_sxw.rml_parse,
CommonBalanceReportHeaderWebkit):
# pylint: disable=old-api7-method-defined
def __init__(self, cursor, uid, name, context):
super(TrialBalanceWebkit, self).__init__(cursor, uid, name,
context=context)

3
account_financial_report_webkit/report/webkit_parser_header_fix.py

@ -38,7 +38,7 @@ from functools import partial
from mako import exceptions
from openerp.osv.orm import except_orm
from openerp.exceptions import except_orm
from openerp.tools.translate import _
from openerp.modules.registry import RegistryManager
from openerp import tools
@ -182,6 +182,7 @@ class HeaderFooterTextWebKitParser(webkit_report.WebKitParser):
return pdf
# override needed to keep the attachments' storing procedure
# pylint: disable=old-api7-method-defined
def create_single_pdf(self, cursor, uid, ids, data, report_xml,
context=None):
"""generate the PDF"""

11
account_financial_report_webkit/tests/__init__.py

@ -1,5 +1,10 @@
# -*- coding: utf-8 -*-
# © 2016 Savoir-faire Linux
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_account_move_line
from . import test_general_leger
from . import test_partner_ledger
from . import test_trial_balance
from . import test_partner_balance
from . import test_open_invoices
from . import test_aged_open_invoices
from . import test_aged_partner_balance
from . import test_journal

24
account_financial_report_webkit/tests/test_aged_open_invoices.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import datetime
from .test_common import TestCommon
class TestOpenInvoices(TestCommon):
def _getReportModel(self):
return 'aged.open.invoices.webkit'
def _getReportName(self):
return 'account.account_aged_open_invoices_webkit'
def _getBaseFilters(self):
return {'until_date': '%s-12-31' % (datetime.now().year)}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

26
account_financial_report_webkit/tests/test_aged_partner_balance.py

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common import TestCommon
class TestAgedPartnerBalance(TestCommon):
def _getReportModel(self):
return 'account.aged.trial.balance.webkit'
def _getReportName(self):
return 'account.account_aged_trial_balance_webkit'
def _getBaseFilters(self):
fy_id = self.model._get_current_fiscalyear()
vals = self.model.onchange_fiscalyear(fiscalyear=fy_id)['value']
vals.update({'fiscalyear_id': fy_id})
return vals
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

44
account_financial_report_webkit/tests/test_common.py

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.tests.common import TransactionCase
class TestCommon(TransactionCase):
""" Common tests for all reports """
def setUp(self):
super(TestCommon, self).setUp()
self.model = self.env[self._getReportModel()]
self.report_name = self._getReportName()
wiz_vals = {'chart_account_id': self.env.ref('account.chart0').id}
wiz_vals.update(self._getBaseFilters())
self.report = self.model.create(wiz_vals)
def common_test_01_generation_report(self):
""" Check if report is correctly generated """
# Check if returned report action is correct
report_action = self.report.check_report()
self.assertDictContainsSubset(
{'type': 'ir.actions.report.xml',
'report_name': self.report_name},
report_action)
def _getReportModel(self):
"""
:return: the report model name
"""
raise NotImplementedError()
def _getReportName(self):
"""
:return: the xls report name
"""
raise NotImplementedError()
def _getBaseFilters(self):
"""
:return: the minimum required filters to generate report
"""
raise NotImplementedError()

23
account_financial_report_webkit/tests/test_general_leger.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common import TestCommon
class TestGeneralLedger(TestCommon):
def _getReportModel(self):
return 'general.ledger.webkit'
def _getReportName(self):
return 'account.account_report_general_ledger_webkit'
def _getBaseFilters(self):
return {}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

27
account_financial_report_webkit/tests/test_journal.py

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common import TestCommon
class TestGeneralLedger(TestCommon):
def _getReportModel(self):
return 'print.journal.webkit'
def _getReportName(self):
return 'account.account_report_print_journal_webkit'
def _getBaseFilters(self):
fy_id = self.model._get_fiscalyear()
vals = self.model.onchange_filter(
filter='filter_period', fiscalyear_id=fy_id)['value']
vals.update({'fiscalyear_id': fy_id})
return vals
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

24
account_financial_report_webkit/tests/test_open_invoices.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import datetime
from .test_common import TestCommon
class TestOpenInvoices(TestCommon):
def _getReportModel(self):
return 'open.invoices.webkit'
def _getReportName(self):
return 'account.account_report_open_invoices_webkit'
def _getBaseFilters(self):
return {'until_date': '%s-12-31' % (datetime.now().year)}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

23
account_financial_report_webkit/tests/test_partner_balance.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common import TestCommon
class TestPartnerBalance(TestCommon):
def _getReportModel(self):
return 'partner.balance.webkit'
def _getReportName(self):
return 'account.account_report_partner_balance_webkit'
def _getBaseFilters(self):
return {}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

23
account_financial_report_webkit/tests/test_partner_ledger.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common import TestCommon
class TestPartnerLedger(TestCommon):
def _getReportModel(self):
return 'partners.ledger.webkit'
def _getReportName(self):
return 'account.account_report_partners_ledger_webkit'
def _getBaseFilters(self):
return {}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

23
account_financial_report_webkit/tests/test_trial_balance.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common import TestCommon
class TestTrialBalance(TestCommon):
def _getReportModel(self):
return 'trial.balance.webkit'
def _getReportName(self):
return 'account.account_report_trial_balance_webkit'
def _getBaseFilters(self):
return {}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

23
account_financial_report_webkit/wizard/__init__.py

@ -1,25 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi. Copyright Camptocamp SA
# Copyright (C) 2012 SYLEAM Info Services (<http://www.syleam.fr/>)
# Sebastien LANGE <sebastien.lange@syleam.fr>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
from . import balance_common
from . import general_ledger_wizard
from . import partners_ledger_wizard

12
account_financial_report_webkit/wizard/aged_open_invoices_wizard.py

@ -19,24 +19,23 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
from openerp.osv import orm
class AgedOpenInvoice(orm.TransientModel):
class AgedOpenInvoice(models.TransientModel):
"""Will launch age partner balance report.
This report is based on Open Invoice Report
and share a lot of knowledge with him
"""
# pylint: disable=consider-merging-classes-inherited
_inherit = "open.invoices.webkit"
_name = "aged.open.invoices.webkit"
_description = "Aged open invoices"
_defaults = {
'filter': 'filter_date',
}
filter = fields.Selection(default='filter_date')
# pylint: disable=old-api7-method-defined
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False,
period_id=False, date_to=False, until_date=False,
context=None):
@ -53,6 +52,7 @@ class AgedOpenInvoice(orm.TransientModel):
})
return res
# pylint: disable=old-api7-method-defined
def _print_report(self, cr, uid, ids, data, context=None):
# we update form with display account value
data = self.pre_print_report(cr, uid, ids, data, context=context)

1
account_financial_report_webkit/wizard/aged_open_invoices_wizard.xml

@ -5,6 +5,7 @@
<record id="aged_open_invoice_webkit" model="ir.ui.view">
<field name="name">Aged Open Invoice Report</field>
<field name="model">aged.open.invoices.webkit</field>
<field name="priority">99</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<data>

74
account_financial_report_webkit/wizard/aged_partner_balance_wizard.py

@ -1,29 +1,10 @@
# -*- 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from datetime import date
from openerp.osv import orm, fields
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DATE_FORMAT
# Copyright 2014 Camptocamp SA, Nicolas Bessi.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields
class AccountAgedTrialBalance(orm.TransientModel):
class AccountAgedTrialBalance(models.TransientModel):
"""Will launch age partner balance report.
This report is based on Open Invoice Report
and share a lot of knowledge with him
@ -33,39 +14,21 @@ class AccountAgedTrialBalance(orm.TransientModel):
_name = "account.aged.trial.balance.webkit"
_description = "Aged partner balanced"
# pylint: disable=old-api7-method-defined
def _get_current_fiscalyear(self, cr, uid, context=None):
user_obj = self.pool['res.users']
company = user_obj.browse(cr, uid, uid, context=context).company_id
fyear_obj = self.pool['account.period']
today = date.today().strftime(DATE_FORMAT)
fyear_ids = fyear_obj.search(
cr, uid,
[('date_start', '>=', today),
('date_stop', '<=', today),
('company_id', '=', company.id)],
limit=1,
context=context)
if fyear_ids:
return fyear_ids[0]
_columns = {
'filter': fields.selection(
[('filter_period', 'Periods')],
"Filter by",
required=True),
'fiscalyear_id': fields.many2one(
'account.fiscalyear',
'Fiscal Year',
required=True),
'period_to': fields.many2one('account.period', 'End Period',
required=True),
}
_defaults = {
'filter': 'filter_period',
'fiscalyear_id': _get_current_fiscalyear,
}
return self.pool['account.fiscalyear'].find(cr, uid, context=context)
filter = fields.Selection(
[('filter_period', 'Periods')], "Filter by", required=True,
default='filter_period'
)
fiscalyear_id = fields.Many2one(
'account.fiscalyear', 'Fiscal Year', required=True,
default=lambda self: self._get_current_fiscalyear()
)
period_to = fields.Many2one('account.period', 'End Period', required=True)
# pylint: disable=old-api7-method-defined
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False,
period_id=False, date_to=False, until_date=False,
context=None):
@ -82,6 +45,7 @@ class AccountAgedTrialBalance(orm.TransientModel):
})
return res
# pylint: disable=old-api7-method-defined
def _print_report(self, cr, uid, ids, data, context=None):
# we update form with display account value
data = self.pre_print_report(cr, uid, ids, data, context=context)

1
account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml

@ -5,6 +5,7 @@
<record id="account_aged_trial_balance_webkit" model="ir.ui.view">
<field name="name">Aged Partner Balance Report</field>
<field name="model">account.aged.trial.balance.webkit</field>
<field name="priority">99</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<data>

78
account_financial_report_webkit/wizard/balance_common.py

@ -32,8 +32,10 @@ import time
from lxml import etree
from datetime import datetime
from openerp.osv import fields, orm
from openerp import fields, models
from openerp.tools.translate import _
# pylint: disable=deprecated-module
from openerp.osv.orm import setup_modifiers
def previous_year_date(date, nb_prev=1):
@ -46,10 +48,11 @@ def previous_year_date(date, nb_prev=1):
return previous_date
class AccountBalanceCommonWizard(orm.TransientModel):
class AccountBalanceCommonWizard(models.TransientModel):
"""Will launch trial balance report and pass required args"""
# pylint: disable=consider-merging-classes-inherited
_inherit = "account.common.account.report"
_name = "account.common.balance.report"
_description = "Common Balance Report"
@ -74,6 +77,7 @@ class AccountBalanceCommonWizard(orm.TransientModel):
for index in range(COMPARISON_LEVEL)]
DYNAMIC_FIELDS = M2O_DYNAMIC_FIELDS + SIMPLE_DYNAMIC_FIELDS
# pylint: disable=old-api7-method-defined
def _get_account_ids(self, cr, uid, context=None):
res = False
if context.get('active_model', False) == 'account.account' \
@ -81,48 +85,47 @@ class AccountBalanceCommonWizard(orm.TransientModel):
res = context['active_ids']
return res
_columns = {
'account_ids': fields.many2many(
'account.account', string='Filter on accounts',
help="Only selected accounts will be printed. Leave empty to \
print all accounts."),
'filter': fields.selection(
[('filter_no', 'No Filters'),
('filter_date', 'Date'),
('filter_period', 'Periods'),
('filter_opening', 'Opening Only')],
"Filter by",
required=True,
help='Filter by date: no opening balance will be displayed. '
'(opening balance can only be computed based on period to be \
correct).'),
# Set statically because of the impossibility of changing the selection
# field when changing chart_account_id
'account_level': fields.selection(
[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'),
('6', '6')], string="Account level"),
}
account_ids = fields.Many2many(
'account.account', string='Filter on accounts',
help="Only selected accounts will be printed. Leave empty to \
print all accounts.", default=lambda self: self._get_account_ids(),
)
filter = fields.Selection(
[('filter_no', 'No Filters'),
('filter_date', 'Date'),
('filter_period', 'Periods'),
('filter_opening', 'Opening Only')],
"Filter by", required=True,
help='Filter by date: no opening balance will be displayed. '
'(opening balance can only be computed based on period to be \
correct).'
)
# Set statically because of the impossibility of changing the selection
# field when changing chart_account_id
account_level = fields.Selection(
[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'),
('6', '6')], string="Account level"
)
# pylint: disable=attribute-deprecated
_columns = {}
for index in range(COMPARISON_LEVEL):
_columns.update(
{"comp%s_filter" % index:
fields.selection(
fields.fields.selection(
COMPARE_SELECTION, string='Compare By', required=True),
"comp%s_fiscalyear_id" % index:
fields.many2one('account.fiscalyear', 'Fiscal Year'),
fields.fields.many2one('account.fiscalyear', 'Fiscal Year'),
"comp%s_period_from" % index:
fields.many2one('account.period', 'Start Period'),
fields.fields.many2one('account.period', 'Start Period'),
"comp%s_period_to" % index:
fields.many2one('account.period', 'End Period'),
fields.fields.many2one('account.period', 'End Period'),
"comp%s_date_from" % index:
fields.date("Start Date"),
fields.fields.date("Start Date"),
"comp%s_date_to" % index:
fields.date("End Date")})
_defaults = {
'account_ids': _get_account_ids,
}
fields.fields.date("End Date")})
# pylint: disable=old-api7-method-defined
def _check_fiscalyear(self, cr, uid, ids, context=None):
obj = self.read(
cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
@ -136,6 +139,7 @@ class AccountBalanceCommonWizard(orm.TransientModel):
periods or by date.', ['filter']),
]
# pylint: disable=old-api7-method-defined
def default_get(self, cr, uid, fields, context=None):
"""
To get default values for the object.
@ -157,6 +161,7 @@ class AccountBalanceCommonWizard(orm.TransientModel):
res[field] = 'filter_no'
return res
# pylint: disable=old-api7-method-defined
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
res = super(AccountBalanceCommonWizard, self).fields_view_get(
@ -180,7 +185,7 @@ class AccountBalanceCommonWizard(orm.TransientModel):
page.append(group)
def modifiers_and_append(elem):
orm.setup_modifiers(elem)
setup_modifiers(elem)
group.append(elem)
modifiers_and_append(etree.Element(
@ -244,6 +249,7 @@ class AccountBalanceCommonWizard(orm.TransientModel):
res['arch'] = etree.tostring(eview)
return res
# pylint: disable=old-api7-method-defined
def onchange_filter(self, cr, uid, ids, filter='filter_no',
fiscalyear_id=False, context=None):
res = {}
@ -296,6 +302,7 @@ class AccountBalanceCommonWizard(orm.TransientModel):
end_period, 'date_from': False, 'date_to': False}
return res
# pylint: disable=old-api7-method-defined
def onchange_comp_filter(self, cr, uid, ids, index,
main_filter='filter_no', comp_filter='filter_no',
fiscalyear_id=False, start_date=False,
@ -390,6 +397,7 @@ class AccountBalanceCommonWizard(orm.TransientModel):
date_to_field: False}
return res
# pylint: disable=old-api7-method-defined
def pre_print_report(self, cr, uid, ids, data, context=None):
data = super(AccountBalanceCommonWizard, self).pre_print_report(
cr, uid, ids, data, context=context)

54
account_financial_report_webkit/wizard/general_ledger_wizard.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Guewen Baconnier
@ -20,11 +20,10 @@
##############################################################################
import time
from openerp import models, fields
from openerp.osv import fields, orm
class AccountReportGeneralLedgerWizard(orm.TransientModel):
class AccountReportGeneralLedgerWizard(models.TransientModel):
"""Will launch general ledger report and pass required args"""
@ -32,6 +31,7 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
_name = "general.ledger.webkit"
_description = "General Ledger Report"
# pylint: disable=old-api7-method-defined
def _get_account_ids(self, cr, uid, context=None):
res = False
if context.get('active_model', False) == 'account.account' \
@ -39,30 +39,27 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
res = context['active_ids']
return res
_columns = {
'amount_currency': fields.boolean("With Currency",
help="It adds the currency column"),
'display_account': fields.selection(
[('bal_all', 'All'),
('bal_mix', 'With transactions or non zero balance')],
'Display accounts',
required=True),
'account_ids': fields.many2many(
'account.account', string='Filter on accounts',
help="""Only selected accounts will be printed. Leave empty to
print all accounts."""),
'centralize': fields.boolean(
'Activate Centralization',
help='Uncheck to display all the details of centralized accounts.')
}
_defaults = {
'amount_currency': False,
'display_account': 'bal_mix',
'account_ids': _get_account_ids,
'centralize': True,
}
amount_currency = fields.Boolean(
"With Currency", help="It adds the currency column", default=False,
)
display_account = fields.Selection(
[
('bal_all', 'All'),
('bal_mix', 'With transactions or non zero balance')
],
'Display accounts', required=True, default='bal_mix',
)
account_ids = fields.Many2many(
'account.account', string='Filter on accounts',
help="Only selected accounts will be printed. Leave empty to "
"print all accounts.", default=lambda self: self._get_account_ids(),
)
centralize = fields.Boolean(
'Activate Centralization', default=True,
help='Uncheck to display all the details of centralized accounts.',
)
# pylint: disable=old-api7-method-defined
def _check_fiscalyear(self, cr, uid, ids, context=None):
obj = self.read(
cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
@ -76,6 +73,7 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
periods or by date.', ['filter']),
]
# pylint: disable=old-api7-method-defined
def pre_print_report(self, cr, uid, ids, data, context=None):
data = super(AccountReportGeneralLedgerWizard, self).pre_print_report(
cr, uid, ids, data, context=context)
@ -90,6 +88,7 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
data['form'].update(vals)
return data
# pylint: disable=old-api7-method-defined
def onchange_filter(self, cr, uid, ids, filter='filter_no',
fiscalyear_id=False, context=None):
res = {}
@ -148,6 +147,7 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
end_period, 'date_from': False, 'date_to': False}
return res
# pylint: disable=old-api7-method-defined
def _print_report(self, cursor, uid, ids, data, context=None):
# we update form with display account value
data = self.pre_print_report(cursor, uid, ids, data, context=context)

1
account_financial_report_webkit/wizard/general_ledger_wizard_view.xml

@ -5,6 +5,7 @@
<record id="account_report_general_ledger_view_webkit" model="ir.ui.view">
<field name="name">General Ledger</field>
<field name="model">general.ledger.webkit</field>
<field name="priority">99</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<data>

28
account_financial_report_webkit/wizard/open_invoices_wizard.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier
@ -18,10 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import fields, orm
from openerp import models, fields
class AccountReportOpenInvoicesWizard(orm.TransientModel):
class AccountReportOpenInvoicesWizard(models.TransientModel):
"""Will launch partner ledger report and pass required args"""
@ -29,13 +29,11 @@ class AccountReportOpenInvoicesWizard(orm.TransientModel):
_name = "open.invoices.webkit"
_description = "Open Invoices Report"
_columns = {
'group_by_currency': fields.boolean('Group Partner by currency'),
'until_date': fields.date(
"Clearance date",
required=True,
help="""The clearance date is essentially a tool used for debtors
provisionning calculation.
group_by_currency = fields.Boolean('Group Partner by currency')
until_date = fields.Date(
"Clearance date", required=True,
help="""The clearance date is essentially a tool used for debtors
provisionning calculation.
By default, this date is equal to the the end date (ie: 31/12/2011 if you
select fy 2011).
@ -43,8 +41,9 @@ select fy 2011).
By amending the clearance date, you will be, for instance, able to answer the
question : 'based on my last year end debtors open invoices, which invoices
are still unpaid today (today is my clearance date)?'
""")}
""")
# pylint: disable=old-api7-method-defined
def _check_until_date(self, cr, uid, ids, context=None):
def get_key_id(obj, field):
return obj.get(field) and obj[field][0] or False
@ -66,6 +65,7 @@ are still unpaid today (today is my clearance date)?'
last period or later.', ['until_date']),
]
# pylint: disable=old-api7-method-defined
def default_until_date(self, cr, uid, ids, fiscalyear_id=False,
period_id=False, date_to=False, context=None):
res_date = False
@ -82,6 +82,7 @@ are still unpaid today (today is my clearance date)?'
context=context)['date_stop']
return res_date
# pylint: disable=old-api7-method-defined
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False,
period_id=False, date_to=False, until_date=False,
context=None):
@ -94,6 +95,7 @@ are still unpaid today (today is my clearance date)?'
context=context)
return res
# pylint: disable=old-api7-method-defined
def onchange_date_to(self, cr, uid, ids, fiscalyear=False, period_id=False,
date_to=False, until_date=False, context=None):
res = {'value': {}}
@ -105,6 +107,7 @@ are still unpaid today (today is my clearance date)?'
context=context)
return res
# pylint: disable=old-api7-method-defined
def onchange_period_to(self, cr, uid, ids, fiscalyear=False,
period_id=False, date_to=False, until_date=False,
context=None):
@ -117,6 +120,7 @@ are still unpaid today (today is my clearance date)?'
context=context)
return res
# pylint: disable=old-api7-method-defined
def onchange_filter(self, cr, uid, ids, filter='filter_no',
fiscalyear_id=False, context=None):
res = super(AccountReportOpenInvoicesWizard, self).onchange_filter(
@ -131,6 +135,7 @@ are still unpaid today (today is my clearance date)?'
context=context)
return res
# pylint: disable=old-api7-method-defined
def pre_print_report(self, cr, uid, ids, data, context=None):
data = super(AccountReportOpenInvoicesWizard, self).pre_print_report(
cr, uid, ids, data, context=context)
@ -140,6 +145,7 @@ are still unpaid today (today is my clearance date)?'
data['form'].update(vals)
return data
# pylint: disable=old-api7-method-defined
def _print_report(self, cr, uid, ids, data, context=None):
# we update form with display account value
data = self.pre_print_report(cr, uid, ids, data, context=context)

1
account_financial_report_webkit/wizard/open_invoices_wizard_view.xml

@ -5,6 +5,7 @@
<record id="account_open_invoices_view_webkit" model="ir.ui.view">
<field name="name">Open Invoices Report</field>
<field name="model">open.invoices.webkit</field>
<field name="priority">99</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<data>

1
account_financial_report_webkit/wizard/partner_balance_wizard.py

@ -9,6 +9,7 @@ class AccountPartnerBalanceWizard(models.TransientModel):
"""Will launch partner balance report and pass required args"""
# pylint: disable=consider-merging-classes-inherited
_inherit = "account.common.balance.report"
_name = "partner.balance.webkit"
_description = "Partner Balance Report"

1
account_financial_report_webkit/wizard/partner_balance_wizard_view.xml

@ -9,6 +9,7 @@
<record id="account_partner_balance_view_webkit" model="ir.ui.view">
<field name="name">Partner Balance</field>
<field name="model">partner.balance.webkit</field>
<field name="priority">99</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<data>

48
account_financial_report_webkit/wizard/partners_ledger_wizard.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Guewen Baconnier
@ -19,11 +19,10 @@
#
##############################################################################
import time
from openerp import models, fields
from openerp.osv import fields, orm
class AccountReportPartnersLedgerWizard(orm.TransientModel):
class AccountReportPartnersLedgerWizard(models.TransientModel):
"""Will launch partner ledger report and pass required args"""
@ -31,27 +30,25 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel):
_name = "partners.ledger.webkit"
_description = "Partner Ledger Report"
_columns = {
'amount_currency': fields.boolean("With Currency",
help="It adds the currency column"),
'partner_ids': fields.many2many(
'res.partner',
string='Filter on partner',
help="Only selected partners will be printed. "
"Leave empty to print all partners."),
'filter': fields.selection(
[('filter_no', 'No Filters'),
('filter_date', 'Date'),
('filter_period', 'Periods')], "Filter by", required=True,
help='Filter by date: no opening balance will be displayed. '
'(opening balance can only be computed based on period to be \
correct).'),
}
_defaults = {
'amount_currency': False,
'result_selection': 'customer_supplier',
}
amount_currency = fields.Boolean(
"With Currency", help="It adds the currency column", default=False,
)
partner_ids = fields.Many2many(
'res.partner', string='Filter on partner',
help="Only selected partners will be printed. Leave empty to print "
"all partners."
)
filter = fields.Selection(
[('filter_no', 'No Filters'),
('filter_date', 'Date'),
('filter_period', 'Periods')], "Filter by", required=True,
help='Filter by date: no opening balance will be displayed. '
'(opening balance can only be computed based on period to be '
'correct).',
)
result_selection = fields.Selection(default='customer_supplier')
# pylint: disable=old-api7-method-defined
def _check_fiscalyear(self, cr, uid, ids, context=None):
obj = self.read(
cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
@ -66,6 +63,7 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel):
['filter']),
]
# pylint: disable=old-api7-method-defined
def onchange_filter(self, cr, uid, ids, filter='filter_no',
fiscalyear_id=False, context=None):
res = {}
@ -119,6 +117,7 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel):
end_period, 'date_from': False, 'date_to': False}
return res
# pylint: disable=old-api7-method-defined
def pre_print_report(self, cr, uid, ids, data, context=None):
data = super(AccountReportPartnersLedgerWizard, self).pre_print_report(
cr, uid, ids, data, context=context)
@ -132,6 +131,7 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel):
data['form'].update(vals)
return data
# pylint: disable=old-api7-method-defined
def _print_report(self, cursor, uid, ids, data, context=None):
# we update form with display account value
data = self.pre_print_report(cursor, uid, ids, data, context=context)

1
account_financial_report_webkit/wizard/partners_ledger_wizard_view.xml

@ -5,6 +5,7 @@
<record id="account_partner_ledger_view_webkit" model="ir.ui.view">
<field name="name">Partner Ledger</field>
<field name="model">partners.ledger.webkit</field>
<field name="priority">99</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<data>

24
account_financial_report_webkit/wizard/print_journal.py

@ -21,30 +21,25 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import fields, orm
from openerp import models, fields
import time
class AccountReportPrintJournalWizard(orm.TransientModel):
class AccountReportPrintJournalWizard(models.TransientModel):
"""Will launch print journal report and pass requiered args"""
# pylint: disable=consider-merging-classes-inherited
_inherit = "account.common.account.report"
_name = "print.journal.webkit"
_description = "Journals Report"
_columns = {
'amount_currency': fields.boolean("With Currency",
help="It adds the currency column"),
}
_defaults = {
'amount_currency': False,
'journal_ids': False,
'filter': 'filter_period',
}
amount_currency = fields.Boolean(
"With Currency", default=False, help="It adds the currency column",
)
filter = fields.Selection(default='filter_period')
# pylint: disable=old-api7-method-defined
def _check_fiscalyear(self, cr, uid, ids, context=None):
obj = self.read(cr, uid, ids[0], ['fiscalyear_id', 'filter'],
context=context)
@ -57,6 +52,7 @@ class AccountReportPrintJournalWizard(orm.TransientModel):
to filter by periods or by date.', ['filter']),
]
# pylint: disable=old-api7-method-defined
def pre_print_report(self, cr, uid, ids, data, context=None):
data = super(AccountReportPrintJournalWizard, self).\
pre_print_report(cr, uid, ids, data, context=context)
@ -70,6 +66,7 @@ class AccountReportPrintJournalWizard(orm.TransientModel):
data['form'].update(vals)
return data
# pylint: disable=old-api7-method-defined
def onchange_filter(self, cr, uid, ids, filter='filter_no',
fiscalyear_id=False, context=None):
res = {}
@ -122,6 +119,7 @@ class AccountReportPrintJournalWizard(orm.TransientModel):
end_period, 'date_from': False, 'date_to': False}
return res
# pylint: disable=old-api7-method-defined
def _print_report(self, cursor, uid, ids, data, context=None):
context = context or {}
# we update form with display account value

1
account_financial_report_webkit/wizard/print_journal_view.xml

@ -28,6 +28,7 @@
<field name="name">Journals</field>
<field name="model">print.journal.webkit</field>
<field name="type">form</field>
<field name="priority">99</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<data>

8
account_financial_report_webkit/wizard/trial_balance_wizard.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier
@ -18,17 +18,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models
from openerp.osv import orm
class AccountTrialBalanceWizard(orm.TransientModel):
class AccountTrialBalanceWizard(models.TransientModel):
"""Will launch trial balance report and pass required args"""
_inherit = "account.common.balance.report"
_name = "trial.balance.webkit"
_description = "Trial Balance Report"
# pylint: disable=old-api7-method-defined
def _print_report(self, cursor, uid, ids, data, context=None):
context = context or {}
# we update form with display account value

1
account_financial_report_webkit/wizard/trial_balance_wizard_view.xml

@ -9,6 +9,7 @@
<record id="account_trial_balance_view_webkit" model="ir.ui.view">
<field name="name">Trial Balance</field>
<field name="model">trial.balance.webkit</field>
<field name="priority">99</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<data>

64
account_financial_report_webkit_xls/README.rst

@ -0,0 +1,64 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
==============================
Financial Reports - XLS Export
==============================
This module adds XLS export to the following accounting reports:
- General Ledger
- Trial Balance
- Partner Ledger
- Partner Balance
- Aged Partner Balance
- Open Invoices
Installation
============
To install this module, you need also the **report_xls**
module located in:
https://github.com/OCA/reporting-engine
Usage
=====
Use the 'Export' button on the financial report wizards to export the
data in Excel format.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/91/8.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_.
In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Credits
=======
Contributors
------------
* Noviat <info@noviat.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

23
account_financial_report_webkit_xls/__init__.py

@ -1,25 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
try:
from . import wizard
from . import report

49
account_financial_report_webkit_xls/__openerp__.py

@ -1,40 +1,12 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Add XLS export to accounting reports',
'version': '8.0.0.4.0',
'version': '8.0.1.0.0',
'license': 'AGPL-3',
'author': "Noviat,Odoo Community Association (OCA)",
'category': 'Generic Modules/Accounting',
'description': """
This module adds XLS export to the following accounting reports:
- general ledger
- trial balance
- partner ledger
- partner balance
- open invoices
""",
'depends': ['report_xls', 'account_financial_report_webkit'],
'demo': [],
'data': [
@ -43,12 +15,13 @@
'wizard/partners_ledger_wizard_view.xml',
'wizard/partners_balance_wizard_view.xml',
'wizard/open_invoices_wizard_view.xml',
'wizard/aged_partner_balance_wizard.xml',
'wizard/aged_open_invoices_wizard.xml',
],
'test': ['tests/general_ledger.yml',
'tests/partner_ledger.yml',
'tests/trial_balance.yml',
'tests/partner_balance.yml',
'tests/open_invoices.yml'],
'active': False,
'test': ['test/general_ledger.yml',
'test/partner_ledger.yml',
'test/trial_balance.yml',
'test/partner_balance.yml',
'test/open_invoices.yml'],
'installable': True,
}

2
account_financial_report_webkit_xls/report/__init__.py

@ -4,3 +4,5 @@ from . import trial_balance_xls
from . import partners_balance_xls
from . import partner_ledger_xls
from . import open_invoices_xls
from . import aged_partner_balance_xls
from . import aged_open_invoices_xls

281
account_financial_report_webkit_xls/report/aged_open_invoices_xls.py

@ -0,0 +1,281 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2016 Noviat.
# Copyright 2017 Therp BV.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import xlwt
from openerp.addons.report_xls.report_xls import report_xls
from openerp.addons.report_xls.utils import rowcol_to_cell
from openerp.addons.account_financial_report_webkit.report \
.aged_open_invoices import AccountAgedOpenInvoicesWebkit
from openerp.tools.translate import _
# import logging
# _logger = logging.getLogger(__name__)
class AccountAgedOpenInvoicesWebkitXls(report_xls):
# pylint: disable=old-api7-method-defined
def create(self, cr, uid, ids, data, context=None):
self._column_sizes = [
30, # Partner
20, # Partner Code
20, # Balance
20, # Due
20, # Overdue 0-30
20, # Overdue 30-60
20, # Overdue 60-90
20, # Overdue 90-120
20, # Overdue 120+
]
self._balance_pos = 2
return super(AccountAgedOpenInvoicesWebkitXls, self).create(
cr, uid, ids, data, context=context)
def _cell_styles(self, _xs):
self._style_title = xlwt.easyxf(_xs['xls_title'])
self._style_bold_blue_center = xlwt.easyxf(
_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] +
_xs['center'])
self._style_center = xlwt.easyxf(
_xs['borders_all'] + _xs['wrap'] + _xs['center'])
format_yellow_bold = _xs['bold'] + _xs['fill'] + _xs['borders_all']
self._style_account_title = xlwt.easyxf(
format_yellow_bold + _xs['xls_title'])
self._style_yellow_bold = xlwt.easyxf(format_yellow_bold)
self._style_yellow_bold_right = xlwt.easyxf(
format_yellow_bold + _xs['right'])
self._style_yellow_bold_decimal = xlwt.easyxf(
format_yellow_bold + _xs['right'],
num_format_str=report_xls.decimal_format)
self._style_default = xlwt.easyxf(_xs['borders_all'])
self._style_decimal = xlwt.easyxf(
_xs['borders_all'] + _xs['right'],
num_format_str=report_xls.decimal_format)
self._style_percent = xlwt.easyxf(
_xs['borders_all'] + _xs['right'],
num_format_str='0.00%')
def _setup_worksheet(self, _p, _xs, data, wb):
self.ws = wb.add_sheet(_p.report_name[:31])
self.ws.panes_frozen = True
self.ws.remove_splits = True
self.ws.portrait = 0 # Landscape
self.ws.fit_width_to_pages = 1
self.ws.header_str = self.xls_headers['standard']
self.ws.footer_str = self.xls_footers['standard']
def _print_title(self, _p, _xs, data, row_pos):
report_name = ' - '.join(
[_p.report_name.upper(),
_p.company.partner_id.name,
_p.company.currency_id.name])
c_specs = [
('report_name', 1, 0, 'text', report_name),
]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data, row_style=self._style_title)
return row_pos
def _print_empty_row(self, _p, _xs, data, row_pos):
"""
Print empty row to define column sizes
"""
c_specs = [('empty%s' % i, 1, self._column_sizes[i], 'text', None)
for i in range(len(self._column_sizes))]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data, set_column_size=True)
return row_pos
def _print_header_title(self, _p, _xs, data, row_pos):
c_specs = [
('coa', 1, 0, 'text', _('Chart of Account')),
('fy', 1, 0, 'text', _('Fiscal Year')),
('period_filter', 2, 0, 'text', _('Periods Filter')),
('cd', 1, 0, 'text', _('Clearance Date')),
('account_filter', 2, 0, 'text', _('Accounts Filter')),
('partner_filter', 1, 0, 'text', _('Partners Filter')),
('tm', 1, 0, 'text', _('Target Moves')),
]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data,
row_style=self._style_bold_blue_center)
return row_pos
def _print_header_data(self, _p, _xs, data, row_pos):
period_filter = _('From') + ': '
period_filter += _p.start_period.name if _p.start_period else u''
period_filter += ' ' + _('To') + ': '
period_filter += _p.stop_period.name if _p.stop_period else u''
c_specs = [
('coa', 1, 0, 'text', _p.chart_account.name),
('fy', 1, 0, 'text',
_p.fiscalyear.name if _p.fiscalyear else '-'),
('period_filter', 2, 0, 'text', period_filter),
('cd', 1, 0, 'text', _p.date_until),
('account_filter', 2, 0, 'text',
_p.display_partner_account(data)),
('partner_filter', 1, 0, 'text',
_('Selected Partners') if _p.partner_ids else '-'),
('tm', 1, 0, 'text',
_p.display_target_move(data)),
]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data, row_style=self._style_center)
return row_pos
def _print_header(self, _p, _xs, data, row_pos):
"""
Header Table: Chart of Account, Fiscal year, Filters, ...
"""
row_pos = self._print_header_title(_p, _xs, data, row_pos)
row_pos = self._print_header_data(_p, _xs, data, row_pos)
self.ws.set_horz_split_pos(row_pos) # freeze the line
return row_pos + 1
def _print_account_header(self, _p, _xs, data, row_pos, account):
"""
Fill in a row with the code and name of the account
"""
c_specs = [
('acc_title', len(self._column_sizes), 0, 'text',
' - '.join([account.code, account.name])),
]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data, self._style_account_title)
return row_pos + 1
def _print_partner_header(self, _p, _xs, data, row_pos):
"""
Partner header line
"""
c_specs = [
('partner_h', 1, 0, 'text', _('Partner'),
None, self._style_yellow_bold),
('pcode_h', 1, 0, 'text', _('Code'),
None, self._style_yellow_bold),
('balance_h', 1, 0, 'text', _('Balance')),
('due_h', 1, 0, 'text', _('Due'))]
for days in [30, 60, 90, 120]:
entry = 'od_%s_h' % days
label = _("Overdue ≤ %s d.") % days
c_specs += [(entry, 1, 0, 'text', label)]
c_specs += [('older_h', 1, 0, 'text', _("Older"))]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data,
row_style=self._style_yellow_bold_right)
return row_pos
def _print_partner_line(self, _p, _xs, data, row_pos, partner, line):
"""
Partner data line
"""
partner_name, p_id, p_ref, p_name = partner
c_specs = [
('partner', 1, 0, 'text', p_name,
None, self._style_default),
('pcode', 1, 0, 'text', p_ref,
None, self._style_default),
('balance', 1, 0, 'number', line['balance'])]
for r in _p.ranges:
entry = 'od_%s' % r[0]
c_specs += [(entry, 1, 0, 'number', line[r])]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data,
row_style=self._style_decimal)
return row_pos
def _print_partner_footer(self, _p, _xs, data, row_pos,
account, line_count):
"""
Partner header line
"""
# Totals
c_specs = [
('total', 1, 0, 'text', _('Total') + ' ' + account.code,
None, self._style_yellow_bold),
('empty', 1, 0, 'text', None,
None, self._style_yellow_bold)]
row_start = row_pos - line_count
col_start = self._balance_pos
start = rowcol_to_cell(row_start, col_start)
stop = rowcol_to_cell(row_pos - 1, col_start)
formula = 'SUM(%s:%s)' % (start, stop)
c_specs += [('total_balance', 1, 0, 'number', None, formula)]
col_start += 1
for i, r in enumerate(_p.ranges):
entry = 'total_%s' % i
start = rowcol_to_cell(row_start, col_start + i)
stop = rowcol_to_cell(row_pos - 1, col_start + i)
formula = 'SUM(%s:%s)' % (start, stop)
c_specs += [(entry, 1, 0, 'number', None, formula)]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data,
row_style=self._style_yellow_bold_decimal)
# percents
c_specs = [
('pct', 1, 0, 'text', _('Percentages') + ' ' + account.code,
None, self._style_default),
('empty', 2, 0, 'text', None,
None, self._style_default)]
total_balance = rowcol_to_cell(row_pos - 1, self._balance_pos)
for i, r in enumerate(_p.ranges):
entry = 'pct_%s' % i
total_range = rowcol_to_cell(row_pos - 1, col_start + i)
formula = '%s/%s' % (total_range, total_balance)
c_specs += [(entry, 1, 0, 'number', None, formula)]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data,
row_style=self._style_percent)
return row_pos
def _print_account_data(self, _p, _xs, data, row_pos, account):
if _p.aged_open_inv[account.id]:
row_pos = self._print_account_header(
_p, _xs, data, row_pos, account)
lines = _p.aged_open_inv[account.id]
row_pos = self._print_partner_header(
_p, _xs, data, row_pos)
row_pos_start = row_pos
for partner in _p.partners_order[account.id]:
partner_id = partner[1]
if partner_id in lines:
line = lines[partner_id]
row_pos = self._print_partner_line(
_p, _xs, data, row_pos, partner, line)
line_count = row_pos - row_pos_start
row_pos = self._print_partner_footer(
_p, _xs, data, row_pos, account, line_count)
return row_pos + 1
def generate_xls_report(self, _p, _xs, data, objects, wb):
self._cell_styles(_xs)
self._setup_worksheet(_p, _xs, data, wb)
row_pos = 0
row_pos = self._print_title(_p, _xs, data, row_pos)
row_pos = self._print_empty_row(_p, _xs, data, row_pos)
row_pos = self._print_header(_p, _xs, data, row_pos)
for account in objects:
row_pos = self._print_account_data(
_p, _xs, data, row_pos, account)
AccountAgedOpenInvoicesWebkitXls(
'report.account.aged_open_invoices_xls',
'account.account',
parser=AccountAgedOpenInvoicesWebkit)

281
account_financial_report_webkit_xls/report/aged_partner_balance_xls.py

@ -0,0 +1,281 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2016 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import xlwt
from openerp.addons.report_xls.report_xls import report_xls
from openerp.addons.report_xls.utils import rowcol_to_cell
from openerp.addons.account_financial_report_webkit.report \
.aged_partner_balance import AccountAgedTrialBalanceWebkit
from openerp.tools.translate import _
# import logging
# _logger = logging.getLogger(__name__)
class AccountAgedTrialBalanceWebkitXls(report_xls):
# pylint: disable=old-api7-method-defined
def create(self, cr, uid, ids, data, context=None):
self._column_sizes = [
30, # Partner
20, # Partner Code
20, # Balance
20, # Due
20, # Overdue 0-30
20, # Overdue 30-60
20, # Overdue 60-90
20, # Overdue 90-120
20, # Overdue 120+
]
self._balance_pos = 2
return super(AccountAgedTrialBalanceWebkitXls, self).create(
cr, uid, ids, data, context=context)
def _cell_styles(self, _xs):
self._style_title = xlwt.easyxf(_xs['xls_title'])
self._style_bold_blue_center = xlwt.easyxf(
_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] +
_xs['center'])
self._style_center = xlwt.easyxf(
_xs['borders_all'] + _xs['wrap'] + _xs['center'])
format_yellow_bold = _xs['bold'] + _xs['fill'] + _xs['borders_all']
self._style_account_title = xlwt.easyxf(
format_yellow_bold + _xs['xls_title'])
self._style_yellow_bold = xlwt.easyxf(format_yellow_bold)
self._style_yellow_bold_right = xlwt.easyxf(
format_yellow_bold + _xs['right'])
self._style_yellow_bold_decimal = xlwt.easyxf(
format_yellow_bold + _xs['right'],
num_format_str=report_xls.decimal_format)
self._style_default = xlwt.easyxf(_xs['borders_all'])
self._style_decimal = xlwt.easyxf(
_xs['borders_all'] + _xs['right'],
num_format_str=report_xls.decimal_format)
self._style_percent = xlwt.easyxf(
_xs['borders_all'] + _xs['right'],
num_format_str='0.00%')
def _setup_worksheet(self, _p, _xs, data, wb):
self.ws = wb.add_sheet(_p.report_name[:31])
self.ws.panes_frozen = True
self.ws.remove_splits = True
self.ws.portrait = 0 # Landscape
self.ws.fit_width_to_pages = 1
self.ws.header_str = self.xls_headers['standard']
self.ws.footer_str = self.xls_footers['standard']
def _print_title(self, _p, _xs, data, row_pos):
report_name = ' - '.join(
[_p.report_name.upper(),
_p.company.partner_id.name,
_p.company.currency_id.name])
c_specs = [
('report_name', 1, 0, 'text', report_name),
]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data, row_style=self._style_title)
return row_pos
def _print_empty_row(self, _p, _xs, data, row_pos):
"""
Print empty row to define column sizes
"""
c_specs = [('empty%s' % i, 1, self._column_sizes[i], 'text', None)
for i in range(len(self._column_sizes))]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data, set_column_size=True)
return row_pos
def _print_header_title(self, _p, _xs, data, row_pos):
c_specs = [
('coa', 1, 0, 'text', _('Chart of Account')),
('fy', 1, 0, 'text', _('Fiscal Year')),
('period_filter', 2, 0, 'text', _('Periods Filter')),
('cd', 1, 0, 'text', _('Clearance Date')),
('account_filter', 2, 0, 'text', _('Accounts Filter')),
('partner_filter', 1, 0, 'text', _('Partners Filter')),
('tm', 1, 0, 'text', _('Target Moves')),
]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data,
row_style=self._style_bold_blue_center)
return row_pos
def _print_header_data(self, _p, _xs, data, row_pos):
period_filter = _('From') + ': '
period_filter += _p.start_period.name if _p.start_period else u''
period_filter += ' ' + _('To') + ': '
period_filter += _p.stop_period.name if _p.stop_period else u''
c_specs = [
('coa', 1, 0, 'text', _p.chart_account.name),
('fy', 1, 0, 'text',
_p.fiscalyear.name if _p.fiscalyear else '-'),
('period_filter', 2, 0, 'text', period_filter),
('cd', 1, 0, 'text', _p.date_until),
('account_filter', 2, 0, 'text',
_p.display_partner_account(data)),
('partner_filter', 1, 0, 'text',
_('Selected Partners') if _p.partner_ids else '-'),
('tm', 1, 0, 'text',
_p.display_target_move(data)),
]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data, row_style=self._style_center)
return row_pos
def _print_header(self, _p, _xs, data, row_pos):
"""
Header Table: Chart of Account, Fiscal year, Filters, ...
"""
row_pos = self._print_header_title(_p, _xs, data, row_pos)
row_pos = self._print_header_data(_p, _xs, data, row_pos)
self.ws.set_horz_split_pos(row_pos) # freeze the line
return row_pos + 1
def _print_account_header(self, _p, _xs, data, row_pos, account):
"""
Fill in a row with the code and name of the account
"""
c_specs = [
('acc_title', len(self._column_sizes), 0, 'text',
' - '.join([account.code, account.name])),
]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data, self._style_account_title)
return row_pos + 1
def _print_partner_header(self, _p, _xs, data, row_pos):
"""
Partner header line
"""
c_specs = [
('partner_h', 1, 0, 'text', _('Partner'),
None, self._style_yellow_bold),
('pcode_h', 1, 0, 'text', _('Code'),
None, self._style_yellow_bold),
('balance_h', 1, 0, 'text', _('Balance')),
('due_h', 1, 0, 'text', _('Due'))]
for days in [30, 60, 90, 120]:
entry = 'od_%s_h' % days
label = _("Overdue ≤ %s d.") % days
c_specs += [(entry, 1, 0, 'text', label)]
c_specs += [('older_h', 1, 0, 'text', _("Older"))]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data,
row_style=self._style_yellow_bold_right)
return row_pos
def _print_partner_line(self, _p, _xs, data, row_pos, partner, line):
"""
Partner data line
"""
partner_name, p_id, p_ref, p_name = partner
c_specs = [
('partner', 1, 0, 'text', p_name,
None, self._style_default),
('pcode', 1, 0, 'text', p_ref,
None, self._style_default),
('balance', 1, 0, 'number', line['balance'])]
for r in _p.ranges:
entry = 'od_%s' % r[0]
c_specs += [(entry, 1, 0, 'number', line['aged_lines'][r])]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data,
row_style=self._style_decimal)
return row_pos
def _print_partner_footer(self, _p, _xs, data, row_pos,
account, line_count):
"""
Partner header line
"""
# Totals
c_specs = [
('total', 1, 0, 'text', _('Total') + ' ' + account.code,
None, self._style_yellow_bold),
('empty', 1, 0, 'text', None,
None, self._style_yellow_bold)]
row_start = row_pos - line_count
col_start = self._balance_pos
start = rowcol_to_cell(row_start, col_start)
stop = rowcol_to_cell(row_pos - 1, col_start)
formula = 'SUM(%s:%s)' % (start, stop)
c_specs += [('total_balance', 1, 0, 'number', None, formula)]
col_start += 1
for i, r in enumerate(_p.ranges):
entry = 'total_%s' % i
start = rowcol_to_cell(row_start, col_start + i)
stop = rowcol_to_cell(row_pos - 1, col_start + i)
formula = 'SUM(%s:%s)' % (start, stop)
c_specs += [(entry, 1, 0, 'number', None, formula)]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data,
row_style=self._style_yellow_bold_decimal)
# percents
c_specs = [
('pct', 1, 0, 'text', _('Percentages') + ' ' + account.code,
None, self._style_default),
('empty', 2, 0, 'text', None,
None, self._style_default)]
total_balance = rowcol_to_cell(row_pos - 1, self._balance_pos)
for i, r in enumerate(_p.ranges):
entry = 'pct_%s' % i
total_range = rowcol_to_cell(row_pos - 1, col_start + i)
formula = '%s/%s' % (total_range, total_balance)
c_specs += [(entry, 1, 0, 'number', None, formula)]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(
self.ws, row_pos, row_data,
row_style=self._style_percent)
return row_pos
def _print_account_data(self, _p, _xs, data, row_pos, account):
if _p.agged_lines_accounts.get(account.id):
row_pos = self._print_account_header(
_p, _xs, data, row_pos, account)
lines = _p.agged_lines_accounts[account.id]
row_pos = self._print_partner_header(
_p, _xs, data, row_pos)
row_pos_start = row_pos
for partner in _p.partners_order[account.id]:
partner_id = partner[1]
if partner_id in lines:
line = lines[partner_id]
row_pos = self._print_partner_line(
_p, _xs, data, row_pos, partner, line)
line_count = row_pos - row_pos_start
row_pos = self._print_partner_footer(
_p, _xs, data, row_pos, account, line_count)
return row_pos + 1
def generate_xls_report(self, _p, _xs, data, objects, wb):
self._cell_styles(_xs)
self._setup_worksheet(_p, _xs, data, wb)
row_pos = 0
row_pos = self._print_title(_p, _xs, data, row_pos)
row_pos = self._print_empty_row(_p, _xs, data, row_pos)
row_pos = self._print_header(_p, _xs, data, row_pos)
for account in objects:
row_pos = self._print_account_data(
_p, _xs, data, row_pos, account)
AccountAgedTrialBalanceWebkitXls(
'report.account.account_report_aged_partner_balance_xls',
'account.account',
parser=AccountAgedTrialBalanceWebkit)

8
account_financial_report_webkit_xls/report/general_ledger_xls.py

@ -29,7 +29,7 @@ _column_sizes = [
]
class general_ledger_xls(report_xls):
class GeneralLedgerXls(report_xls):
column_sizes = [x[1] for x in _column_sizes]
def generate_xls_report(self, _p, _xs, data, objects, wb):
@ -327,6 +327,6 @@ class general_ledger_xls(report_xls):
row_pos += 1
general_ledger_xls('report.account.account_report_general_ledger_xls',
'account.account',
parser=GeneralLedgerWebkit)
GeneralLedgerXls('report.account.account_report_general_ledger_xls',
'account.account',
parser=GeneralLedgerWebkit)

6
account_financial_report_webkit_xls/report/open_invoices_xls.py

@ -12,7 +12,7 @@ from openerp.tools.translate import _
# _logger = logging.getLogger(__name__)
class open_invoices_xls(report_xls):
class OpenInvoicesXls(report_xls):
column_sizes = [12, 12, 20, 15, 30, 30, 14, 14, 14, 14, 14, 14, 10]
def global_initializations(self, wb, _p, xlwt, _xs, objects, data):
@ -806,5 +806,5 @@ class open_invoices_xls(report_xls):
row_pos += 1
open_invoices_xls('report.account.account_report_open_invoices_xls',
'account.account', parser=PartnersOpenInvoicesWebkit)
OpenInvoicesXls('report.account.account_report_open_invoices_xls',
'account.account', parser=PartnersOpenInvoicesWebkit)

8
account_financial_report_webkit_xls/report/partner_ledger_xls.py

@ -27,7 +27,7 @@ _column_sizes = [
]
class partner_ledger_xls(report_xls):
class PartnerLedgerXls(report_xls):
column_sizes = [x[1] for x in _column_sizes]
def generate_xls_report(self, _p, _xs, data, objects, wb):
@ -438,6 +438,6 @@ class partner_ledger_xls(report_xls):
row_pos += 2
partner_ledger_xls('report.account.account_report_partner_ledger_xls',
'account.account',
parser=PartnersLedgerWebkit)
PartnerLedgerXls('report.account.account_report_partner_ledger_xls',
'account.account',
parser=PartnersLedgerWebkit)

8
account_financial_report_webkit_xls/report/partners_balance_xls.py

@ -15,7 +15,7 @@ def display_line(all_comparison_lines):
return any([line.get('balance') for line in all_comparison_lines])
class partners_balance_xls(report_xls):
class PartnersBalanceXls(report_xls):
column_sizes = [12, 40, 25, 17, 17, 17, 17, 17]
def print_title(self, ws, _p, row_position, xlwt, _xs):
@ -409,6 +409,6 @@ class partners_balance_xls(report_xls):
_xs, xlwt, ws, row_account_start, row_pos, current_account, _p)
partners_balance_xls('report.account.account_report_partner_balance_xls',
'account.account',
parser=PartnerBalanceWebkit)
PartnersBalanceXls('report.account.account_report_partner_balance_xls',
'account.account',
parser=PartnerBalanceWebkit)

29
account_financial_report_webkit_xls/report/trial_balance_xls.py

@ -11,8 +11,14 @@ from openerp.tools.translate import _
# _logger = logging.getLogger(__name__)
class trial_balance_xls(report_xls):
column_sizes = [12, 60, 17, 17, 17, 17, 17, 17]
class TrialBalanceXls(report_xls):
# pylint: disable=old-api7-method-defined
def create(self, cr, uid, ids, data, context=None):
self._column_sizes = [12, 60, 17, 17, 17, 17, 17, 17]
self._debit_pos = 4
return super(TrialBalanceXls, self).create(
cr, uid, ids, data, context=context)
def generate_xls_report(self, _p, _xs, data, objects, wb):
@ -45,7 +51,7 @@ class trial_balance_xls(report_xls):
ws, row_pos, row_data, row_style=cell_style)
# write empty row to define column sizes
c_sizes = self.column_sizes
c_sizes = self._column_sizes
c_specs = [('empty%s' % i, 1, c_sizes[i], 'text', None)
for i in range(0, len(c_sizes))]
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
@ -246,15 +252,14 @@ class trial_balance_xls(report_xls):
('account', account_span, 0, 'text', current_account.name),
]
if _p.comparison_mode == 'no_comparison':
debit_cell = rowcol_to_cell(row_pos, 4)
credit_cell = rowcol_to_cell(row_pos, 5)
debit_cell = rowcol_to_cell(row_pos, self._debit_pos)
credit_cell = rowcol_to_cell(row_pos, self._debit_pos + 1)
bal_formula = debit_cell + '-' + credit_cell
if _p.initial_balance_mode:
init_cell = rowcol_to_cell(row_pos, 3)
debit_cell = rowcol_to_cell(row_pos, 4)
credit_cell = rowcol_to_cell(row_pos, 5)
init_cell = rowcol_to_cell(row_pos, self._debit_pos - 1)
debit_cell = rowcol_to_cell(row_pos, self._debit_pos)
credit_cell = rowcol_to_cell(row_pos, self._debit_pos + 1)
bal_formula = init_cell + '+' + \
debit_cell + '-' + credit_cell
c_specs += [('init_bal', 1, 0, 'number',
@ -301,6 +306,6 @@ class trial_balance_xls(report_xls):
ws, row_pos, row_data, row_style=cell_style)
trial_balance_xls('report.account.account_report_trial_balance_xls',
'account.account',
parser=TrialBalanceWebkit)
TrialBalanceXls('report.account.account_report_trial_balance_xls',
'account.account',
parser=TrialBalanceWebkit)

556
account_financial_report_webkit_xls/static/description/icon.svg
File diff suppressed because it is too large
View File

0
account_financial_report_webkit_xls/tests/general_ledger.yml → account_financial_report_webkit_xls/test/general_ledger.yml

0
account_financial_report_webkit_xls/tests/open_invoices.yml → account_financial_report_webkit_xls/test/open_invoices.yml

0
account_financial_report_webkit_xls/tests/partner_balance.yml → account_financial_report_webkit_xls/test/partner_balance.yml

0
account_financial_report_webkit_xls/tests/partner_ledger.yml → account_financial_report_webkit_xls/test/partner_ledger.yml

0
account_financial_report_webkit_xls/tests/trial_balance.yml → account_financial_report_webkit_xls/test/trial_balance.yml

8
account_financial_report_webkit_xls/tests/__init__.py

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from . import test_general_leger_xls
from . import test_partner_ledger_xls
from . import test_trial_balance_xls
from . import test_partner_balance_xls
from . import test_open_invoices_xls
from . import test_aged_partner_balance_xls
from . import test_aged_open_invoices_xls

33
account_financial_report_webkit_xls/tests/test_aged_open_invoices_xls.py

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import datetime
from .test_common_xls import TestCommonXls
class TestAgedOpenInvoicesXls(TestCommonXls):
def _getReportModel(self):
return 'aged.open.invoices.webkit'
def _getXlsReportName(self):
return 'account.aged_open_invoices_xls'
def _getXlsReportActionName(self):
module = 'account_financial_report_webkit'
action = 'account_report_open_invoices_webkit'
return '%s.%s' % (module, action)
def _getBaseFilters(self):
return {
'date_from': '%s-01-01' % (datetime.now().year),
'date_to': '%s-12-31' % (datetime.now().year),
'until_date': '%s-12-31' % (datetime.now().year),
}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

31
account_financial_report_webkit_xls/tests/test_aged_partner_balance_xls.py

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common_xls import TestCommonXls
class TestAgedPartnerBalanceXls(TestCommonXls):
def _getReportModel(self):
return 'account.aged.trial.balance.webkit'
def _getXlsReportName(self):
return 'account.account_report_aged_partner_balance_xls'
def _getXlsReportActionName(self):
module = 'account_financial_report_webkit'
action = 'account_report_aged_trial_blanance_webkit'
return '%s.%s' % (module, action)
def _getBaseFilters(self):
fy_id = self.model._get_current_fiscalyear()
vals = self.model.onchange_fiscalyear(fiscalyear=fy_id)['value']
vals.update({'fiscalyear_id': fy_id})
return vals
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

60
account_financial_report_webkit_xls/tests/test_common_xls.py

@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.tests.common import TransactionCase
class TestCommonXls(TransactionCase):
""" Common tests for all XLS Exports """
def setUp(self):
super(TestCommonXls, self).setUp()
self.model = self.env[self._getReportModel()]
self.xls_report_name = self._getXlsReportName()
ctx = {'xls_export': 1}
self.xls_action_name = self._getXlsReportActionName()
self.xls_action = self.env.ref(self.xls_action_name).with_context(ctx)
wiz_vals = {'chart_account_id': self.env.ref('account.chart0').id}
wiz_vals.update(self._getBaseFilters())
self.report = self.model.with_context(ctx).create(wiz_vals)
def common_test_01_action_xls(self):
""" Check if report XLS action is correct """
report_action = self.report.xls_export()
self.assertDictContainsSubset(
{'type': 'ir.actions.report.xml',
'report_name': self.xls_report_name},
report_action)
self.render_dict = report_action['datas']
def common_test_02_render_xls(self):
report_xls = self.xls_action.render_report(
self.report.ids,
self.xls_report_name,
self.render_dict)
self.assertGreaterEqual(len(report_xls[0]), 1)
self.assertEqual(report_xls[1], 'xls')
def _getReportModel(self):
"""
:return: the report model name
"""
raise NotImplementedError()
def _getXlsReportName(self):
"""
:return: the xls report name
"""
raise NotImplementedError()
def _getXlsReportActionName(self):
"""
:return: the xls report action name
"""
raise NotImplementedError()
def _getBaseFilters(self):
"""
:return: the minimum required filters to generate report
"""
raise NotImplementedError()

28
account_financial_report_webkit_xls/tests/test_general_leger_xls.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common_xls import TestCommonXls
class TestGeneralLedgerXls(TestCommonXls):
def _getReportModel(self):
return 'general.ledger.webkit'
def _getXlsReportName(self):
return 'account.account_report_general_ledger_xls'
def _getXlsReportActionName(self):
module = 'account_financial_report_webkit'
action = 'account_report_general_ledger_webkit'
return '%s.%s' % (module, action)
def _getBaseFilters(self):
return {}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

29
account_financial_report_webkit_xls/tests/test_open_invoices_xls.py

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import datetime
from .test_common_xls import TestCommonXls
class TestOpenInvoicesXls(TestCommonXls):
def _getReportModel(self):
return 'open.invoices.webkit'
def _getXlsReportName(self):
return 'account.account_report_open_invoices_xls'
def _getXlsReportActionName(self):
module = 'account_financial_report_webkit'
action = 'account_report_open_invoices_webkit'
return '%s.%s' % (module, action)
def _getBaseFilters(self):
return {'until_date': '%s-12-31' % (datetime.now().year)}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

28
account_financial_report_webkit_xls/tests/test_partner_balance_xls.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common_xls import TestCommonXls
class TestPartnerBalanceXls(TestCommonXls):
def _getReportModel(self):
return 'partner.balance.webkit'
def _getXlsReportName(self):
return 'account.account_report_partner_balance_xls'
def _getXlsReportActionName(self):
module = 'account_financial_report_webkit'
action = 'account_report_partner_balance_webkit'
return '%s.%s' % (module, action)
def _getBaseFilters(self):
return {}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

28
account_financial_report_webkit_xls/tests/test_partner_ledger_xls.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common_xls import TestCommonXls
class TestPartnerLedgerXls(TestCommonXls):
def _getReportModel(self):
return 'partners.ledger.webkit'
def _getXlsReportName(self):
return 'account.account_report_partner_ledger_xls'
def _getXlsReportActionName(self):
module = 'account_financial_report_webkit'
action = 'account_report_partners_ledger_webkit'
return '%s.%s' % (module, action)
def _getBaseFilters(self):
return {}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

28
account_financial_report_webkit_xls/tests/test_trial_balance_xls.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2017 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from .test_common_xls import TestCommonXls
class TestTrialBalanceXls(TestCommonXls):
def _getReportModel(self):
return 'trial.balance.webkit'
def _getXlsReportName(self):
return 'account.account_report_trial_balance_xls'
def _getXlsReportActionName(self):
module = 'account_financial_report_webkit'
action = 'account_report_trial_balance_webkit'
return '%s.%s' % (module, action)
def _getBaseFilters(self):
return {}
def test_common(self):
common_tests = [
x for x in dir(self)
if callable(getattr(self, x)) and x.startswith('common_test_')]
for test in common_tests:
getattr(self, test)()

25
account_financial_report_webkit_xls/wizard/__init__.py

@ -1,27 +1,8 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
from . import general_ledger_wizard
from . import trial_balance_wizard
from . import partners_balance_wizard
from . import partners_ledger_wizard
from . import open_invoices_wizard
from . import aged_partner_balance_wizard
from . import aged_open_invoices_wizard

27
account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2016 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models
class AgedOpenInvoice(models.TransientModel):
_inherit = 'aged.open.invoices.webkit'
# pylint: disable=old-api7-method-defined
def xls_export(self, cr, uid, ids, context=None):
return self.check_report(cr, uid, ids, context=context)
# pylint: disable=old-api7-method-defined
def _print_report(self, cr, uid, ids, data, context=None):
context = context or {}
if context.get('xls_export'):
# we update form with display account value
data = self.pre_print_report(cr, uid, ids, data, context=context)
return {
'type': 'ir.actions.report.xml',
'report_name':
'account.aged_open_invoices_xls',
'datas': data}
else:
return super(AgedOpenInvoice, self)._print_report(
cr, uid, ids, data, context=context)

17
account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="aged_open_invoice_webkit" model="ir.ui.view">
<field name="model">aged.open.invoices.webkit</field>
<field name="type">form</field>
<field name="inherit_id" ref="account_financial_report_webkit.aged_open_invoice_webkit"/>
<field name="arch" type="xml">
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</field>
</record>
</data>
</openerp>

27
account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2016 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models
class AccountAgedTrialBalance(models.TransientModel):
_inherit = 'account.aged.trial.balance.webkit'
# pylint: disable=old-api7-method-defined
def xls_export(self, cr, uid, ids, context=None):
return self.check_report(cr, uid, ids, context=context)
# pylint: disable=old-api7-method-defined
def _print_report(self, cr, uid, ids, data, context=None):
context = context or {}
if context.get('xls_export'):
# we update form with display account value
data = self.pre_print_report(cr, uid, ids, data, context=context)
return {
'type': 'ir.actions.report.xml',
'report_name':
'account.account_report_aged_partner_balance_xls',
'datas': data}
else:
return super(AccountAgedTrialBalance, self)._print_report(
cr, uid, ids, data, context=context)

18
account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="account_aged_trial_balance_webkit" model="ir.ui.view">
<field name="name">account.aged.trial.balance.webkit.xls</field>
<field name="model">account.aged.trial.balance.webkit</field>
<field name="type">form</field>
<field name="inherit_id" ref="account_financial_report_webkit.account_aged_trial_balance_webkit"/>
<field name="arch" type="xml">
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</field>
</record>
</data>
</openerp>

35
account_financial_report_webkit_xls/wizard/general_ledger_wizard.py

@ -1,36 +1,17 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2009-2016 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models
from openerp.osv import orm
# import logging
# _logger = logging.getLogger(__name__)
class general_ledger_webkit_wizard(orm.TransientModel):
class AccountReportGeneralLedgerWizard(models.TransientModel):
_inherit = 'general.ledger.webkit'
# pylint: disable=old-api7-method-defined
def xls_export(self, cr, uid, ids, context=None):
return self.check_report(cr, uid, ids, context=context)
# pylint: disable=old-api7-method-defined
def _print_report(self, cr, uid, ids, data, context=None):
context = context or {}
if context.get('xls_export'):
@ -40,5 +21,5 @@ class general_ledger_webkit_wizard(orm.TransientModel):
'report_name': 'account.account_report_general_ledger_xls',
'datas': data}
else:
return super(general_ledger_webkit_wizard, self)._print_report(
return super(AccountReportGeneralLedgerWizard, self)._print_report(
cr, uid, ids, data, context=context)

20
account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml

@ -2,23 +2,19 @@
<openerp>
<data>
<record id="general_ledger_webkit_xls_wizard_view" model="ir.ui.view">
<record id="account_report_general_ledger_view_webkit" model="ir.ui.view">
<field name="name">general.ledger.webkit.xls</field>
<field name="model">general.ledger.webkit</field>
<field name="priority">99</field>
<field name="type">form</field>
<field name="inherit_id" ref="account_financial_report_webkit.account_report_general_ledger_view_webkit"/>
<field name="arch" type="xml">
<data>
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your general ledger with details of all your account journals"/>
</xpath>
<xpath expr="/form/group[@col='4']" position='attributes'>
<attribute name="col">6</attribute>
</xpath>
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</data>
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your general ledger with details of all your account journals"/>
</xpath>
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</field>
</record>

35
account_financial_report_webkit_xls/wizard/open_invoices_wizard.py

@ -1,36 +1,17 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2009-2016 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models
from openerp.osv import orm
# import logging
# _logger = logging.getLogger(__name__)
class open_invoices_webkit_wizard(orm.TransientModel):
class AccountReportOpenInvoicesWizard(models.TransientModel):
_inherit = 'open.invoices.webkit'
# pylint: disable=old-api7-method-defined
def xls_export(self, cr, uid, ids, context=None):
return self.check_report(cr, uid, ids, context=context)
# pylint: disable=old-api7-method-defined
def _print_report(self, cr, uid, ids, data, context=None):
context = context or {}
if context.get('xls_export'):
@ -40,5 +21,5 @@ class open_invoices_webkit_wizard(orm.TransientModel):
'report_name': 'account.account_report_open_invoices_xls',
'datas': data}
else:
return super(open_invoices_webkit_wizard, self)._print_report(
return super(AccountReportOpenInvoicesWizard, self)._print_report(
cr, uid, ids, data, context=context)

20
account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml

@ -2,23 +2,19 @@
<openerp>
<data>
<record id="open_invoices_webkit_xls_wizard_view" model="ir.ui.view">
<record id="account_open_invoices_view_webkit" model="ir.ui.view">
<field name="name">open.invoices.webkit.xls</field>
<field name="model">open.invoices.webkit</field>
<field name="priority">99</field>
<field name="type">form</field>
<field name="inherit_id" ref="account_financial_report_webkit.account_open_invoices_view_webkit"/>
<field name="arch" type="xml">
<data>
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your open invoices per partner with details of all your payable/receivable account. Exclude full reconciled journal items."/>
</xpath>
<xpath expr="/form/group[@col='4']" position='attributes'>
<attribute name="col">6</attribute>
</xpath>
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</data>
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your open invoices per partner with details of all your payable/receivable account. Exclude full reconciled journal items."/>
</xpath>
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</field>
</record>

35
account_financial_report_webkit_xls/wizard/partners_balance_wizard.py

@ -1,36 +1,17 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2009-2016 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models
from openerp.osv import orm
# import logging
# _logger = logging.getLogger(__name__)
class partner_balance_wizard(orm.TransientModel):
class AccountPartnerBalanceWizard(models.TransientModel):
_inherit = 'partner.balance.webkit'
# pylint: disable=old-api7-method-defined
def xls_export(self, cr, uid, ids, context=None):
return self.check_report(cr, uid, ids, context=context)
# pylint: disable=old-api7-method-defined
def _print_report(self, cr, uid, ids, data, context=None):
context = context or {}
if context.get('xls_export'):
@ -41,5 +22,5 @@ class partner_balance_wizard(orm.TransientModel):
'report_name': 'account.account_report_partner_balance_xls',
'datas': data}
else:
return super(partner_balance_wizard, self)._print_report(
return super(AccountPartnerBalanceWizard, self)._print_report(
cr, uid, ids, data, context=context)

18
account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml

@ -1,24 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="partners_balance_webkit_xls_wizard_view" model="ir.ui.view">
<record id="account_partner_balance_view_webkit" model="ir.ui.view">
<field name="name">partner.balance.webkit.xls</field>
<field name="model">partner.balance.webkit</field>
<field name="type">form</field>
<field name="inherit_id" ref="account_financial_report_webkit.account_partner_balance_view_webkit"/>
<field name="arch" type="xml">
<data>
<xpath expr="/form/label[contains(@string,'is an analysis')]" position="replace">
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your partner balance allowing you to quickly check the balance of each of your accounts in a single report"/>
</xpath>
<xpath expr="/form/group[@col='4']" position='attributes'>
<attribute name="col">6</attribute>
</xpath>
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</data>
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</field>
</record>

43
account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py

@ -1,44 +1,27 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2009-2016 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models
from openerp.osv import orm
# import logging
# _logger = logging.getLogger(__name__)
class partner_ledger_webkit_wizard(orm.TransientModel):
class AccountReportPartnersLedgerWizard(models.TransientModel):
_inherit = 'partners.ledger.webkit'
# pylint: disable=old-api7-method-defined
def xls_export(self, cr, uid, ids, context=None):
return self.check_report(cr, uid, ids, context=context)
# pylint: disable=old-api7-method-defined
def _print_report(self, cr, uid, ids, data, context=None):
context = context or {}
if context.get('xls_export'):
# we update form with display account value
data = self.pre_print_report(cr, uid, ids, data, context=context)
return {'type': 'ir.actions.report.xml',
'report_name': 'account.account_report_partner_ledger_xls',
'datas': data}
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.account_report_partner_ledger_xls',
'datas': data}
else:
return super(partner_ledger_webkit_wizard, self)._print_report(
return super(
AccountReportPartnersLedgerWizard, self)._print_report(
cr, uid, ids, data, context=context)

20
account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml

@ -2,23 +2,19 @@
<openerp>
<data>
<record id="partner_ledger_webkit_xls_wizard_view" model="ir.ui.view">
<record id="account_partner_ledger_view_webkit" model="ir.ui.view">
<field name="name">partners.ledger.webkit.xls</field>
<field name="model">partners.ledger.webkit</field>
<field name="priority">99</field>
<field name="type">form</field>
<field name="inherit_id" ref="account_financial_report_webkit.account_partner_ledger_view_webkit"/>
<field name="arch" type="xml">
<data>
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your partner ledger with details of all your account journals"/>
</xpath>
<xpath expr="/form/group[@col='4']" position='attributes'>
<attribute name="col">6</attribute>
</xpath>
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</data>
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your partner ledger with details of all your account journals"/>
</xpath>
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</field>
</record>

35
account_financial_report_webkit_xls/wizard/trial_balance_wizard.py

@ -1,36 +1,17 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2009-2016 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models
from openerp.osv import orm
# import logging
# _logger = logging.getLogger(__name__)
class trial_balance_wizard(orm.TransientModel):
class AccountTrialBalanceWizard(models.TransientModel):
_inherit = 'trial.balance.webkit'
# pylint: disable=old-api7-method-defined
def xls_export(self, cr, uid, ids, context=None):
return self.check_report(cr, uid, ids, context=context)
# pylint: disable=old-api7-method-defined
def _print_report(self, cr, uid, ids, data, context=None):
context = context or {}
if context.get('xls_export'):
@ -40,5 +21,5 @@ class trial_balance_wizard(orm.TransientModel):
'report_name': 'account.account_report_trial_balance_xls',
'datas': data}
else:
return super(trial_balance_wizard, self)._print_report(
return super(AccountTrialBalanceWizard, self)._print_report(
cr, uid, ids, data, context=context)

22
account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml

@ -1,24 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="trial_balance_webkit_xls_wizard_view" model="ir.ui.view">
<record id="account_trial_balance_view_webkit" model="ir.ui.view">
<field name="name">trial.balance.webkit.xls</field>
<field name="model">trial.balance.webkit</field>
<field name="priority">99</field>
<field name="type">form</field>
<field name="inherit_id" ref="account_financial_report_webkit.account_trial_balance_view_webkit"/>
<field name="arch" type="xml">
<data>
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your trial balance allowing you to quickly check the balance of each of your accounts in a single report"/>
</xpath>
<xpath expr="/form/group[@col='4']" position='attributes'>
<attribute name="col">6</attribute>
</xpath>
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</data>
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your trial balance allowing you to quickly check the balance of each of your accounts in a single report"/>
</xpath>
<button string="Print" position="after">
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
</button>
</field>
</record>

2
account_journal_report_xls/__init__.py

@ -27,4 +27,4 @@ try:
except ImportError:
import logging
logging.getLogger('openerp.module').warning('''report_xls not available in
addons path. account_financial_report_webkit_xls will not be usable''')
addons path. account_journal_report_xls will not be usable''')

2
account_journal_report_xls/__openerp__.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution

11
account_journal_report_xls/account_journal.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
@ -19,14 +19,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models
from openerp.osv import orm
class account_journal(orm.Model):
class AccountJournal(models.Model):
_inherit = 'account.journal'
# allow inherited modules to extend the query
# pylint: disable=old-api7-method-defined
def _report_xls_query_extra(self, cr, uid, context=None):
select_extra = ""
join_extra = ""
@ -34,10 +34,12 @@ class account_journal(orm.Model):
return (select_extra, join_extra, where_extra)
# allow inherited modules to add document references
# pylint: disable=old-api7-method-defined
def _report_xls_document_extra(self, cr, uid, context):
return "''"
# override list in inherited module to add/drop columns or change order
# pylint: disable=old-api7-method-defined
def _report_xls_fields(self, cr, uid, context=None):
res = [
'move_name', # account.move,name
@ -73,6 +75,7 @@ class account_journal(orm.Model):
return res
# Change/Add Template entries
# pylint: disable=old-api7-method-defined
def _report_xls_template(self, cr, uid, context=None):
"""
Template updates, e.g.

16
account_journal_report_xls/report/nov_account_journal.py

@ -11,12 +11,12 @@ _logger = logging.getLogger(__name__)
_ir_translation_name = 'nov.account.journal.print'
class nov_journal_print(report_sxw.rml_parse):
class NovJournalPrint(report_sxw.rml_parse):
def set_context(self, objects, data, ids, report_type=None):
# _logger.warn('set_context, objects = %s, data = %s,
# ids = %s', objects, data, ids)
super(nov_journal_print, self).set_context(objects, data, ids)
super(NovJournalPrint, self).set_context(objects, data, ids)
j_obj = self.pool.get('account.journal')
p_obj = self.pool.get('account.period')
fy_obj = self.pool.get('account.fiscalyear')
@ -48,10 +48,11 @@ class nov_journal_print(report_sxw.rml_parse):
objects.append((journal, fiscalyear))
self.localcontext['objects'] = self.objects = objects
# pylint: disable=old-api7-method-defined
def __init__(self, cr, uid, name, context):
if context is None:
context = {}
super(nov_journal_print, self).__init__(cr, uid, name, context=context)
super(NovJournalPrint, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'title': self._title,
@ -121,6 +122,7 @@ class nov_journal_print(report_sxw.rml_parse):
# field value translations.
# If performance is no issue, you can adapt the _report_xls_template in
# an inherited module to add field value translations.
# pylint: disable=sql-injection
self.cr.execute("SELECT l.move_id AS move_id, l.id AS aml_id, "
"am.name AS move_name, "
"coalesce(am.ref,'') AS move_ref, "
@ -197,8 +199,9 @@ class nov_journal_print(report_sxw.rml_parse):
code_string = j_obj._report_xls_document_extra(
self.cr, self.uid, self.context)
# _logger.warn('code_string= %s', code_string)
# disable=W0123, safe_eval doesn't apply here since
# W0123, safe_eval doesn't apply here since
# code_string comes from python module
# pylint: disable=eval-referenced
[x.update(
{'docname': eval(code_string) or '-'}) # pylint: disable=W0123
for x in lines]
@ -307,6 +310,7 @@ class nov_journal_print(report_sxw.rml_parse):
else:
fiscalyear = object[1]
period_ids = [x.id for x in fiscalyear.period_ids]
# pylint: disable=sql-injection
select = "SELECT sum(" + field + ") FROM account_move_line l " \
"INNER JOIN account_move am ON l.move_id = am.id " \
"WHERE l.period_id IN %s AND l.journal_id=%s AND am.state IN %s"
@ -334,7 +338,7 @@ class nov_journal_print(report_sxw.rml_parse):
if isinstance(value, (float, int)) and not value:
return ''
else:
return super(nov_journal_print, self).formatLang(
return super(NovJournalPrint, self).formatLang(
value, digits,
date, date_time, grouping, monetary, dp, currency_obj)
@ -342,4 +346,4 @@ class nov_journal_print(report_sxw.rml_parse):
report_sxw.report_sxw(
'report.nov.account.journal.print', 'account.journal',
'addons/account_journal_report_xls/report/nov_account_journal.rml',
parser=nov_journal_print, header=False)
parser=NovJournalPrint, header=False)

34
account_journal_report_xls/report/nov_account_journal_xls.py

@ -4,20 +4,21 @@
import xlwt
from datetime import datetime
from openerp.osv import orm
from openerp.addons.report_xls.report_xls import report_xls
from openerp.addons.report_xls.utils import rowcol_to_cell, _render
from .nov_account_journal import nov_journal_print
from .nov_account_journal import NovJournalPrint
from openerp.tools.translate import _
from openerp.exceptions import except_orm
import logging
_logger = logging.getLogger(__name__)
class account_journal_xls_parser(nov_journal_print):
class AccountJournalXlsParser(NovJournalPrint):
# pylint: disable=old-api7-method-defined
def __init__(self, cr, uid, name, context):
super(account_journal_xls_parser, self).__init__(cr, uid, name,
context=context)
super(AccountJournalXlsParser, self).__init__(
cr, uid, name, context=context)
journal_obj = self.pool.get('account.journal')
self.context = context
wanted_list = journal_obj._report_xls_fields(cr, uid, context)
@ -29,11 +30,12 @@ class account_journal_xls_parser(nov_journal_print):
})
class account_journal_xls(report_xls):
class AccountJournalXls(report_xls):
# pylint: disable=old-api7-method-defined
def __init__(self, name, table, rml=False, parser=False, header=True,
store=False):
super(account_journal_xls, self).__init__(
super(AccountJournalXls, self).__init__(
name, table, rml, parser, header, store)
# Cell Styles
@ -305,7 +307,7 @@ class account_journal_xls(report_xls):
cols_number = len(wanted_list)
vat_summary_cols_number = len(vat_summary_wanted_list)
if vat_summary_cols_number > cols_number:
raise orm.except_orm(
raise except_orm(
_('Programming Error!'),
_("vat_summary_cols_number should be < cols_number !"))
index = 0
@ -360,10 +362,12 @@ class account_journal_xls(report_xls):
'credit')
if not (self.credit_pos and self.debit_pos) and 'balance' \
in wanted_list:
raise orm.except_orm(_('Customisation Error!'),
_("The 'Balance' field is a calculated XLS \
field requiring the presence of the \
'Debit' and 'Credit' fields !"))
raise except_orm(
_('Customisation Error!'),
_("The 'Balance' field is a calculated XLS \
field requiring the presence of the \
'Debit' and 'Credit' fields !")
)
for o in objects:
@ -387,5 +391,7 @@ class account_journal_xls(report_xls):
row_pos = self._journal_vat_summary(o, ws, _p, row_pos, _xs)
account_journal_xls('report.nov.account.journal.xls', 'account.journal.period',
parser=account_journal_xls_parser)
AccountJournalXls(
'report.nov.account.journal.xls', 'account.journal.period',
parser=AccountJournalXlsParser,
)

23
account_journal_report_xls/wizard/__init__.py

@ -1,23 +1,2 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
from . import print_journal_wizard

48
account_journal_report_xls/wizard/print_journal_wizard.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
@ -19,37 +19,34 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.tools.translate import _
from openerp.osv import orm, fields
from openerp import _, exceptions, models, fields
from openerp.addons.account.wizard.account_report_common_journal \
import account_common_journal_report
import logging
_logger = logging.getLogger(__name__)
class account_print_journal_xls(orm.TransientModel):
class AccountPrintJournalXls(models.TransientModel):
_inherit = 'account.print.journal'
_name = 'account.print.journal.xls'
_description = 'Print/Export Journal'
_columns = {
'journal_ids': fields.many2many(
'account.journal',
'account_print_journal_xls_journal_rel',
'journal_xls_id',
'journal_id',
string='Journals',
required=True),
'group_entries': fields.boolean(
'Group Entries',
help="Group entries with same General Account & Tax Code."),
}
_defaults = {
'group_entries': True,
}
journal_ids = fields.Many2many(
'account.journal',
'account_print_journal_xls_journal_rel',
'journal_xls_id',
'journal_id',
string='Journals',
required=True
)
group_entries = fields.Boolean(
'Group Entries', default=True,
help="Group entries with same General Account & Tax Code."
)
# pylint: disable=old-api7-method-defined
def fields_get(self, cr, uid, fields=None, context=None):
res = super(account_print_journal_xls, self).fields_get(
res = super(AccountPrintJournalXls, self).fields_get(
cr, uid, fields, context)
if context.get('print_by') == 'fiscalyear':
if 'fiscalyear_id' in res:
@ -65,6 +62,7 @@ class account_print_journal_xls(orm.TransientModel):
res['period_to']['required'] = True
return res
# pylint: disable=old-api7-method-defined
def fy_period_ids(self, cr, uid, fiscalyear_id):
""" returns all periods from a fiscalyear sorted by date """
fy_period_ids = []
@ -78,6 +76,7 @@ class account_print_journal_xls(orm.TransientModel):
fy_period_ids = [x[0] for x in res]
return fy_period_ids
# pylint: disable=old-api7-method-defined
def onchange_fiscalyear_id(self, cr, uid, ids, fiscalyear_id=False,
context=None):
res = {'value': {}}
@ -89,6 +88,7 @@ class account_print_journal_xls(orm.TransientModel):
res['value']['period_to'] = fy_period_ids[-1]
return res
# pylint: disable=old-api7-method-defined
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
""" skip account.common.journal.report,fields_view_get
@ -97,9 +97,11 @@ class account_print_journal_xls(orm.TransientModel):
fields_view_get(cr, uid, view_id, view_type, context, toolbar,
submenu)
# pylint: disable=old-api7-method-defined
def xls_export(self, cr, uid, ids, context=None):
return self.print_report(cr, uid, ids, context=context)
# pylint: disable=old-api7-method-defined
def print_report(self, cr, uid, ids, context=None):
if context is None:
context = {}
@ -156,7 +158,7 @@ class account_print_journal_xls(orm.TransientModel):
if aml_ids:
journal_fy_ids.append((journal_id, fiscalyear_id))
if not journal_fy_ids:
raise orm.except_orm(
raise exceptions.except_orm(
_('No Data Available'),
_('No records found for your selection!'))
datas.update({
@ -180,7 +182,7 @@ class account_print_journal_xls(orm.TransientModel):
if period_ids:
journal_period_ids.append((journal_id, period_ids))
if not journal_period_ids:
raise orm.except_orm(
raise exceptions.except_orm(
_('No Data Available'),
_('No records found for your selection!'))
datas.update({

10
account_journal_report_xls/wizard/print_journal_wizard.xml

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_print_journal_xls" model="ir.ui.view">
<field name="name">Print/Export Journals</field>
<field name="model">account.print.journal.xls</field>
<field name="priority">99</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<data>
@ -19,7 +19,7 @@
</xpath>
<xpath expr="//field[@name='target_move']" position="after">
<field name="sort_selection"/>
<field name="amount_currency"/>
<field name="amount_currency"/>
<field name="group_entries"/>
<newline/>
<separator string="Periods" colspan="4"/>
@ -53,7 +53,7 @@
action="action_print_journal_by_period_xls"
id="menu_print_journal_by_period_xls"
icon="STOCK_PRINT"/>
<record id="action_print_journal_by_fiscalyear_xls" model="ir.actions.act_window">
<field name="name">Journal by Fiscal Year</field>
<field name="type">ir.actions.act_window</field>
@ -75,6 +75,6 @@
<record id="account.menu_account_print_sale_purchase_journal" model="ir.ui.menu">
<field name="sequence">3</field>
</record>
</data>
</openerp>
</openerp>
Loading…
Cancel
Save