diff --git a/account_financial_report_webkit/__init__.py b/account_financial_report_webkit/__init__.py
index 1583e4ad..7cdea65e 100644
--- a/account_financial_report_webkit/__init__.py
+++ b/account_financial_report_webkit/__init__.py
@@ -17,7 +17,7 @@
# along with this program. If not, see .
#
##############################################################################
-import account
+from . import account
from . import wizard
from . import report
-from . import account_move_line
\ No newline at end of file
+from . import account_move_line
diff --git a/account_financial_report_webkit/__openerp__.py b/account_financial_report_webkit/__openerp__.py
index 40bfc53b..22de6562 100644
--- a/account_financial_report_webkit/__openerp__.py
+++ b/account_financial_report_webkit/__openerp__.py
@@ -35,7 +35,8 @@ This module adds or replaces the following standard OpenERP financial reports:
Main improvements per report:
-----------------------------
-The General ledger: details of all entries posted in your books sorted by account.
+The General ledger: details of all entries posted in your books sorted by
+account.
* Filter by account is available in the wizard (no need to go to the
Chart of Accounts to do this anymore) or by View account (the report
@@ -114,7 +115,8 @@ like the trial balance but add an extra information :
Overdue data are also split by period.
* For each partner following columns will be displayed:
- * Total balance (all figures must match with same date partner balance report).
+ * Total balance (all figures must match with same date partner balance
+ report).
This column equals the sum of all following columns)
* Due
@@ -126,11 +128,11 @@ like the trial balance but add an extra information :
Hypothesis / Contraints of aged partner balance
-* Overdues columns will be by default be based on 30 days range fix number of days.
- This can be changed by changes the RANGES constraint
+* Overdues columns will be by default be based on 30 days range fix number of
+ days. This can be changed by changes the RANGES constraint
* All data will be displayed in company currency
-* When partial payments, the payment must appear in the same colums than the invoice
- (Except if multiple payment terms)
+* When partial payments, the payment must appear in the same colums than the
+ invoice (Except if multiple payment terms)
* Data granularity: partner (will not display figures at invoices level)
* The report aggregate data per account with sub-totals
* Initial balance must be calculated the same way that
@@ -173,25 +175,24 @@ wkhtmltopdf. The texts are defined inside the report classes.
'category': 'Finance',
'website': 'http://www.camptocamp.com',
'images': [
- 'images/ledger.png',],
+ 'images/ledger.png', ],
'depends': ['account',
'report_webkit'],
- 'init_xml': [],
- 'demo_xml' : [],
- 'update_xml': ['account_view.xml',
- 'data/financial_webkit_header.xml',
- 'report/report.xml',
- 'wizard/wizard.xml',
- 'wizard/balance_common_view.xml',
- 'wizard/general_ledger_wizard_view.xml',
- 'wizard/partners_ledger_wizard_view.xml',
- 'wizard/trial_balance_wizard_view.xml',
- 'wizard/partner_balance_wizard_view.xml',
- 'wizard/open_invoices_wizard_view.xml',
- 'wizard/aged_partner_balance_wizard.xml',
- 'wizard/print_journal_view.xml',
- 'report_menus.xml',
- ],
+ 'demo': [],
+ 'data': ['account_view.xml',
+ 'data/financial_webkit_header.xml',
+ 'report/report.xml',
+ 'wizard/wizard.xml',
+ 'wizard/balance_common_view.xml',
+ 'wizard/general_ledger_wizard_view.xml',
+ 'wizard/partners_ledger_wizard_view.xml',
+ 'wizard/trial_balance_wizard_view.xml',
+ 'wizard/partner_balance_wizard_view.xml',
+ 'wizard/open_invoices_wizard_view.xml',
+ 'wizard/aged_partner_balance_wizard.xml',
+ 'wizard/print_journal_view.xml',
+ 'report_menus.xml',
+ ],
# tests order matter
'test': ['tests/general_ledger.yml',
'tests/partner_ledger.yml',
@@ -199,7 +200,7 @@ wkhtmltopdf. The texts are defined inside the report classes.
'tests/partner_balance.yml',
'tests/open_invoices.yml',
'tests/aged_trial_balance.yml'],
- #'tests/account_move_line.yml'
+ # 'tests/account_move_line.yml'
'active': False,
'installable': True,
'application': True,
diff --git a/account_financial_report_webkit/account_move_line.py b/account_financial_report_webkit/account_move_line.py
index 617908bc..56e74b5a 100644
--- a/account_financial_report_webkit/account_move_line.py
+++ b/account_financial_report_webkit/account_move_line.py
@@ -20,16 +20,18 @@
##############################################################################
from openerp.osv import fields, orm
-from openerp.tools.translate import _
class AccountMoveLine(orm.Model):
+
"""Overriding Account move line in order to add last_rec_date.
- Last rec date is the date of the last reconciliation (full or partial) account move line"""
+ Last rec date is the date of the last reconciliation (full or partial)
+ account move line"""
_inherit = 'account.move.line'
def init(self, cr):
- ##We do not want to catch error as if sql is not run it will give invalid data
+ # We do not want to catch error as if sql is not run it will give
+ # invalid data
cr.execute("UPDATE account_move_line as acm "
" SET last_rec_date ="
" (SELECT date from account_move_line"
@@ -41,14 +43,16 @@ class AccountMoveLine(orm.Model):
cr.execute("UPDATE account_move_line as acm "
" SET last_rec_date ="
" (SELECT date from account_move_line"
- " WHERE reconcile_partial_id = acm.reconcile_partial_id"
+ " WHERE reconcile_partial_id"
+ " = acm.reconcile_partial_id"
" AND reconcile_partial_id IS NOT NULL"
" ORDER BY date DESC LIMIT 1)"
" WHERE last_rec_date is null;")
def _get_move_line_from_line_rec(self, cr, uid, ids, context=None):
moves = []
- for reconcile in self.pool.get('account.move.reconcile').browse(cr, uid, ids, context=context):
+ for reconcile in self.pool['account.move.reconcile'].browse(
+ cr, uid, ids, context=context):
for move_line in reconcile.line_partial_ids:
moves.append(move_line.id)
for move_line in reconcile.line_id:
@@ -64,22 +68,27 @@ class AccountMoveLine(orm.Model):
rec = line.reconcile_id or line.reconcile_partial_id or False
if rec:
# we use cursor in order to gain some perfs
- cursor.execute('SELECT date from account_move_line where'
- ' reconcile_id = %s OR reconcile_partial_id = %s'
- ' ORDER BY date DESC LIMIT 1 ',
- (rec.id, rec.id))
+ cursor.execute('SELECT date from account_move_line'
+ ' WHERE reconcile_id = %s'
+ ' OR reconcile_partial_id = %s'
+ ' ORDER BY date DESC LIMIT 1 ',
+ (rec.id, rec.id))
res_set = cursor.fetchone()
if res_set:
res[line.id] = {'last_rec_date': res_set[0]}
return res
_columns = {
- 'last_rec_date': fields.function(_get_last_rec_date,
- method=True,
- string='Last reconciliation date',
- store={'account.move.line': (lambda self, cr, uid, ids, c={}: ids, ['date'], 20),
- 'account.move.reconcile': (_get_move_line_from_line_rec, None, 20)},
- type='date',
- multi='all',
- help="the date of the last reconciliation (full or partial) account move line"),
- }
+ 'last_rec_date': fields.function(
+ _get_last_rec_date,
+ method=True,
+ string='Last reconciliation date',
+ store={'account.move.line': (lambda self, cr, uid, ids, c={}: ids,
+ ['date'], 20),
+ 'account.move.reconcile': (_get_move_line_from_line_rec,
+ None, 20)},
+ type='date',
+ multi='all',
+ help="the date of the last reconciliation (full or partial) \
+ account move line"),
+ }
diff --git a/account_financial_report_webkit/report/aged_partner_balance.py b/account_financial_report_webkit/report/aged_partner_balance.py
index ef81d326..721b787e 100644
--- a/account_financial_report_webkit/report/aged_partner_balance.py
+++ b/account_financial_report_webkit/report/aged_partner_balance.py
@@ -35,14 +35,15 @@ def make_ranges(top, offset):
:param offset: offset for ranges
:returns: list of sorted ranges tuples in days
- eg. [(-100000, 0), (0, offset), (offset, n*offset), ... (top, 100000)]
+ eg. [(-100000, 0), (0, offset),
+ (offset, n*offset), ... (top, 100000)]
"""
ranges = [(n, min(n + offset, top)) for n in xrange(0, top, offset)]
ranges.insert(0, (-100000000000, 0))
ranges.append((top, 100000000000))
return ranges
-#list of overdue ranges
+# list of overdue ranges
RANGES = make_ranges(120, 30)
@@ -53,20 +54,22 @@ def make_ranges_titles():
titles.append(_('Older'))
return titles
-#list of overdue ranges title
+# list of overdue ranges title
RANGES_TITLES = make_ranges_titles()
-#list of payable journal types
+# list of payable journal types
REC_PAY_TYPE = ('purchase', 'sale')
-#list of refund payable type
+# list of refund payable type
REFUND_TYPE = ('purchase_refund', 'sale_refund')
INV_TYPE = REC_PAY_TYPE + REFUND_TYPE
class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit):
+
"""Compute Aged Partner Balance based on result of Open Invoices"""
def __init__(self, cursor, uid, name, context=None):
- """Constructor, refer to :class:`openerp.report.report_sxw.rml_parse`"""
+ """Constructor,
+ refer to :class:`openerp.report.report_sxw.rml_parse`"""
super(AccountAgedTrialBalanceWebkit, self).__init__(cursor, uid, name,
context=context)
self.pool = pooler.get_pool(self.cr.dbname)
@@ -95,7 +98,8 @@ class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit):
('--header-left', header_report_name),
('--header-spacing', '2'),
('--footer-left', footer_date_time),
- ('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
+ ('--footer-right',
+ ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
('--footer-line',),
],
})
@@ -141,9 +145,10 @@ class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit):
data)
if aged_lines:
acc.aged_lines[part_id] = aged_lines
- acc.aged_totals = totals = self.compute_totals(acc.aged_lines.values())
+ acc.aged_totals = totals = self.compute_totals(
+ acc.aged_lines.values())
acc.aged_percents = self.compute_percents(totals)
- #Free some memory
+ # Free some memory
del(acc.ledger_lines)
return res
@@ -265,17 +270,18 @@ class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit):
:returns: delta in days
"""
- sale_lines = [x for x in ledger_lines if x['jtype'] in REC_PAY_TYPE and
- line['rec_id'] == x['rec_id']]
- refund_lines = [x for x in ledger_lines if x['jtype'] in REFUND_TYPE and
- line['rec_id'] == x['rec_id']]
+ sale_lines = [x for x in ledger_lines if x['jtype'] in REC_PAY_TYPE
+ and line['rec_id'] == x['rec_id']]
+ refund_lines = [x for x in ledger_lines if x['jtype'] in REFUND_TYPE
+ and line['rec_id'] == x['rec_id']]
if len(sale_lines) == 1:
reference_line = sale_lines[0]
elif len(refund_lines) == 1:
reference_line = refund_lines[0]
else:
reference_line = line
- key = 'date_maturity' if reference_line.get('date_maturity') else 'ldate'
+ key = 'date_maturity' if reference_line.get(
+ 'date_maturity') else 'ldate'
return self._compute_delay_from_key(key,
reference_line,
end_date)
@@ -398,6 +404,7 @@ class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit):
HeaderFooterTextWebKitParser(
'report.account.account_aged_trial_balance_webkit',
'account.account',
- 'addons/account_financial_report_webkit/report/templates/aged_trial_webkit.mako',
+ 'addons/account_financial_report_webkit/report/templates/\
+ aged_trial_webkit.mako',
parser=AccountAgedTrialBalanceWebkit,
)
diff --git a/account_financial_report_webkit/report/common_balance_reports.py b/account_financial_report_webkit/report/common_balance_reports.py
index 7d0945a7..c3017e3b 100644
--- a/account_financial_report_webkit/report/common_balance_reports.py
+++ b/account_financial_report_webkit/report/common_balance_reports.py
@@ -26,7 +26,9 @@ from .common_reports import CommonReportHeaderWebkit
class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
- """Define common helper for balance (trial balance, P&L, BS oriented financial report"""
+
+ """Define common helper for balance (trial balance, P&L, BS oriented
+ financial report"""
def _get_numbers_display(self, data):
return self._get_form_param('numbers_display', data)
@@ -35,7 +37,9 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
def find_key_by_value_in_list(dic, value):
return [key for key, val in dic.iteritems() if value in val][0]
- def _get_account_details(self, account_ids, target_move, fiscalyear, main_filter, start, stop, initial_balance_mode, context=None):
+ def _get_account_details(self, account_ids, target_move, fiscalyear,
+ main_filter, start, stop, initial_balance_mode,
+ context=None):
"""
Get details of accounts to display on the report
@param account_ids: ids of accounts to get details
@@ -44,21 +48,26 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
@param main_filter: selection filter period / date or none
@param start: start date or start period browse instance
@param stop: stop date or stop period browse instance
- @param initial_balance_mode: False: no calculation, 'opening_balance': from the opening period, 'initial_balance': computed from previous year / periods
- @return: dict of list containing accounts details, keys are the account ids
+ @param initial_balance_mode: False: no calculation,
+ 'opening_balance': from the opening period,
+ 'initial_balance': computed from previous year / periods
+ @return: dict of list containing accounts details, keys are
+ the account ids
"""
if context is None:
context = {}
account_obj = self.pool.get('account.account')
period_obj = self.pool.get('account.period')
- use_period_ids = main_filter in ('filter_no', 'filter_period', 'filter_opening')
+ use_period_ids = main_filter in (
+ 'filter_no', 'filter_period', 'filter_opening')
if use_period_ids:
if main_filter == 'filter_opening':
period_ids = [start.id]
else:
- period_ids = period_obj.build_ctx_periods(self.cursor, self.uid, start.id, stop.id)
+ period_ids = period_obj.build_ctx_periods(
+ self.cursor, self.uid, start.id, stop.id)
# never include the opening in the debit / credit amounts
period_ids = self.exclude_opening_periods(period_ids)
@@ -66,7 +75,8 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
if initial_balance_mode == 'opening_balance':
init_balance = self._read_opening_balance(account_ids, start)
elif initial_balance_mode:
- init_balance = self._compute_initial_balances(account_ids, start, fiscalyear)
+ init_balance = self._compute_initial_balances(
+ account_ids, start, fiscalyear)
ctx = context.copy()
ctx.update({'state': target_move,
@@ -79,42 +89,52 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
'date_to': stop})
accounts = account_obj.read(
- self.cursor,
- self.uid,
- account_ids,
- ['type', 'code', 'name', 'debit', 'credit', 'balance', 'parent_id', 'level', 'child_id'],
- ctx)
+ self.cursor,
+ self.uid,
+ account_ids,
+ ['type', 'code', 'name', 'debit', 'credit',
+ 'balance', 'parent_id', 'level', 'child_id'],
+ ctx)
accounts_by_id = {}
for account in accounts:
if init_balance:
# sum for top level views accounts
- child_ids = account_obj._get_children_and_consol(self.cursor, self.uid, account['id'], ctx)
+ child_ids = account_obj._get_children_and_consol(
+ self.cursor, self.uid, account['id'], ctx)
if child_ids:
child_init_balances = [
- init_bal['init_balance']
- for acnt_id, init_bal in init_balance.iteritems()
- if acnt_id in child_ids]
+ init_bal['init_balance']
+ for acnt_id, init_bal in init_balance.iteritems()
+ if acnt_id in child_ids]
top_init_balance = reduce(add, child_init_balances)
account['init_balance'] = top_init_balance
else:
account.update(init_balance[account['id']])
- account['balance'] = account['init_balance'] + account['debit'] - account['credit']
+ account['balance'] = account['init_balance'] + \
+ account['debit'] - account['credit']
accounts_by_id[account['id']] = account
return accounts_by_id
- def _get_comparison_details(self, data, account_ids, target_move, comparison_filter, index):
+ def _get_comparison_details(self, data, account_ids, target_move,
+ comparison_filter, index):
"""
@param data: data of the wizard form
@param account_ids: ids of the accounts to get details
- @param comparison_filter: selected filter on the form for the comparison (filter_no, filter_year, filter_period, filter_date)
- @param index: index of the fields to get (ie. comp1_fiscalyear_id where 1 is the index)
+ @param comparison_filter: selected filter on the form for
+ the comparison (filter_no, filter_year, filter_period,
+ filter_date)
+ @param index: index of the fields to get
+ (ie. comp1_fiscalyear_id where 1 is the index)
@return: dict of account details (key = account id)
"""
- fiscalyear = self._get_info(data, "comp%s_fiscalyear_id" % (index,), 'account.fiscalyear')
- start_period = self._get_info(data, "comp%s_period_from" % (index,), 'account.period')
- stop_period = self._get_info(data, "comp%s_period_to" % (index,), 'account.period')
+ fiscalyear = self._get_info(
+ data, "comp%s_fiscalyear_id" % (index,), 'account.fiscalyear')
+ start_period = self._get_info(
+ data, "comp%s_period_from" % (index,), 'account.period')
+ stop_period = self._get_info(
+ data, "comp%s_period_to" % (index,), 'account.period')
start_date = self._get_form_param("comp%s_date_from" % (index,), data)
stop_date = self._get_form_param("comp%s_date_to" % (index,), data)
init_balance = self.is_initial_balance_enabled(comparison_filter)
@@ -124,13 +144,17 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
details_filter = comparison_filter
if comparison_filter != 'filter_no':
start_period, stop_period, start, stop = \
- self._get_start_stop_for_filter(comparison_filter, fiscalyear, start_date, stop_date, start_period, stop_period)
+ self._get_start_stop_for_filter(
+ comparison_filter, fiscalyear, start_date, stop_date,
+ start_period, stop_period)
if comparison_filter == 'filter_year':
details_filter = 'filter_no'
- initial_balance_mode = init_balance and self._get_initial_balance_mode(start) or False
- accounts_by_ids = self._get_account_details(account_ids, target_move, fiscalyear, details_filter,
- start, stop, initial_balance_mode)
+ initial_balance_mode = init_balance \
+ and self._get_initial_balance_mode(start) or False
+ accounts_by_ids = self._get_account_details(
+ account_ids, target_move, fiscalyear, details_filter,
+ start, stop, initial_balance_mode)
comp_params = {
'comparison_filter': comparison_filter,
'fiscalyear': fiscalyear,
@@ -146,14 +170,16 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
"""
@param balance: current balance
@param previous_balance: last balance
- @return: dict of form {'diff': difference, 'percent_diff': diff in percentage}
+ @return: dict of form {'diff': difference,
+ 'percent_diff': diff in percentage}
"""
diff = balance - previous_balance
obj_precision = self.pool.get('decimal.precision')
- precision = obj_precision.precision_get(self.cursor, self.uid, 'Account')
- # round previous balance with account precision to avoid big numbers if previous
- # balance is 0.0000001 or a any very small number
+ precision = obj_precision.precision_get(
+ self.cursor, self.uid, 'Account')
+ # round previous balance with account precision to avoid big numbers
+ # if previous balance is 0.0000001 or a any very small number
if round(previous_balance, precision) == 0:
percent_diff = False
else:
@@ -165,13 +191,18 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
"""
@param data: data of the report
@param comparison_number: number of comparisons
- @return: list of comparison filters, nb of comparisons used and comparison mode (no_comparison, single, multiple)
+ @return: list of comparison filters, nb of comparisons used and
+ comparison mode (no_comparison, single, multiple)
"""
comp_filters = []
for index in range(comparison_number):
- comp_filters.append(self._get_form_param("comp%s_filter" % (index,), data, default='filter_no'))
+ comp_filters.append(
+ self._get_form_param("comp%s_filter" % (index,), data,
+ default='filter_no'))
- nb_comparisons = len([comp_filter for comp_filter in comp_filters if comp_filter != 'filter_no'])
+ nb_comparisons = len(
+ [comp_filter for comp_filter in comp_filters
+ if comp_filter != 'filter_no'])
if not nb_comparisons:
comparison_mode = 'no_comparison'
elif nb_comparisons > 1:
@@ -180,12 +211,14 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
comparison_mode = 'single'
return comp_filters, nb_comparisons, comparison_mode
- def _get_start_stop_for_filter(self, main_filter, fiscalyear, start_date, stop_date, start_period, stop_period):
+ def _get_start_stop_for_filter(self, main_filter, fiscalyear, start_date,
+ stop_date, start_period, stop_period):
if main_filter in ('filter_no', 'filter_year'):
start_period = self.get_first_fiscalyear_period(fiscalyear)
stop_period = self.get_last_fiscalyear_period(fiscalyear)
elif main_filter == 'filter_opening':
- opening_period = self._get_st_fiscalyear_period(fiscalyear, special=True)
+ opening_period = self._get_st_fiscalyear_period(
+ fiscalyear, special=True)
start_period = stop_period = opening_period
if main_filter == 'filter_date':
start = start_date
@@ -197,11 +230,14 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
return start_period, stop_period, start, stop
def compute_balance_data(self, data, filter_report_type=None):
- new_ids = data['form']['account_ids'] or data['form']['chart_account_id']
- max_comparison = self._get_form_param('max_comparison', data, default=0)
+ new_ids = data['form']['account_ids'] or data[
+ 'form']['chart_account_id']
+ max_comparison = self._get_form_param(
+ 'max_comparison', data, default=0)
main_filter = self._get_form_param('filter', data, default='filter_no')
- comp_filters, nb_comparisons, comparison_mode = self._comp_filters(data, max_comparison)
+ comp_filters, nb_comparisons, comparison_mode = self._comp_filters(
+ data, max_comparison)
fiscalyear = self.get_fiscalyear_br(data)
@@ -214,51 +250,75 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
chart_account = self._get_chart_account_id_br(data)
start_period, stop_period, start, stop = \
- self._get_start_stop_for_filter(main_filter, fiscalyear, start_date, stop_date, start_period, stop_period)
+ self._get_start_stop_for_filter(main_filter, fiscalyear,
+ start_date, stop_date,
+ start_period, stop_period)
init_balance = self.is_initial_balance_enabled(main_filter)
- initial_balance_mode = init_balance and self._get_initial_balance_mode(start) or False
+ initial_balance_mode = init_balance and self._get_initial_balance_mode(
+ start) or False
# Retrieving accounts
- account_ids = self.get_all_accounts(new_ids, only_type=filter_report_type)
+ account_ids = self.get_all_accounts(
+ new_ids, only_type=filter_report_type)
# get details for each accounts, total of debit / credit / balance
- accounts_by_ids = self._get_account_details(account_ids, target_move, fiscalyear, main_filter, start, stop, initial_balance_mode)
+ accounts_by_ids = self._get_account_details(
+ account_ids, target_move, fiscalyear, main_filter, start, stop,
+ initial_balance_mode)
comparison_params = []
comp_accounts_by_ids = []
for index in range(max_comparison):
if comp_filters[index] != 'filter_no':
- comparison_result, comp_params = self._get_comparison_details(data, account_ids, target_move, comp_filters[index], index)
+ comparison_result, comp_params = self._get_comparison_details(
+ data, account_ids, target_move, comp_filters[index], index)
comparison_params.append(comp_params)
comp_accounts_by_ids.append(comparison_result)
to_display = dict.fromkeys(account_ids, True)
objects = []
- for account in self.pool.get('account.account').browse(self.cursor, self.uid, account_ids):
+ for account in self.pool.get('account.account').browse(self.cursor,
+ self.uid,
+ account_ids):
if not account.parent_id: # hide top level account
continue
if account.type == 'consolidation':
- to_display.update(dict([(a.id, False) for a in account.child_consol_ids]))
+ to_display.update(
+ dict([(a.id, False) for a in account.child_consol_ids]))
elif account.type == 'view':
- to_display.update(dict([(a.id, True) for a in account.child_id]))
+ to_display.update(
+ dict([(a.id, True) for a in account.child_id]))
account.debit = accounts_by_ids[account.id]['debit']
account.credit = accounts_by_ids[account.id]['credit']
account.balance = accounts_by_ids[account.id]['balance']
- account.init_balance = accounts_by_ids[account.id].get('init_balance', 0.0)
+ account.init_balance = accounts_by_ids[
+ account.id].get('init_balance', 0.0)
- display_account = False # if any amount is != 0 in comparisons, we have to display the whole account
+ # if any amount is != 0 in comparisons, we have to display the
+ # whole account
+ display_account = False
comp_accounts = []
for comp_account_by_id in comp_accounts_by_ids:
values = comp_account_by_id.get(account.id)
- values.update(self._get_diff(account.balance, values['balance']))
- display_account = any((values.get('credit', 0.0), values.get('debit', 0.0), values.get('balance', 0.0), values.get('init_balance', 0.0)))
+ values.update(
+ self._get_diff(account.balance, values['balance']))
+ display_account = any((values.get('credit', 0.0),
+ values.get('debit', 0.0),
+ values.get('balance', 0.0),
+ values.get('init_balance', 0.0)))
comp_accounts.append(values)
account.comparisons = comp_accounts
- # we have to display the account if a comparison as an amount or if we have an amount in the main column
- # we set it as a property to let the data in the report if someone want to use it in a custom report
- display_account = display_account or any((account.debit, account.credit, account.balance, account.init_balance))
- to_display.update({account.id: display_account and to_display[account.id]})
+ # we have to display the account if a comparison as an amount or
+ # if we have an amount in the main column
+ # we set it as a property to let the data in the report if someone
+ # want to use it in a custom report
+ display_account = display_account or any((account.debit,
+ account.credit,
+ account.balance,
+ account.init_balance))
+ to_display.update(
+ {account.id: display_account and to_display[account.id]})
objects.append(account)
for account in objects:
diff --git a/account_financial_report_webkit/report/common_partner_balance_reports.py b/account_financial_report_webkit/report/common_partner_balance_reports.py
index eeec0c53..08cc3818 100644
--- a/account_financial_report_webkit/report/common_partner_balance_reports.py
+++ b/account_financial_report_webkit/report/common_partner_balance_reports.py
@@ -27,11 +27,16 @@ from .common_balance_reports import CommonBalanceReportHeaderWebkit
from .common_partner_reports import CommonPartnersReportHeaderWebkit
-class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, CommonPartnersReportHeaderWebkit):
- """Define common helper for balance (trial balance, P&L, BS oriented financial report"""
+class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit,
+ CommonPartnersReportHeaderWebkit):
- def _get_account_partners_details(self, account_by_ids, main_filter, target_move, start,
- stop, initial_balance_mode, partner_filter_ids=False):
+ """Define common helper for balance (trial balance, P&L,
+ BS oriented financial report"""
+
+ def _get_account_partners_details(self, account_by_ids, main_filter,
+ target_move, start, stop,
+ initial_balance_mode,
+ partner_filter_ids=False):
res = {}
filter_from = False
if main_filter in ('filter_period', 'filter_no', 'filter_opening'):
@@ -41,51 +46,71 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, Co
partners_init_balances_by_ids = {}
for account_id, account_details in account_by_ids.iteritems():
- partners_init_balances_by_ids.update(self._get_partners_initial_balances(account_id,
- start,
- initial_balance_mode,
- partner_filter_ids=partner_filter_ids,
- exclude_reconcile=False)) # we'll never exclude reconciled entries in the legal reports
+ partners_init_balances_by_ids.update(
+ self._get_partners_initial_balances(
+ account_id, start, initial_balance_mode,
+ partner_filter_ids=partner_filter_ids,
+ # we'll never exclude reconciled entries in the legal
+ # reports
+ exclude_reconcile=False))
opening_mode = 'exclude_opening'
if main_filter == 'filter_opening':
opening_mode = 'include_opening'
# get credit and debit for partner
- details = self._get_partners_totals_account(filter_from,
- account_id,
- start,
- stop,
- target_move,
- partner_filter_ids=partner_filter_ids,
- mode=opening_mode)
+ details = self._get_partners_totals_account(
+ filter_from,
+ account_id,
+ start,
+ stop,
+ target_move,
+ partner_filter_ids=partner_filter_ids,
+ mode=opening_mode)
# merge initial balances in partner details
if partners_init_balances_by_ids.get(account_id):
- for partner_id, initial_balances in partners_init_balances_by_ids[account_id].iteritems():
+ for partner_id, initial_balances in \
+ partners_init_balances_by_ids[account_id].iteritems():
if initial_balances.get('init_balance'):
- details[partner_id].update({'init_balance': initial_balances['init_balance']})
+ details[partner_id].update(
+ {'init_balance': initial_balances['init_balance']})
# compute balance for the partner
for partner_id, partner_details in details.iteritems():
- details[partner_id]['balance'] = details[partner_id].get('init_balance', 0.0) +\
- details[partner_id].get('debit', 0.0) -\
- details[partner_id].get('credit', 0.0)
+ details[partner_id]['balance'] = details[partner_id].\
+ get('init_balance', 0.0) + \
+ details[partner_id].get('debit', 0.0) - \
+ details[partner_id].get('credit', 0.0)
res[account_id] = details
return res
- def _get_partners_initial_balances(self, account_ids, start_period, initial_balance_mode, partner_filter_ids=None, exclude_reconcile=False):
- # we get the initial balance from the opening period (opening_balance) when the opening period is included in the start period and
- # when there is at least one entry in the opening period. Otherwise we compute it from previous periods
+ def _get_partners_initial_balances(self, account_ids, start_period,
+ initial_balance_mode,
+ partner_filter_ids=None,
+ exclude_reconcile=False):
+ # we get the initial balance from the opening period (opening_balance)
+ # when the opening period is included in the start period and
+ # when there is at least one entry in the opening period. Otherwise we
+ # compute it from previous periods
if initial_balance_mode == 'opening_balance':
- opening_period_selected = self.get_included_opening_period(start_period)
- res = self._compute_partners_initial_balances(account_ids, start_period, partner_filter_ids, force_period_ids=opening_period_selected, exclude_reconcile=exclude_reconcile)
+ opening_period_selected = self.get_included_opening_period(
+ start_period)
+ res = self._compute_partners_initial_balances(
+ account_ids, start_period, partner_filter_ids,
+ force_period_ids=opening_period_selected,
+ exclude_reconcile=exclude_reconcile)
elif initial_balance_mode == 'initial_balance':
- res = self._compute_partners_initial_balances(account_ids, start_period, partner_filter_ids, exclude_reconcile=exclude_reconcile)
+ res = self._compute_partners_initial_balances(
+ account_ids, start_period, partner_filter_ids,
+ exclude_reconcile=exclude_reconcile)
else:
res = {}
return res
- def _get_partners_totals_account(self, filter_from, account_id, start, stop, target_move, partner_filter_ids=None, mode='exclude_opening'):
+ def _get_partners_totals_account(self, filter_from, account_id, start,
+ stop, target_move,
+ partner_filter_ids=None,
+ mode='exclude_opening'):
final_res = defaultdict(dict)
sql_select = """
@@ -94,17 +119,20 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, Co
sum(account_move_line.credit) AS credit
FROM account_move_line"""
sql_joins = ''
- sql_where = "WHERE account_move_line.account_id = %(account_id)s AND account_move_line.state = 'valid' "
+ sql_where = "WHERE account_move_line.account_id = %(account_id)s \
+ AND account_move_line.state = 'valid' "
method = getattr(self, '_get_query_params_from_' + filter_from + 's')
sql_conditions, search_params = method(start, stop, mode=mode)
sql_where += sql_conditions
if partner_filter_ids:
- sql_where += " AND account_move_line.partner_id in %(partner_ids)s"
+ sql_where += " AND account_move_line.partner_id \
+ in %(partner_ids)s"
search_params.update({'partner_ids': tuple(partner_filter_ids)})
if target_move == 'posted':
- sql_joins += "INNER JOIN account_move ON account_move_line.move_id = account_move.id"
+ sql_joins += "INNER JOIN account_move \
+ ON account_move_line.move_id = account_move.id"
sql_where += " AND account_move.state = %(target_move)s"
search_params.update({'target_move': target_move})
@@ -128,19 +156,26 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, Co
filter_type = ('payable',)
return filter_type
- def _get_partners_comparison_details(self, data, account_ids, target_move, comparison_filter, index, partner_filter_ids=False):
+ def _get_partners_comparison_details(self, data, account_ids, target_move,
+ comparison_filter, index,
+ partner_filter_ids=False):
"""
@param data: data of the wizard form
@param account_ids: ids of the accounts to get details
- @param comparison_filter: selected filter on the form for the comparison (filter_no, filter_year, filter_period, filter_date)
- @param index: index of the fields to get (ie. comp1_fiscalyear_id where 1 is the index)
+ @param comparison_filter: selected filter on the form for
+ the comparison (filter_no, filter_year, filter_period, filter_date)
+ @param index: index of the fields to get (ie. comp1_fiscalyear_id
+ where 1 is the index)
@param partner_filter_ids: list of ids of partners to select
@return: dict of account details (key = account id)
"""
- fiscalyear = self._get_info(data, "comp%s_fiscalyear_id" % (index,), 'account.fiscalyear')
- start_period = self._get_info(data, "comp%s_period_from" % (index,), 'account.period')
- stop_period = self._get_info(data, "comp%s_period_to" % (index,), 'account.period')
+ fiscalyear = self._get_info(
+ data, "comp%s_fiscalyear_id" % (index,), 'account.fiscalyear')
+ start_period = self._get_info(
+ data, "comp%s_period_from" % (index,), 'account.period')
+ stop_period = self._get_info(
+ data, "comp%s_period_to" % (index,), 'account.period')
start_date = self._get_form_param("comp%s_date_from" % (index,), data)
stop_date = self._get_form_param("comp%s_date_to" % (index,), data)
init_balance = self.is_initial_balance_enabled(comparison_filter)
@@ -149,22 +184,30 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, Co
accounts_details_by_ids = defaultdict(dict)
if comparison_filter != 'filter_no':
start_period, stop_period, start, stop = \
- self._get_start_stop_for_filter(comparison_filter, fiscalyear, start_date, stop_date, start_period, stop_period)
+ self._get_start_stop_for_filter(
+ comparison_filter, fiscalyear, start_date, stop_date,
+ start_period, stop_period)
details_filter = comparison_filter
if comparison_filter == 'filter_year':
details_filter = 'filter_no'
- initial_balance_mode = init_balance and self._get_initial_balance_mode(start) or False
+ initial_balance_mode = init_balance \
+ and self._get_initial_balance_mode(start) or False
- accounts_by_ids = self._get_account_details(account_ids, target_move, fiscalyear, details_filter, start, stop, initial_balance_mode)
+ accounts_by_ids = self._get_account_details(
+ account_ids, target_move, fiscalyear, details_filter, start,
+ stop, initial_balance_mode)
- partner_details_by_ids = self._get_account_partners_details(accounts_by_ids, details_filter,
- target_move, start, stop, initial_balance_mode,
- partner_filter_ids=partner_filter_ids)
+ partner_details_by_ids = self._get_account_partners_details(
+ accounts_by_ids, details_filter,
+ target_move, start, stop, initial_balance_mode,
+ partner_filter_ids=partner_filter_ids)
for account_id in account_ids:
- accounts_details_by_ids[account_id]['account'] = accounts_by_ids[account_id]
- accounts_details_by_ids[account_id]['partners_amounts'] = partner_details_by_ids[account_id]
+ accounts_details_by_ids[account_id][
+ 'account'] = accounts_by_ids[account_id]
+ accounts_details_by_ids[account_id][
+ 'partners_amounts'] = partner_details_by_ids[account_id]
comp_params = {
'comparison_filter': comparison_filter,
@@ -177,11 +220,14 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, Co
return accounts_details_by_ids, comp_params
def compute_partner_balance_data(self, data, filter_report_type=None):
- new_ids = data['form']['account_ids'] or data['form']['chart_account_id']
- max_comparison = self._get_form_param('max_comparison', data, default=0)
+ new_ids = data['form']['account_ids'] or data[
+ 'form']['chart_account_id']
+ max_comparison = self._get_form_param(
+ 'max_comparison', data, default=0)
main_filter = self._get_form_param('filter', data, default='filter_no')
- comp_filters, nb_comparisons, comparison_mode = self._comp_filters(data, max_comparison)
+ comp_filters, nb_comparisons, comparison_mode = self._comp_filters(
+ data, max_comparison)
fiscalyear = self.get_fiscalyear_br(data)
@@ -197,62 +243,78 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, Co
filter_type = self._get_filter_type(result_selection)
start_period, stop_period, start, stop = \
- self._get_start_stop_for_filter(main_filter, fiscalyear, start_date, stop_date, start_period, stop_period)
+ self._get_start_stop_for_filter(
+ main_filter, fiscalyear, start_date, stop_date, start_period,
+ stop_period)
initial_balance = self.is_initial_balance_enabled(main_filter)
- initial_balance_mode = initial_balance and self._get_initial_balance_mode(start) or False
+ initial_balance_mode = initial_balance \
+ and self._get_initial_balance_mode(start) or False
# Retrieving accounts
- account_ids = self.get_all_accounts(new_ids, only_type=filter_type,
- filter_report_type=filter_report_type)
+ account_ids = self.get_all_accounts(
+ new_ids, only_type=filter_type,
+ filter_report_type=filter_report_type)
# get details for each accounts, total of debit / credit / balance
- accounts_by_ids = self._get_account_details(account_ids, target_move, fiscalyear, main_filter, start, stop, initial_balance_mode)
+ accounts_by_ids = self._get_account_details(
+ account_ids, target_move, fiscalyear, main_filter, start, stop,
+ initial_balance_mode)
- partner_details_by_ids = self._get_account_partners_details(accounts_by_ids,
- main_filter,
- target_move,
- start,
- stop,
- initial_balance_mode,
- partner_filter_ids=partner_ids)
+ partner_details_by_ids = self._get_account_partners_details(
+ accounts_by_ids, main_filter, target_move, start, stop,
+ initial_balance_mode, partner_filter_ids=partner_ids)
comparison_params = []
comp_accounts_by_ids = []
for index in range(max_comparison):
if comp_filters[index] != 'filter_no':
- comparison_result, comp_params = self._get_partners_comparison_details(data, account_ids,
- target_move, comp_filters[index],
- index, partner_filter_ids=partner_ids)
+ comparison_result, comp_params = self.\
+ _get_partners_comparison_details(
+ data, account_ids,
+ target_move,
+ comp_filters[index],
+ index,
+ partner_filter_ids=partner_ids)
comparison_params.append(comp_params)
comp_accounts_by_ids.append(comparison_result)
objects = []
- for account in self.pool.get('account.account').browse(self.cursor, self.uid, account_ids):
+ for account in self.pool.get('account.account').browse(self.cursor,
+ self.uid,
+ account_ids):
if not account.parent_id: # hide top level account
continue
account.debit = accounts_by_ids[account.id]['debit']
account.credit = accounts_by_ids[account.id]['credit']
account.balance = accounts_by_ids[account.id]['balance']
- account.init_balance = accounts_by_ids[account.id].get('init_balance', 0.0)
+ account.init_balance = accounts_by_ids[
+ account.id].get('init_balance', 0.0)
account.partners_amounts = partner_details_by_ids[account.id]
comp_accounts = []
for comp_account_by_id in comp_accounts_by_ids:
values = comp_account_by_id.get(account.id)
- values['account'].update(self._get_diff(account.balance, values['account'].get('balance', 0.0)))
+ values['account'].update(
+ self._get_diff(account.balance,
+ values['account'].get('balance', 0.0)))
comp_accounts.append(values)
- for partner_id, partner_values in values['partners_amounts'].copy().iteritems():
- base_partner_balance = account.partners_amounts[partner_id]['balance'] if \
- account.partners_amounts.get(partner_id) else 0.0
- partner_values.update(self._get_diff(base_partner_balance,
- partner_values.get('balance', 0.0)))
- values['partners_amounts'][partner_id].update(partner_values)
+ for partner_id, partner_values in \
+ values['partners_amounts'].copy().iteritems():
+ base_partner_balance = account.partners_amounts[
+ partner_id]['balance'] if \
+ account.partners_amounts.get(partner_id) else 0.0
+ partner_values.update(self._get_diff(
+ base_partner_balance,
+ partner_values.get('balance', 0.0)))
+ values['partners_amounts'][
+ partner_id].update(partner_values)
account.comparisons = comp_accounts
- all_partner_ids = reduce(add, [comp['partners_amounts'].keys() for comp in comp_accounts],
+ all_partner_ids = reduce(add, [comp['partners_amounts'].keys()
+ for comp in comp_accounts],
account.partners_amounts.keys())
account.partners_order = self._order_partners(all_partner_ids)
diff --git a/account_financial_report_webkit/report/common_partner_reports.py b/account_financial_report_webkit/report/common_partner_reports.py
index 38e18743..55ce8efd 100644
--- a/account_financial_report_webkit/report/common_partner_reports.py
+++ b/account_financial_report_webkit/report/common_partner_reports.py
@@ -30,10 +30,15 @@ from .common_reports import CommonReportHeaderWebkit
class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
+
"""Define common helper for partner oriented financial report"""
- ####################Account move line retrieval helper ##########################
- def get_partners_move_lines_ids(self, account_id, main_filter, start, stop, target_move,
+ ######################################
+ # Account move line retrieval helper #
+ ######################################
+
+ def get_partners_move_lines_ids(self, account_id, main_filter, start, stop,
+ target_move,
exclude_reconcile=False,
partner_filter=False):
filter_from = False
@@ -42,13 +47,10 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
elif main_filter == 'filter_date':
filter_from = 'date'
if filter_from:
- return self._get_partners_move_line_ids(filter_from,
- account_id,
- start,
- stop,
- target_move,
- exclude_reconcile=exclude_reconcile,
- partner_filter=partner_filter)
+ return self._get_partners_move_line_ids(
+ filter_from, account_id, start, stop, target_move,
+ exclude_reconcile=exclude_reconcile,
+ partner_filter=partner_filter)
def _get_first_special_period(self):
"""
@@ -59,8 +61,8 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
and it returns the id of the first period for which `special` is True
in this fiscal year.
- It is used for example in the partners reports, where we have to include
- the first, and only the first opening period.
+ It is used for example in the partners reports, where we have to
+ include the first, and only the first opening period.
:return: browse record of the first special period.
"""
@@ -71,31 +73,36 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
# it may so
if not first_entry_id:
return
- first_entry = move_line_obj.browse(self.cr, self.uid, first_entry_id[0])
+ first_entry = move_line_obj.browse(
+ self.cr, self.uid, first_entry_id[0])
fiscalyear = first_entry.period_id.fiscalyear_id
- special_periods = [period for period in fiscalyear.period_ids if period.special]
+ special_periods = [
+ period for period in fiscalyear.period_ids if period.special]
# so, we have no opening period on the first year, nothing to return
if not special_periods:
return
return min(special_periods,
- key=lambda p: datetime.strptime(p.date_start, DEFAULT_SERVER_DATE_FORMAT))
+ key=lambda p: datetime.strptime(p.date_start,
+ DEFAULT_SERVER_DATE_FORMAT))
- def _get_period_range_from_start_period(self, start_period, include_opening=False,
+ def _get_period_range_from_start_period(self, start_period,
+ include_opening=False,
fiscalyear=False,
stop_at_previous_opening=False):
"""We retrieve all periods before start period"""
periods = super(CommonPartnersReportHeaderWebkit, self).\
- _get_period_range_from_start_period(
- start_period,
- include_opening=include_opening,
- fiscalyear=fiscalyear,
- stop_at_previous_opening=stop_at_previous_opening)
+ _get_period_range_from_start_period(
+ start_period,
+ include_opening=include_opening,
+ fiscalyear=fiscalyear,
+ stop_at_previous_opening=stop_at_previous_opening)
first_special = self._get_first_special_period()
if first_special and first_special.id not in periods:
periods.append(first_special.id)
return periods
- def _get_query_params_from_periods(self, period_start, period_stop, mode='exclude_opening'):
+ def _get_query_params_from_periods(self, period_start, period_stop,
+ mode='exclude_opening'):
"""
Build the part of the sql "where clause" which filters on the selected
periods.
@@ -106,7 +113,7 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
"""
# we do not want opening period so we exclude opening
periods = self.pool.get('account.period').build_ctx_periods(
- self.cr, self.uid, period_start.id, period_stop.id)
+ self.cr, self.uid, period_start.id, period_stop.id)
if not periods:
return []
@@ -118,7 +125,8 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
sql_conditions = ""
if periods:
- sql_conditions = " AND account_move_line.period_id in %(period_ids)s"
+ sql_conditions = " AND account_move_line.period_id in \
+ %(period_ids)s"
return sql_conditions, search_params
@@ -138,14 +146,18 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
'date_start': date_start,
'date_stop': date_stop}
- sql_conditions = " AND account_move_line.period_id not in %(period_ids)s" \
- " AND account_move_line.date between date(%(date_start)s) and date((%(date_stop)s))"
+ sql_conditions = " AND account_move_line.period_id not \
+ in %(period_ids)s \
+ AND account_move_line.date between \
+ date(%(date_start)s) and date((%(date_stop)s))"
return sql_conditions, search_params
def _get_partners_move_line_ids(self, filter_from, account_id, start, stop,
- target_move, opening_mode='exclude_opening',
- exclude_reconcile=False, partner_filter=None):
+ target_move,
+ opening_mode='exclude_opening',
+ exclude_reconcile=False,
+ partner_filter=None):
"""
:param str filter_from: "periods" or "dates"
@@ -162,7 +174,8 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
final_res = defaultdict(list)
- sql_select = "SELECT account_move_line.id, account_move_line.partner_id FROM account_move_line"
+ sql_select = "SELECT account_move_line.id, \
+ account_move_line.partner_id FROM account_move_line"
sql_joins = ''
sql_where = " WHERE account_move_line.account_id = %(account_ids)s " \
" AND account_move_line.state = 'valid' "
@@ -174,13 +187,17 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
if exclude_reconcile:
sql_where += (" AND ((account_move_line.reconcile_id IS NULL)"
- " OR (account_move_line.reconcile_id IS NOT NULL AND account_move_line.last_rec_date > date(%(date_stop)s)))")
+ " OR (account_move_line.reconcile_id IS NOT NULL \
+ AND account_move_line.last_rec_date > \
+ date(%(date_stop)s)))")
if partner_filter:
- sql_where += " AND account_move_line.partner_id in %(partner_ids)s"
+ sql_where += " AND account_move_line.partner_id \
+ in %(partner_ids)s"
if target_move == 'posted':
- sql_joins += "INNER JOIN account_move ON account_move_line.move_id = account_move.id"
+ sql_joins += "INNER JOIN account_move \
+ ON account_move_line.move_id = account_move.id"
sql_where += " AND account_move.state = %(target_move)s"
search_params.update({'target_move': target_move})
@@ -197,14 +214,16 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
final_res[row['partner_id']].append(row['id'])
return final_res
- def _get_clearance_move_line_ids(self, move_line_ids, date_stop, date_until):
+ def _get_clearance_move_line_ids(self, move_line_ids, date_stop,
+ date_until):
if not move_line_ids:
return []
move_line_obj = self.pool.get('account.move.line')
# we do not use orm in order to gain perfo
# In this case I have to test the effective gain over an itteration
# Actually ORM does not allows distinct behavior
- sql = "Select distinct reconcile_id from account_move_line where id in %s"
+ sql = "Select distinct reconcile_id from account_move_line \
+ where id in %s"
self.cursor.execute(sql, (tuple(move_line_ids),))
rec_ids = self.cursor.fetchall()
if rec_ids:
@@ -218,7 +237,9 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
else:
return []
- ####################Initial Partner Balance helper ########################
+ ##############################################
+ # Initial Partner Balance helper #
+ ##############################################
def _tree_move_line_ids(self, move_lines_data, key=None):
"""
@@ -243,19 +264,24 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
res[account_id][partner_id] = row
return res
- def _partners_initial_balance_line_ids(self, account_ids, start_period, partner_filter, exclude_reconcile=False, force_period_ids=False, date_stop=None):
+ def _partners_initial_balance_line_ids(self, account_ids, start_period,
+ partner_filter,
+ exclude_reconcile=False,
+ force_period_ids=False,
+ date_stop=None):
# take ALL previous periods
period_ids = force_period_ids \
- if force_period_ids \
- else self._get_period_range_from_start_period(start_period, fiscalyear=False, include_opening=False)
+ if force_period_ids \
+ else self._get_period_range_from_start_period(
+ start_period, fiscalyear=False, include_opening=False)
if not period_ids:
period_ids = [-1]
search_param = {
- 'date_start': start_period.date_start,
- 'period_ids': tuple(period_ids),
- 'account_ids': tuple(account_ids),
- }
+ 'date_start': start_period.date_start,
+ 'period_ids': tuple(period_ids),
+ 'account_ids': tuple(account_ids),
+ }
sql = ("SELECT ml.id, ml.account_id, ml.partner_id "
"FROM account_move_line ml "
"INNER JOIN account_account a "
@@ -264,10 +290,12 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
"AND ml.account_id in %(account_ids)s ")
if exclude_reconcile:
if not date_stop:
- raise Exception("Missing \"date_stop\" to compute the open invoices.")
+ raise Exception(
+ "Missing \"date_stop\" to compute the open invoices.")
search_param.update({'date_stop': date_stop})
- sql += ("AND ((ml.reconcile_id IS NULL)"
- "OR (ml.reconcile_id IS NOT NULL AND ml.last_rec_date > date(%(date_stop)s))) ")
+ sql += ("AND ((ml.reconcile_id IS NULL) "
+ "OR (ml.reconcile_id IS NOT NULL \
+ AND ml.last_rec_date > date(%(date_stop)s))) ")
if partner_filter:
sql += "AND ml.partner_id in %(partner_ids)s "
search_param.update({'partner_ids': tuple(partner_filter)})
@@ -275,21 +303,28 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
self.cursor.execute(sql, search_param)
return self.cursor.dictfetchall()
- def _compute_partners_initial_balances(self, account_ids, start_period, partner_filter=None, exclude_reconcile=False, force_period_ids=False):
+ def _compute_partners_initial_balances(self, account_ids, start_period,
+ partner_filter=None,
+ exclude_reconcile=False,
+ force_period_ids=False):
"""We compute initial balance.
If form is filtered by date all initial balance are equal to 0
- This function will sum pear and apple in currency amount if account as no secondary currency"""
+ This function will sum pear and apple in currency amount if account
+ as no secondary currency"""
if isinstance(account_ids, (int, long)):
account_ids = [account_ids]
- move_line_ids = self._partners_initial_balance_line_ids(account_ids, start_period, partner_filter,
- exclude_reconcile=exclude_reconcile,
- force_period_ids=force_period_ids)
+ move_line_ids = self._partners_initial_balance_line_ids(
+ account_ids, start_period, partner_filter,
+ exclude_reconcile=exclude_reconcile,
+ force_period_ids=force_period_ids)
if not move_line_ids:
move_line_ids = [{'id': -1}]
sql = ("SELECT ml.account_id, ml.partner_id,"
" sum(ml.debit) as debit, sum(ml.credit) as credit,"
" sum(ml.debit-ml.credit) as init_balance,"
- " CASE WHEN a.currency_id ISNULL THEN 0.0 ELSE sum(ml.amount_currency) END as init_balance_currency, "
+ " CASE WHEN a.currency_id ISNULL THEN 0.0\
+ ELSE sum(ml.amount_currency) \
+ END as init_balance_currency, "
" c.name as currency_name "
"FROM account_move_line ml "
"INNER JOIN account_account a "
@@ -298,12 +333,17 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
"ON c.id = a.currency_id "
"WHERE ml.id in %(move_line_ids)s "
"GROUP BY ml.account_id, ml.partner_id, a.currency_id, c.name")
- search_param = {'move_line_ids': tuple([move_line['id'] for move_line in move_line_ids])}
+ search_param = {
+ 'move_line_ids': tuple([move_line['id'] for move_line in
+ move_line_ids])}
self.cursor.execute(sql, search_param)
res = self.cursor.dictfetchall()
return self._tree_move_line_ids(res)
- ####################Partner specific helper ################################
+ ############################################################
+ # Partner specific helper #
+ ############################################################
+
def _order_partners(self, *args):
"""We get the partner linked to all current accounts that are used.
We also use ensure that partner are ordered by name
@@ -316,11 +356,16 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
if not partner_ids:
return []
- existing_partner_ids = [partner_id for partner_id in partner_ids if partner_id]
+ existing_partner_ids = [
+ partner_id for partner_id in partner_ids if partner_id]
if existing_partner_ids:
- # We may use orm here as the performance optimization is not that big
- sql = ("SELECT name|| ' ' ||CASE WHEN ref IS NOT NULL THEN '('||ref||')' ELSE '' END, id, ref, name"
- " FROM res_partner WHERE id IN %s ORDER BY LOWER(name), ref")
+ # We may use orm here as the performance optimization is not that
+ # big
+ sql = ("SELECT name|| ' ' ||CASE WHEN ref IS NOT NULL \
+ THEN '('||ref||')' \
+ ELSE '' END, id, ref, name"
+ " FROM res_partner \
+ WHERE id IN %s ORDER BY LOWER(name), ref")
self.cursor.execute(sql, (tuple(set(existing_partner_ids)),))
res = self.cursor.fetchall()
diff --git a/account_financial_report_webkit/report/common_reports.py b/account_financial_report_webkit/report/common_reports.py
index 617cc97e..0dd56120 100644
--- a/account_financial_report_webkit/report/common_reports.py
+++ b/account_financial_report_webkit/report/common_reports.py
@@ -26,15 +26,22 @@ import logging
from openerp.osv import osv
from openerp.tools.translate import _
-from openerp.addons.account.report.common_report_header import common_report_header
+from openerp.addons.account.report.common_report_header \
+ import common_report_header
_logger = logging.getLogger('financial.reports.webkit')
MAX_MONSTER_SLICE = 50000
+
+
class CommonReportHeaderWebkit(common_report_header):
+
"""Define common helper for financial report"""
- ####################From getter helper #####################################
+ ######################################################################
+ # From getter helper #
+ ######################################################################
+
def get_start_period_br(self, data):
return self._get_info(data, 'period_from', 'account.period')
@@ -112,20 +119,26 @@ class CommonReportHeaderWebkit(common_report_header):
def _get_form_param(self, param, data, default=False):
return data.get('form', {}).get(param, default)
- ####################Account and account line filter helper #################
+ #############################################
+ # Account and account line filter helper #
+ #############################################
- def sort_accounts_with_structure(self, root_account_ids, account_ids, context=None):
+ def sort_accounts_with_structure(self, root_account_ids, account_ids,
+ context=None):
"""Sort accounts by code respecting their structure"""
def recursive_sort_by_code(accounts, parent):
sorted_accounts = []
# add all accounts with same parent
level_accounts = [account for account in accounts
- if account['parent_id'] and account['parent_id'][0] == parent['id']]
- # add consolidation children of parent, as they are logically on the same level
+ if account['parent_id']
+ and account['parent_id'][0] == parent['id']]
+ # add consolidation children of parent, as they are logically on
+ # the same level
if parent.get('child_consol_ids'):
level_accounts.extend([account for account in accounts
- if account['id'] in parent['child_consol_ids']])
+ if account['id']
+ in parent['child_consol_ids']])
# stop recursion if no children found
if not level_accounts:
return []
@@ -134,16 +147,17 @@ class CommonReportHeaderWebkit(common_report_header):
for level_account in level_accounts:
sorted_accounts.append(level_account['id'])
- sorted_accounts.extend(recursive_sort_by_code(accounts, parent=level_account))
+ sorted_accounts.extend(
+ recursive_sort_by_code(accounts, parent=level_account))
return sorted_accounts
if not account_ids:
return []
- accounts_data = self.pool.get('account.account').read(self.cr, self.uid,
- account_ids,
- ['id', 'parent_id', 'level', 'code', 'child_consol_ids'],
- context=context)
+ accounts_data = self.pool.get('account.account').read(
+ self.cr, self.uid, account_ids,
+ ['id', 'parent_id', 'level', 'code', 'child_consol_ids'],
+ context=context)
sorted_accounts = []
@@ -151,7 +165,8 @@ class CommonReportHeaderWebkit(common_report_header):
if account_data['id'] in root_account_ids]
for root_account_data in root_accounts_data:
sorted_accounts.append(root_account_data['id'])
- sorted_accounts.extend(recursive_sort_by_code(accounts_data, root_account_data))
+ sorted_accounts.extend(
+ recursive_sort_by_code(accounts_data, root_account_data))
# fallback to unsorted accounts when sort failed
# sort fails when the levels are miscalculated by account.account
@@ -162,11 +177,14 @@ class CommonReportHeaderWebkit(common_report_header):
return sorted_accounts
- def get_all_accounts(self, account_ids, exclude_type=None, only_type=None, filter_report_type=None, context=None):
+ def get_all_accounts(self, account_ids, exclude_type=None, only_type=None,
+ filter_report_type=None, context=None):
"""Get all account passed in params with their childrens
- @param exclude_type: list of types to exclude (view, receivable, payable, consolidation, other)
- @param only_type: list of types to filter on (view, receivable, payable, consolidation, other)
+ @param exclude_type: list of types to exclude (view, receivable,
+ payable, consolidation, other)
+ @param only_type: list of types to filter on (view, receivable,
+ payable, consolidation, other)
@param filter_report_type: list of report type to filter on
"""
context = context or {}
@@ -176,9 +194,11 @@ class CommonReportHeaderWebkit(common_report_header):
acc_obj = self.pool.get('account.account')
for account_id in account_ids:
accounts.append(account_id)
- accounts += acc_obj._get_children_and_consol(self.cursor, self.uid, account_id, context=context)
+ accounts += acc_obj._get_children_and_consol(
+ self.cursor, self.uid, account_id, context=context)
res_ids = list(set(accounts))
- res_ids = self.sort_accounts_with_structure(account_ids, res_ids, context=context)
+ res_ids = self.sort_accounts_with_structure(
+ account_ids, res_ids, context=context)
if exclude_type or only_type or filter_report_type:
sql_filters = {'ids': tuple(res_ids)}
@@ -207,17 +227,22 @@ class CommonReportHeaderWebkit(common_report_header):
res_ids = [res_id for res_id in res_ids if res_id in only_ids]
return res_ids
- ####################Periods and fiscal years helper #######################
+ ##########################################
+ # Periods and fiscal years helper #
+ ##########################################
def _get_opening_periods(self):
- """Return the list of all journal that can be use to create opening entries
- We actually filter on this instead of opening period as older version of OpenERP
- did not have this notion"""
- return self.pool.get('account.period').search(self.cursor, self.uid, [('special', '=', True)])
+ """Return the list of all journal that can be use to create opening
+ entries.
+ We actually filter on this instead of opening period as older version
+ of OpenERP did not have this notion"""
+ return self.pool.get('account.period').search(self.cursor, self.uid,
+ [('special', '=', True)])
def exclude_opening_periods(self, period_ids):
period_obj = self.pool.get('account.period')
- return period_obj.search(self.cr, self.uid, [['special', '=', False], ['id', 'in', period_ids]])
+ return period_obj.search(self.cr, self.uid, [['special', '=', False],
+ ['id', 'in', period_ids]])
def get_included_opening_period(self, period):
"""Return the opening included in normal period we use the assumption
@@ -228,7 +253,7 @@ class CommonReportHeaderWebkit(common_report_header):
('date_start', '>=', period.date_start),
('date_stop', '<=', period.date_stop),
('company_id', '=', period.company_id.id)],
- limit=1)
+ limit=1)
def periods_contains_move_lines(self, period_ids):
if not period_ids:
@@ -236,12 +261,16 @@ class CommonReportHeaderWebkit(common_report_header):
mv_line_obj = self.pool.get('account.move.line')
if isinstance(period_ids, (int, long)):
period_ids = [period_ids]
- return mv_line_obj.search(self.cursor, self.uid, [('period_id', 'in', period_ids)], limit=1) and True or False
+ return mv_line_obj.search(self.cursor, self.uid,
+ [('period_id', 'in', period_ids)], limit=1) \
+ and True or False
- def _get_period_range_from_periods(self, start_period, stop_period, mode=None):
+ def _get_period_range_from_periods(self, start_period, stop_period,
+ mode=None):
"""
- Deprecated. We have to use now the build_ctx_periods of period_obj otherwise we'll have
- inconsistencies, because build_ctx_periods does never filter on the the special
+ Deprecated. We have to use now the build_ctx_periods of period_obj
+ otherwise we'll have inconsistencies, because build_ctx_periods does
+ never filter on the the special
"""
period_obj = self.pool.get('account.period')
search_period = [('date_start', '>=', start_period.date_start),
@@ -252,8 +281,10 @@ class CommonReportHeaderWebkit(common_report_header):
res = period_obj.search(self.cursor, self.uid, search_period)
return res
- def _get_period_range_from_start_period(self, start_period, include_opening=False,
- fiscalyear=False, stop_at_previous_opening=False):
+ def _get_period_range_from_start_period(self, start_period,
+ include_opening=False,
+ fiscalyear=False,
+ stop_at_previous_opening=False):
"""We retrieve all periods before start period"""
opening_period_id = False
past_limit = []
@@ -262,24 +293,28 @@ class CommonReportHeaderWebkit(common_report_header):
# We look for previous opening period
if stop_at_previous_opening:
opening_search = [('special', '=', True),
- ('date_stop', '<', start_period.date_start)]
+ ('date_stop', '<', start_period.date_start)]
if fiscalyear:
opening_search.append(('fiscalyear_id', '=', fiscalyear.id))
- opening_periods = period_obj.search(self.cursor, self.uid, opening_search,
+ opening_periods = period_obj.search(self.cursor, self.uid,
+ opening_search,
order='date_stop desc')
for opening_period in opening_periods:
validation_res = mv_line_obj.search(self.cursor,
self.uid,
- [('period_id', '=', opening_period)],
+ [('period_id', '=',
+ opening_period)],
limit=1)
if validation_res:
opening_period_id = opening_period
break
if opening_period_id:
- #we also look for overlapping periods
- opening_period_br = period_obj.browse(self.cursor, self.uid, opening_period_id)
- past_limit = [('date_start', '>=', opening_period_br.date_stop)]
+ # we also look for overlapping periods
+ opening_period_br = period_obj.browse(
+ self.cursor, self.uid, opening_period_id)
+ past_limit = [
+ ('date_start', '>=', opening_period_br.date_stop)]
periods_search = [('date_stop', '<=', start_period.date_stop)]
periods_search += past_limit
@@ -303,7 +338,8 @@ class CommonReportHeaderWebkit(common_report_header):
def get_last_fiscalyear_period(self, fiscalyear):
return self._get_st_fiscalyear_period(fiscalyear, order='DESC')
- def _get_st_fiscalyear_period(self, fiscalyear, special=False, order='ASC'):
+ def _get_st_fiscalyear_period(self, fiscalyear, special=False,
+ order='ASC'):
period_obj = self.pool.get('account.period')
p_id = period_obj.search(self.cursor,
self.uid,
@@ -315,9 +351,12 @@ class CommonReportHeaderWebkit(common_report_header):
raise osv.except_osv(_('No period found'), '')
return period_obj.browse(self.cursor, self.uid, p_id[0])
- ####################Initial Balance helper #################################
+ ###############################
+ # Initial Balance helper #
+ ###############################
- def _compute_init_balance(self, account_id=None, period_ids=None, mode='computed', default_values=False):
+ def _compute_init_balance(self, account_id=None, period_ids=None,
+ mode='computed', default_values=False):
if not isinstance(period_ids, list):
period_ids = [period_ids]
res = {}
@@ -332,7 +371,8 @@ class CommonReportHeaderWebkit(common_report_header):
" sum(amount_currency) AS curr_balance"
" FROM account_move_line"
" WHERE period_id in %s"
- " AND account_id = %s", (tuple(period_ids), account_id))
+ " AND account_id = %s",
+ (tuple(period_ids), account_id))
res = self.cursor.dictfetchone()
except Exception, exc:
@@ -348,67 +388,81 @@ class CommonReportHeaderWebkit(common_report_header):
def _read_opening_balance(self, account_ids, start_period):
""" Read opening balances from the opening balance
"""
- opening_period_selected = self.get_included_opening_period(start_period)
+ opening_period_selected = self.get_included_opening_period(
+ start_period)
if not opening_period_selected:
raise osv.except_osv(
- _('Error'),
- _('No opening period found to compute the opening balances.\n'
- 'You have to configure a period on the first of January'
- ' with the special flag.'))
+ _('Error'),
+ _('No opening period found to compute the opening balances.\n'
+ 'You have to configure a period on the first of January'
+ ' with the special flag.'))
res = {}
for account_id in account_ids:
- res[account_id] = self._compute_init_balance(account_id, opening_period_selected, mode='read')
+ res[account_id] = self._compute_init_balance(
+ account_id, opening_period_selected, mode='read')
return res
def _compute_initial_balances(self, account_ids, start_period, fiscalyear):
"""We compute initial balance.
If form is filtered by date all initial balance are equal to 0
- This function will sum pear and apple in currency amount if account as no secondary currency"""
- # if opening period is included in start period we do not need to compute init balance
- # we just read it from opening entries
+ This function will sum pear and apple in currency amount if account as
+ no secondary currency"""
+ # if opening period is included in start period we do not need to
+ # compute init balance we just read it from opening entries
res = {}
- # PNL and Balance accounts are not computed the same way look for attached doc
- # We include opening period in pnl account in order to see if opening entries
- # were created by error on this account
- pnl_periods_ids = self._get_period_range_from_start_period(start_period, fiscalyear=fiscalyear,
- include_opening=True)
- bs_period_ids = self._get_period_range_from_start_period(start_period, include_opening=True,
- stop_at_previous_opening=True)
- opening_period_selected = self.get_included_opening_period(start_period)
+ # PNL and Balance accounts are not computed the same way look for
+ # attached doc We include opening period in pnl account in order to see
+ # if opening entries were created by error on this account
+ pnl_periods_ids = self._get_period_range_from_start_period(
+ start_period, fiscalyear=fiscalyear, include_opening=True)
+ bs_period_ids = self._get_period_range_from_start_period(
+ start_period, include_opening=True, stop_at_previous_opening=True)
+ opening_period_selected = self.get_included_opening_period(
+ start_period)
- for acc in self.pool.get('account.account').browse(self.cursor, self.uid, account_ids):
+ for acc in self.pool.get('account.account').browse(self.cursor,
+ self.uid,
+ account_ids):
res[acc.id] = self._compute_init_balance(default_values=True)
if acc.user_type.close_method == 'none':
- # we compute the initial balance for close_method == none only when we print a GL
- # during the year, when the opening period is not included in the period selection!
+ # we compute the initial balance for close_method == none only
+ # when we print a GL during the year, when the opening period
+ # is not included in the period selection!
if pnl_periods_ids and not opening_period_selected:
- res[acc.id] = self._compute_init_balance(acc.id, pnl_periods_ids)
+ res[acc.id] = self._compute_init_balance(
+ acc.id, pnl_periods_ids)
else:
res[acc.id] = self._compute_init_balance(acc.id, bs_period_ids)
return res
- ####################Account move retrieval helper ##########################
- def _get_move_ids_from_periods(self, account_id, period_start, period_stop, target_move):
+ ################################################
+ # Account move retrieval helper #
+ ################################################
+ def _get_move_ids_from_periods(self, account_id, period_start, period_stop,
+ target_move):
move_line_obj = self.pool.get('account.move.line')
period_obj = self.pool.get('account.period')
- periods = period_obj.build_ctx_periods(self.cursor, self.uid, period_start.id, period_stop.id)
+ periods = period_obj.build_ctx_periods(
+ self.cursor, self.uid, period_start.id, period_stop.id)
if not periods:
return []
- search = [('period_id', 'in', periods), ('account_id', '=', account_id)]
+ search = [
+ ('period_id', 'in', periods), ('account_id', '=', account_id)]
if target_move == 'posted':
search += [('move_id.state', '=', 'posted')]
return move_line_obj.search(self.cursor, self.uid, search)
- def _get_move_ids_from_dates(self, account_id, date_start, date_stop, target_move, mode='include_opening'):
+ def _get_move_ids_from_dates(self, account_id, date_start, date_stop,
+ target_move, mode='include_opening'):
# TODO imporve perfomance by setting opening period as a property
move_line_obj = self.pool.get('account.move.line')
search_period = [('date', '>=', date_start),
('date', '<=', date_stop),
('account_id', '=', account_id)]
- # actually not used because OpenERP itself always include the opening when we
- # get the periods from january to december
+ # actually not used because OpenERP itself always include the opening
+ # when we get the periods from january to december
if mode == 'exclude_opening':
opening = self._get_opening_periods()
if opening:
@@ -419,20 +473,28 @@ class CommonReportHeaderWebkit(common_report_header):
return move_line_obj.search(self.cursor, self.uid, search_period)
- def get_move_lines_ids(self, account_id, main_filter, start, stop, target_move, mode='include_opening'):
+ def get_move_lines_ids(self, account_id, main_filter, start, stop,
+ 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(_('Invalid query mode'), _('Must be in include_opening, exclude_opening'))
+ raise osv.except_osv(
+ _('Invalid query mode'),
+ _('Must be in include_opening, exclude_opening'))
if main_filter in ('filter_period', 'filter_no'):
- return self._get_move_ids_from_periods(account_id, start, stop, target_move)
+ return self._get_move_ids_from_periods(account_id, start, stop,
+ target_move)
elif main_filter == 'filter_date':
- return self._get_move_ids_from_dates(account_id, start, stop, target_move)
+ return self._get_move_ids_from_dates(account_id, start, stop,
+ target_move)
else:
- raise osv.except_osv(_('No valid filter'), _('Please set a valid time filter'))
+ raise osv.except_osv(
+ _('No valid filter'), _('Please set a valid time filter'))
- def _get_move_line_datas(self, move_line_ids, order='per.special DESC, l.date ASC, per.date_start ASC, m.name ASC'):
+ def _get_move_line_datas(self, move_line_ids,
+ order='per.special DESC, l.date ASC, \
+ per.date_start ASC, m.name ASC'):
# Possible bang if move_line_ids is too long
# We can not slice here as we have to do the sort.
# If slice has to be done it means that we have to reorder in python
@@ -475,7 +537,8 @@ SELECT l.id AS id,
FROM account_move_line l
JOIN account_move m on (l.move_id=m.id)
LEFT JOIN res_currency c on (l.currency_id=c.id)
- LEFT JOIN account_move_reconcile partialrec on (l.reconcile_partial_id = partialrec.id)
+ LEFT JOIN account_move_reconcile partialrec
+ on (l.reconcile_partial_id = partialrec.id)
LEFT JOIN account_move_reconcile fullrec on (l.reconcile_id = fullrec.id)
LEFT JOIN res_partner p on (l.partner_id=p.id)
LEFT JOIN account_invoice i on (m.id =i.move_id)
@@ -506,8 +569,10 @@ SELECT account_move.id,
AND m2.account_id<>%s limit %s) , ', ')
FROM account_move
- JOIN account_move_line on (account_move_line.move_id = account_move.id)
- JOIN account_account on (account_move_line.account_id = account_account.id)
+ JOIN account_move_line
+ on (account_move_line.move_id = account_move.id)
+ JOIN account_account
+ on (account_move_line.account_id = account_account.id)
WHERE move_id in %s"""
try:
@@ -524,8 +589,10 @@ WHERE move_id in %s"""
return True
def _get_initial_balance_mode(self, start_period):
- opening_period_selected = self.get_included_opening_period(start_period)
- opening_move_lines = self.periods_contains_move_lines(opening_period_selected)
+ opening_period_selected = self.get_included_opening_period(
+ start_period)
+ opening_move_lines = self.periods_contains_move_lines(
+ opening_period_selected)
if opening_move_lines:
return 'opening_balance'
else:
diff --git a/account_financial_report_webkit/report/general_ledger.py b/account_financial_report_webkit/report/general_ledger.py
index 7f495cfb..0f62a270 100644
--- a/account_financial_report_webkit/report/general_ledger.py
+++ b/account_financial_report_webkit/report/general_ledger.py
@@ -33,14 +33,18 @@ from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
def __init__(self, cursor, uid, name, context):
- super(GeneralLedgerWebkit, self).__init__(cursor, uid, name, context=context)
+ super(GeneralLedgerWebkit, self).__init__(
+ cursor, uid, name, context=context)
self.pool = pooler.get_pool(self.cr.dbname)
self.cursor = self.cr
- company = self.pool.get('res.users').browse(self.cr, uid, uid, context=context).company_id
- header_report_name = ' - '.join((_('GENERAL LEDGER'), company.name, company.currency_id.name))
+ company = self.pool.get('res.users').browse(
+ self.cr, uid, uid, context=context).company_id
+ header_report_name = ' - '.join(
+ (_('GENERAL LEDGER'), company.name, company.currency_id.name))
- footer_date_time = self.formatLang(str(datetime.today()), date_time=True)
+ footer_date_time = self.formatLang(
+ str(datetime.today()), date_time=True)
self.localcontext.update({
'cr': cursor,
@@ -62,15 +66,17 @@ class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
('--header-left', header_report_name),
('--header-spacing', '2'),
('--footer-left', footer_date_time),
- ('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
+ ('--footer-right',
+ ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
('--footer-line',),
],
})
def set_context(self, objects, data, ids, report_type=None):
- """Populate a ledger_lines attribute on each browse record that will be used
- by mako template"""
- new_ids = data['form']['account_ids'] or data['form']['chart_account_id']
+ """Populate a ledger_lines attribute on each browse record that will be
+ used by mako template"""
+ new_ids = data['form']['account_ids'] or data[
+ 'form']['chart_account_id']
# Account initial balance memoizer
init_balance_memoizer = {}
@@ -99,23 +105,31 @@ class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
stop = stop_period
initial_balance = self.is_initial_balance_enabled(main_filter)
- initial_balance_mode = initial_balance and self._get_initial_balance_mode(start) or False
+ initial_balance_mode = initial_balance \
+ and self._get_initial_balance_mode(start) or False
# Retrieving accounts
accounts = self.get_all_accounts(new_ids, exclude_type=['view'])
if initial_balance_mode == 'initial_balance':
- init_balance_memoizer = self._compute_initial_balances(accounts, start, fiscalyear)
+ init_balance_memoizer = self._compute_initial_balances(
+ accounts, start, fiscalyear)
elif initial_balance_mode == 'opening_balance':
init_balance_memoizer = self._read_opening_balance(accounts, start)
- ledger_lines_memoizer = self._compute_account_ledger_lines(accounts, init_balance_memoizer,
- main_filter, target_move, start, stop)
+ ledger_lines_memoizer = self._compute_account_ledger_lines(
+ accounts, init_balance_memoizer, main_filter, target_move, start,
+ stop)
objects = []
- for account in self.pool.get('account.account').browse(self.cursor, self.uid, accounts):
- if do_centralize and account.centralized and ledger_lines_memoizer.get(account.id):
- account.ledger_lines = self._centralize_lines(main_filter, ledger_lines_memoizer.get(account.id, []))
+ for account in self.pool.get('account.account').browse(self.cursor,
+ self.uid,
+ accounts):
+ if do_centralize and account.centralized \
+ and ledger_lines_memoizer.get(account.id):
+ account.ledger_lines = self._centralize_lines(
+ main_filter, ledger_lines_memoizer.get(account.id, []))
else:
- account.ledger_lines = ledger_lines_memoizer.get(account.id, [])
+ account.ledger_lines = ledger_lines_memoizer.get(
+ account.id, [])
account.init_balance = init_balance_memoizer.get(account.id, {})
objects.append(account)
@@ -130,17 +144,20 @@ class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
'initial_balance_mode': initial_balance_mode,
})
- return super(GeneralLedgerWebkit, self).set_context(objects, data, new_ids,
- report_type=report_type)
+ return super(GeneralLedgerWebkit, self).set_context(
+ objects, data, new_ids, report_type=report_type)
def _centralize_lines(self, filter, ledger_lines, context=None):
- """ Group by period in filter mode 'period' or on one line in filter mode 'date'
- ledger_lines parameter is a list of dict built by _get_ledger_lines"""
+ """ Group by period in filter mode 'period' or on one line in filter
+ mode 'date' ledger_lines parameter is a list of dict built
+ by _get_ledger_lines"""
def group_lines(lines):
if not lines:
return {}
- sums = reduce(lambda line, memo: dict((key, value + memo[key]) for key, value
- in line.iteritems() if key in ('balance', 'debit', 'credit')), lines)
+ sums = reduce(lambda line, memo:
+ dict((key, value + memo[key]) for key, value
+ in line.iteritems() if key in
+ ('balance', 'debit', 'credit')), lines)
res_lines = {
'balance': sums['balance'],
@@ -161,32 +178,38 @@ class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
period_obj = self.pool.get('account.period')
# we need to sort the lines per period in order to use groupby
# unique ids of each used period id in lines
- period_ids = list(set([line['lperiod_id'] for line in ledger_lines]))
+ period_ids = list(
+ set([line['lperiod_id'] for line in ledger_lines]))
# search on account.period in order to sort them by date_start
- sorted_period_ids = period_obj.search(self.cr, self.uid,
- [('id', 'in', period_ids)],
- order='special desc, date_start',
- context=context)
- sorted_ledger_lines = sorted(ledger_lines, key=lambda x: sorted_period_ids.index(x['lperiod_id']))
+ sorted_period_ids = period_obj.search(
+ self.cr, self.uid, [('id', 'in', period_ids)],
+ order='special desc, date_start', context=context)
+ sorted_ledger_lines = sorted(
+ ledger_lines, key=lambda x: sorted_period_ids.
+ index(x['lperiod_id']))
- for period_id, lines_per_period_iterator in groupby(sorted_ledger_lines, itemgetter('lperiod_id')):
+ for period_id, lines_per_period_iterator in groupby(
+ sorted_ledger_lines, itemgetter('lperiod_id')):
lines_per_period = list(lines_per_period_iterator)
if not lines_per_period:
continue
group_per_period = group_lines(lines_per_period)
group_per_period.update({
'lperiod_id': period_id,
- 'period_code': lines_per_period[0]['period_code'], # period code is anyway the same on each line per period
+ # period code is anyway the same on each line per period
+ 'period_code': lines_per_period[0]['period_code'],
})
centralized_lines.append(group_per_period)
return centralized_lines
- def _compute_account_ledger_lines(self, accounts_ids, init_balance_memoizer, main_filter,
+ def _compute_account_ledger_lines(self, accounts_ids,
+ init_balance_memoizer, main_filter,
target_move, start, stop):
res = {}
for acc_id in accounts_ids:
- move_line_ids = self.get_move_lines_ids(acc_id, main_filter, start, stop, target_move)
+ move_line_ids = self.get_move_lines_ids(
+ acc_id, main_filter, start, stop, target_move)
if not move_line_ids:
res[acc_id] = []
continue
@@ -199,8 +222,8 @@ class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
if not move_line_ids:
return []
res = self._get_move_line_datas(move_line_ids)
- ## computing counter part is really heavy in term of ressouces consuption
- ## looking for a king of SQL to help me improve it
+ # computing counter part is really heavy in term of ressouces
+ # consuption looking for a king of SQL to help me improve it
move_ids = [x.get('move_id') for x in res]
counter_parts = self._get_moves_counterparts(move_ids, account_id)
for line in res:
@@ -208,7 +231,9 @@ class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
return res
-HeaderFooterTextWebKitParser('report.account.account_report_general_ledger_webkit',
- 'account.account',
- 'addons/account_financial_report_webkit/report/templates/account_report_general_ledger.mako',
- parser=GeneralLedgerWebkit)
+HeaderFooterTextWebKitParser(
+ 'report.account.account_report_general_ledger_webkit',
+ 'account.account',
+ 'addons/account_financial_report_webkit/report/templates/\
+ account_report_general_ledger.mako',
+ parser=GeneralLedgerWebkit)
diff --git a/account_financial_report_webkit/report/open_invoices.py b/account_financial_report_webkit/report/open_invoices.py
index cce03dec..4e58d4ad 100644
--- a/account_financial_report_webkit/report/open_invoices.py
+++ b/account_financial_report_webkit/report/open_invoices.py
@@ -43,17 +43,23 @@ def get_mako_template(obj, *args):
report_helper.WebKitHelper.get_mako_template = get_mako_template
-class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebkit):
+class PartnersOpenInvoicesWebkit(report_sxw.rml_parse,
+ CommonPartnersReportHeaderWebkit):
def __init__(self, cursor, uid, name, context):
- super(PartnersOpenInvoicesWebkit, self).__init__(cursor, uid, name, context=context)
+ super(PartnersOpenInvoicesWebkit, self).__init__(
+ cursor, uid, name, context=context)
self.pool = pooler.get_pool(self.cr.dbname)
self.cursor = self.cr
- company = self.pool.get('res.users').browse(self.cr, uid, uid, context=context).company_id
- header_report_name = ' - '.join((_('OPEN INVOICES REPORT'), company.name, company.currency_id.name))
+ company = self.pool.get('res.users').browse(
+ self.cr, uid, uid, context=context).company_id
+ header_report_name = ' - '.join((_('OPEN INVOICES REPORT'),
+ company.name,
+ company.currency_id.name))
- footer_date_time = self.formatLang(str(datetime.today()), date_time=True)
+ footer_date_time = self.formatLang(
+ str(datetime.today()), date_time=True)
self.localcontext.update({
'cr': cursor,
@@ -73,7 +79,8 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeade
('--header-left', header_report_name),
('--header-spacing', '2'),
('--footer-left', footer_date_time),
- ('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
+ ('--footer-right',
+ ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
('--footer-line',),
],
})
@@ -85,13 +92,15 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeade
for part_id, plane_lines in account_br.ledger_lines.items():
account_br.grouped_ledger_lines[part_id] = []
plane_lines.sort(key=itemgetter('currency_code'))
- for curr, lines in groupby(plane_lines, key=itemgetter('currency_code')):
+ for curr, lines in groupby(plane_lines,
+ key=itemgetter('currency_code')):
tmp = [x for x in lines]
- account_br.grouped_ledger_lines[part_id].append((curr, tmp)) # I want to reiter many times
+ account_br.grouped_ledger_lines[part_id].append(
+ (curr, tmp)) # I want to reiter many times
def set_context(self, objects, data, ids, report_type=None):
- """Populate a ledger_lines attribute on each browse record that will be used
- by mako template"""
+ """Populate a ledger_lines attribute on each browse record that will
+ be used by mako template"""
new_ids = data['form']['chart_account_id']
# Account initial balance memoizer
init_balance_memoizer = {}
@@ -120,7 +129,8 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeade
if result_selection == 'supplier':
filter_type = ('payable',)
- account_ids = self.get_all_accounts(new_ids, exclude_type=['view'], only_type=filter_type)
+ account_ids = self.get_all_accounts(
+ new_ids, exclude_type=['view'], only_type=filter_type)
if not account_ids:
raise osv.except_osv(_('Error'), _('No accounts to print.'))
@@ -132,26 +142,28 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeade
else:
start = start_period
stop = stop_period
- ledger_lines_memoizer = self._compute_open_transactions_lines(account_ids,
- main_filter,
- target_move,
- start,
- stop,
- date_until,
- partner_filter=partner_ids)
+ ledger_lines_memoizer = self._compute_open_transactions_lines(
+ account_ids, main_filter, target_move, start, stop, date_until,
+ partner_filter=partner_ids)
objects = []
- for account in self.pool.get('account.account').browse(self.cursor, self.uid, account_ids):
+ for account in self.pool.get('account.account').browse(self.cursor,
+ self.uid,
+ account_ids):
account.ledger_lines = ledger_lines_memoizer.get(account.id, {})
account.init_balance = init_balance_memoizer.get(account.id, {})
- ## we have to compute partner order based on inital balance
- ## and ledger line as we may have partner with init bal
- ## that are not in ledger line and vice versa
+ # we have to compute partner order based on inital balance
+ # and ledger line as we may have partner with init bal
+ # that are not in ledger line and vice versa
ledg_lines_pids = ledger_lines_memoizer.get(account.id, {}).keys()
- non_null_init_balances = dict([(ib, amounts) for ib, amounts in account.init_balance.iteritems()
- if amounts['init_balance'] or amounts['init_balance_currency']])
+ non_null_init_balances = dict([
+ (ib, amounts) for ib, amounts
+ in account.init_balance.iteritems()
+ if amounts['init_balance']
+ or amounts['init_balance_currency']])
init_bal_lines_pids = non_null_init_balances.keys()
- account.partners_order = self._order_partners(ledg_lines_pids, init_bal_lines_pids)
+ account.partners_order = self._order_partners(
+ ledg_lines_pids, init_bal_lines_pids)
account.ledger_lines = ledger_lines_memoizer.get(account.id, {})
if group_by_currency:
self._group_lines_by_currency(account)
@@ -168,13 +180,16 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeade
'chart_account': chart_account,
})
- return super(PartnersOpenInvoicesWebkit, self).set_context(objects, data, new_ids,
- report_type=report_type)
+ return super(PartnersOpenInvoicesWebkit, self).set_context(
+ objects, data, new_ids, report_type=report_type)
- def _compute_open_transactions_lines(self, accounts_ids, main_filter, target_move, start, stop, date_until=False, partner_filter=False):
+ def _compute_open_transactions_lines(self, accounts_ids, main_filter,
+ target_move, start, stop,
+ date_until=False,
+ partner_filter=False):
res = defaultdict(dict)
- ## we check if until date and date stop have the same value
+ # we check if until date and date stop have the same value
if main_filter in ('filter_period', 'filter_no'):
date_stop = stop.date_stop
date_until_match = (date_stop == date_until)
@@ -185,7 +200,8 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeade
else:
raise osv.except_osv(_('Unsuported filter'),
- _('Filter has to be in filter date, period, or none'))
+ _('Filter has to be in filter date, period, \
+ or none'))
initial_move_lines_per_account = {}
if main_filter in ('filter_period', 'filter_no'):
@@ -195,34 +211,38 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeade
partner_filter,
exclude_reconcile=True,
force_period_ids=False,
- date_stop=date_stop), key='id')
+ date_stop=date_stop),
+ key='id')
for account_id in accounts_ids:
- initial_move_lines_ids_per_partner = initial_move_lines_per_account.get(account_id, {})
+ initial_move_lines_ids_per_partner = \
+ initial_move_lines_per_account.get(account_id, {})
# We get the move line ids of the account
- move_line_ids_per_partner = self.get_partners_move_lines_ids(account_id,
- main_filter,
- start,
- stop,
- target_move,
- exclude_reconcile=True,
- partner_filter=partner_filter)
+ move_line_ids_per_partner = self.get_partners_move_lines_ids(
+ account_id, main_filter, start, stop, target_move,
+ exclude_reconcile=True, partner_filter=partner_filter)
- if not initial_move_lines_ids_per_partner and not move_line_ids_per_partner:
+ if not initial_move_lines_ids_per_partner \
+ and not move_line_ids_per_partner:
continue
- for partner_id in list(set(initial_move_lines_ids_per_partner.keys() + move_line_ids_per_partner.keys())):
- partner_line_ids = (move_line_ids_per_partner.get(partner_id, []) +
- initial_move_lines_ids_per_partner.get(partner_id, []))
+ for partner_id in list(
+ set(initial_move_lines_ids_per_partner.keys() +
+ move_line_ids_per_partner.keys())):
+ partner_line_ids = (
+ move_line_ids_per_partner.get(partner_id, []) +
+ initial_move_lines_ids_per_partner.get(partner_id, []))
clearance_line_ids = []
if date_until and not date_until_match and partner_line_ids:
- clearance_line_ids = self._get_clearance_move_line_ids(partner_line_ids, date_stop, date_until)
+ clearance_line_ids = self._get_clearance_move_line_ids(
+ partner_line_ids, date_stop, date_until)
partner_line_ids += clearance_line_ids
lines = self._get_move_line_datas(list(set(partner_line_ids)))
for line in lines:
- if line['id'] in initial_move_lines_ids_per_partner.get(partner_id, []):
+ if line['id'] in initial_move_lines_ids_per_partner.\
+ get(partner_id, []):
line['is_from_previous_periods'] = True
if line['id'] in clearance_line_ids:
line['is_clearance_line'] = True
@@ -231,7 +251,9 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeade
return res
-HeaderFooterTextWebKitParser('report.account.account_report_open_invoices_webkit',
- 'account.account',
- 'addons/account_financial_report_webkit/report/templates/account_report_open_invoices.mako',
- parser=PartnersOpenInvoicesWebkit)
+HeaderFooterTextWebKitParser(
+ 'report.account.account_report_open_invoices_webkit',
+ 'account.account',
+ 'addons/account_financial_report_webkit/report/templates/\
+ account_report_open_invoices.mako',
+ parser=PartnersOpenInvoicesWebkit)
diff --git a/account_financial_report_webkit/report/partner_balance.py b/account_financial_report_webkit/report/partner_balance.py
index 6034f36c..1e039bb7 100644
--- a/account_financial_report_webkit/report/partner_balance.py
+++ b/account_financial_report_webkit/report/partner_balance.py
@@ -25,21 +25,28 @@ from datetime import datetime
from openerp import pooler
from openerp.report import report_sxw
from openerp.tools.translate import _
-from .common_partner_balance_reports import CommonPartnerBalanceReportHeaderWebkit
+from .common_partner_balance_reports \
+ import CommonPartnerBalanceReportHeaderWebkit
from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
-class PartnerBalanceWebkit(report_sxw.rml_parse, CommonPartnerBalanceReportHeaderWebkit):
+class PartnerBalanceWebkit(report_sxw.rml_parse,
+ CommonPartnerBalanceReportHeaderWebkit):
def __init__(self, cursor, uid, name, context):
- super(PartnerBalanceWebkit, self).__init__(cursor, uid, name, context=context)
+ super(PartnerBalanceWebkit, self).__init__(
+ cursor, uid, name, context=context)
self.pool = pooler.get_pool(self.cr.dbname)
self.cursor = self.cr
- company = self.pool.get('res.users').browse(self.cr, uid, uid, context=context).company_id
- header_report_name = ' - '.join((_('PARTNER BALANCE'), company.name, company.currency_id.name))
+ company = self.pool.get('res.users').browse(
+ self.cr, uid, uid, context=context).company_id
+ header_report_name = ' - '.join((_('PARTNER BALANCE'),
+ company.name,
+ company.currency_id.name))
- footer_date_time = self.formatLang(str(datetime.today()), date_time=True)
+ footer_date_time = self.formatLang(
+ str(datetime.today()), date_time=True)
self.localcontext.update({
'cr': cursor,
@@ -60,7 +67,8 @@ class PartnerBalanceWebkit(report_sxw.rml_parse, CommonPartnerBalanceReportHeade
('--header-left', header_report_name),
('--header-spacing', '2'),
('--footer-left', footer_date_time),
- ('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
+ ('--footer-right',
+ ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
('--footer-line',),
],
})
@@ -76,15 +84,18 @@ class PartnerBalanceWebkit(report_sxw.rml_parse, CommonPartnerBalanceReportHeade
return 'initial_balance'
def set_context(self, objects, data, ids, report_type=None):
- """Populate a ledger_lines attribute on each browse record that will be used
- by mako template"""
- objects, new_ids, context_report_values = self.compute_partner_balance_data(data)
+ """Populate a ledger_lines attribute on each browse record that will
+ be used by mako template"""
+ objects, new_ids, context_report_values = self.\
+ compute_partner_balance_data(data)
self.localcontext.update(context_report_values)
- return super(PartnerBalanceWebkit, self).set_context(objects, data, new_ids,
- report_type=report_type)
+ return super(PartnerBalanceWebkit, self).set_context(
+ objects, data, new_ids, report_type=report_type)
-HeaderFooterTextWebKitParser('report.account.account_report_partner_balance_webkit',
- 'account.account',
- 'addons/account_financial_report_webkit/report/templates/account_report_partner_balance.mako',
- parser=PartnerBalanceWebkit)
+HeaderFooterTextWebKitParser(
+ 'report.account.account_report_partner_balance_webkit',
+ 'account.account',
+ 'addons/account_financial_report_webkit/report/templates/\
+ account_report_partner_balance.mako',
+ parser=PartnerBalanceWebkit)
diff --git a/account_financial_report_webkit/report/partners_ledger.py b/account_financial_report_webkit/report/partners_ledger.py
index 97284458..55c22ce4 100644
--- a/account_financial_report_webkit/report/partners_ledger.py
+++ b/account_financial_report_webkit/report/partners_ledger.py
@@ -30,17 +30,23 @@ from .common_partner_reports import CommonPartnersReportHeaderWebkit
from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
-class PartnersLedgerWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebkit):
+class PartnersLedgerWebkit(report_sxw.rml_parse,
+ CommonPartnersReportHeaderWebkit):
def __init__(self, cursor, uid, name, context):
- super(PartnersLedgerWebkit, self).__init__(cursor, uid, name, context=context)
+ super(PartnersLedgerWebkit, self).__init__(
+ cursor, uid, name, context=context)
self.pool = pooler.get_pool(self.cr.dbname)
self.cursor = self.cr
- company = self.pool.get('res.users').browse(self.cr, uid, uid, context=context).company_id
- header_report_name = ' - '.join((_('PARTNER LEDGER'), company.name, company.currency_id.name))
+ company = self.pool.get('res.users').browse(
+ self.cr, uid, uid, context=context).company_id
+ header_report_name = ' - '.join((_('PARTNER LEDGER'),
+ company.name,
+ company.currency_id.name))
- footer_date_time = self.formatLang(str(datetime.today()), date_time=True)
+ footer_date_time = self.formatLang(
+ str(datetime.today()), date_time=True)
self.localcontext.update({
'cr': cursor,
@@ -61,7 +67,8 @@ class PartnersLedgerWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebki
('--header-left', header_report_name),
('--header-spacing', '2'),
('--footer-left', footer_date_time),
- ('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
+ ('--footer-right',
+ ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
('--footer-line',),
],
})
@@ -77,8 +84,8 @@ class PartnersLedgerWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebki
return 'initial_balance'
def set_context(self, objects, data, ids, report_type=None):
- """Populate a ledger_lines attribute on each browse record that will be used
- by mako template"""
+ """Populate a ledger_lines attribute on each browse record that will
+ be used by mako template"""
new_ids = data['form']['chart_account_id']
# account partner memoizer
@@ -118,45 +125,50 @@ class PartnersLedgerWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebki
start = start_period
stop = stop_period
- # when the opening period is included in the selected range of periods and
- # the opening period contains move lines, we must not compute the initial balance from previous periods
- # but only display the move lines of the opening period
- # we identify them as:
- # - 'initial_balance' means compute the sums of move lines from previous periods
- # - 'opening_balance' means display the move lines of the opening period
+ # when the opening period is included in the selected range of periods
+ # and the opening period contains move lines, we must not compute the
+ # initial balance from previous periods but only display the move lines
+ # of the opening period we identify them as:
+ # - 'initial_balance' means compute the sums of move lines from
+ # previous periods
+ # - 'opening_balance' means display the move lines of the opening
+ # period
init_balance = main_filter in ('filter_no', 'filter_period')
- initial_balance_mode = init_balance and self._get_initial_balance_mode(start) or False
+ initial_balance_mode = init_balance and self._get_initial_balance_mode(
+ start) or False
initial_balance_lines = {}
if initial_balance_mode == 'initial_balance':
- initial_balance_lines = self._compute_partners_initial_balances(accounts,
- start_period,
- partner_filter=partner_ids,
- exclude_reconcile=False)
+ initial_balance_lines = self._compute_partners_initial_balances(
+ accounts, start_period, partner_filter=partner_ids,
+ exclude_reconcile=False)
- ledger_lines = self._compute_partner_ledger_lines(accounts,
- main_filter,
- target_move,
- start,
- stop,
- partner_filter=partner_ids)
+ ledger_lines = self._compute_partner_ledger_lines(
+ accounts, main_filter, target_move, start, stop,
+ partner_filter=partner_ids)
objects = []
- for account in self.pool.get('account.account').browse(self.cursor, self.uid, accounts):
+ for account in self.pool.get('account.account').browse(self.cursor,
+ self.uid,
+ accounts):
account.ledger_lines = ledger_lines.get(account.id, {})
account.init_balance = initial_balance_lines.get(account.id, {})
- ## we have to compute partner order based on inital balance
- ## and ledger line as we may have partner with init bal
- ## that are not in ledger line and vice versa
+ # we have to compute partner order based on inital balance
+ # and ledger line as we may have partner with init bal
+ # that are not in ledger line and vice versa
ledg_lines_pids = ledger_lines.get(account.id, {}).keys()
if initial_balance_mode:
- non_null_init_balances = dict([(ib, amounts) for ib, amounts in account.init_balance.iteritems()
- if amounts['init_balance'] or amounts['init_balance_currency']])
+ non_null_init_balances = dict(
+ [(ib, amounts) for ib, amounts
+ in account.init_balance.iteritems()
+ if amounts['init_balance']
+ or amounts['init_balance_currency']])
init_bal_lines_pids = non_null_init_balances.keys()
else:
account.init_balance = {}
init_bal_lines_pids = []
- account.partners_order = self._order_partners(ledg_lines_pids, init_bal_lines_pids)
+ account.partners_order = self._order_partners(
+ ledg_lines_pids, init_bal_lines_pids)
objects.append(account)
self.localcontext.update({
@@ -170,20 +182,18 @@ class PartnersLedgerWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebki
'initial_balance_mode': initial_balance_mode,
})
- return super(PartnersLedgerWebkit, self).set_context(objects, data, new_ids,
- report_type=report_type)
+ return super(PartnersLedgerWebkit, self).set_context(
+ objects, data, new_ids, report_type=report_type)
- def _compute_partner_ledger_lines(self, accounts_ids, main_filter, target_move, start, stop, partner_filter=False):
+ def _compute_partner_ledger_lines(self, accounts_ids, main_filter,
+ target_move, start, stop,
+ partner_filter=False):
res = defaultdict(dict)
for acc_id in accounts_ids:
- move_line_ids = self.get_partners_move_lines_ids(acc_id,
- main_filter,
- start,
- stop,
- target_move,
- exclude_reconcile=False,
- partner_filter=partner_filter)
+ move_line_ids = self.get_partners_move_lines_ids(
+ acc_id, main_filter, start, stop, target_move,
+ exclude_reconcile=False, partner_filter=partner_filter)
if not move_line_ids:
continue
for partner_id in move_line_ids:
@@ -193,7 +203,9 @@ class PartnersLedgerWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebki
return res
-HeaderFooterTextWebKitParser('report.account.account_report_partners_ledger_webkit',
- 'account.account',
- 'addons/account_financial_report_webkit/report/templates/account_report_partners_ledger.mako',
- parser=PartnersLedgerWebkit)
+HeaderFooterTextWebKitParser(
+ 'report.account.account_report_partners_ledger_webkit',
+ 'account.account',
+ 'addons/account_financial_report_webkit/report/templates/\
+ account_report_partners_ledger.mako',
+ parser=PartnersLedgerWebkit)
diff --git a/account_financial_report_webkit/report/print_journal.py b/account_financial_report_webkit/report/print_journal.py
index 7d14059e..c2b2f247 100644
--- a/account_financial_report_webkit/report/print_journal.py
+++ b/account_financial_report_webkit/report/print_journal.py
@@ -1,19 +1,20 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# account_financial_report_webkit module for OpenERP, Webkit based extended report financial report
+# account_financial_report_webkit module for OpenERP, Webkit based
+# extended report financial report
# Copyright (C) 2012 SYLEAM Info Services ()
# Sebastien LANGE
#
# This file is a part of account_financial_report_webkit
#
-# account_financial_report_webkit 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.
+# account_financial_report_webkit 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.
#
-# account_financial_report_webkit is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# account_financial_report_webkit 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.
#
@@ -34,17 +35,22 @@ from webkit_parser_header_fix import HeaderFooterTextWebKitParser
class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
def __init__(self, cursor, uid, name, context):
- super(PrintJournalWebkit, self).__init__(cursor, uid, name, context=context)
+ super(PrintJournalWebkit, self).__init__(cursor, uid, name,
+ context=context)
self.pool = pooler.get_pool(self.cr.dbname)
self.cursor = self.cr
company_obj = self.pool.get('res.company')
- company_id = company_obj._company_default_get(self.cr, uid, 'res.users', context=context)
+ company_id = company_obj._company_default_get(self.cr, uid,
+ 'res.users',
+ context=context)
company = company_obj.browse(self.cr, uid, company_id, context=context)
- header_report_name = ' - '.join((_('JOURNALS'), company.name, company.currency_id.name))
+ header_report_name = ' - '.join((_('JOURNALS'), company.name,
+ company.currency_id.name))
- footer_date_time = self.formatLang(str(datetime.today()), date_time=True)
+ footer_date_time = self.formatLang(str(datetime.today()),
+ date_time=True)
self.localcontext.update({
'cr': cursor,
@@ -66,14 +72,15 @@ class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
('--header-left', header_report_name),
('--header-spacing', '2'),
('--footer-left', footer_date_time),
- ('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
+ ('--footer-right', ' '.join((_('Page'), '[page]', _('of'),
+ '[topage]'))),
('--footer-line',),
],
})
def set_context(self, objects, data, ids, report_type=None):
- """Populate a ledger_lines attribute on each browse record that will be used
- by mako template"""
+ """Populate a ledger_lines attribute on each browse record that will
+ be used by mako template"""
# Reading form
main_filter = self._get_form_param('filter', data, default='filter_no')
@@ -90,8 +97,10 @@ class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
domain = [('journal_id', 'in', journal_ids)]
if main_filter == 'filter_no':
domain += [
- ('date', '>=', self.get_first_fiscalyear_period(fiscalyear).date_start),
- ('date', '<=', self.get_last_fiscalyear_period(fiscalyear).date_stop),
+ ('date', '>=',
+ self.get_first_fiscalyear_period(fiscalyear).date_start),
+ ('date', '<=',
+ self.get_last_fiscalyear_period(fiscalyear).date_stop),
]
# computation of move lines
elif main_filter == 'filter_date':
@@ -100,7 +109,10 @@ class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
('date', '<=', stop_date),
]
elif main_filter == 'filter_period':
- period_ids = account_period_obj.build_ctx_periods(self.cursor, self.uid, start_period.id, stop_period.id)
+ period_ids = account_period_obj.build_ctx_periods(self.cursor,
+ self.uid,
+ start_period.id,
+ stop_period.id)
domain = [
('period_id', 'in', period_ids),
]
@@ -111,7 +123,8 @@ class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
('journal_id', 'in', journal_ids),
('period_id', 'in', period_ids),
])
- objects = account_journal_period_obj.browse(self.cursor, self.uid, new_ids)
+ objects = account_journal_period_obj.browse(self.cursor, self.uid,
+ new_ids)
# Sort by journal and period
objects.sort(key=lambda a: (a.journal_id.code, a.period_id.date_start))
move_obj = self.pool.get('account.move')
@@ -122,8 +135,10 @@ class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
]
if target_move == 'posted':
domain_arg += [('state', '=', 'posted')]
- move_ids = move_obj.search(self.cursor, self.uid, domain_arg, order="name")
- journal_period.moves = move_obj.browse(self.cursor, self.uid, move_ids)
+ move_ids = move_obj.search(self.cursor, self.uid, domain_arg,
+ order="name")
+ journal_period.moves = move_obj.browse(self.cursor, self.uid,
+ move_ids)
# Sort account move line by account accountant
for move in journal_period.moves:
move.line_id.sort(key=lambda a: (a.date, a.account_id.code))
@@ -137,11 +152,14 @@ class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
'chart_account': chart_account,
})
- return super(PrintJournalWebkit, self).set_context(objects, data, new_ids, report_type=report_type)
+ return super(PrintJournalWebkit, self).set_context(
+ objects, data, new_ids, report_type=report_type)
-HeaderFooterTextWebKitParser('report.account.account_report_print_journal_webkit',
- 'account.journal.period',
- 'addons/account_financial_report_webkit/report/templates/account_report_print_journal.mako',
- parser=PrintJournalWebkit)
+HeaderFooterTextWebKitParser(
+ 'report.account.account_report_print_journal_webkit',
+ 'account.journal.period',
+ 'addons/account_financial_report_webkit/report/templates/\
+ account_report_print_journal.mako',
+ parser=PrintJournalWebkit)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/account_financial_report_webkit/report/trial_balance.py b/account_financial_report_webkit/report/trial_balance.py
index db62d54f..27c202b5 100644
--- a/account_financial_report_webkit/report/trial_balance.py
+++ b/account_financial_report_webkit/report/trial_balance.py
@@ -33,17 +33,22 @@ def sign(number):
return cmp(number, 0)
-class TrialBalanceWebkit(report_sxw.rml_parse, CommonBalanceReportHeaderWebkit):
+class TrialBalanceWebkit(report_sxw.rml_parse,
+ CommonBalanceReportHeaderWebkit):
def __init__(self, cursor, uid, name, context):
- super(TrialBalanceWebkit, self).__init__(cursor, uid, name, context=context)
+ super(TrialBalanceWebkit, self).__init__(cursor, uid, name,
+ context=context)
self.pool = pooler.get_pool(self.cr.dbname)
self.cursor = self.cr
- company = self.pool.get('res.users').browse(self.cr, uid, uid, context=context).company_id
- header_report_name = ' - '.join((_('TRIAL BALANCE'), company.name, company.currency_id.name))
+ company = self.pool.get('res.users').browse(self.cr, uid, uid,
+ context=context).company_id
+ header_report_name = ' - '.join((_('TRIAL BALANCE'), company.name,
+ company.currency_id.name))
- footer_date_time = self.formatLang(str(datetime.today()), date_time=True)
+ footer_date_time = self.formatLang(str(datetime.today()),
+ date_time=True)
self.localcontext.update({
'cr': cursor,
@@ -63,22 +68,26 @@ class TrialBalanceWebkit(report_sxw.rml_parse, CommonBalanceReportHeaderWebkit):
('--header-left', header_report_name),
('--header-spacing', '2'),
('--footer-left', footer_date_time),
- ('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
+ ('--footer-right', ' '.join((_('Page'), '[page]', _('of'),
+ '[topage]'))),
('--footer-line',),
],
})
def set_context(self, objects, data, ids, report_type=None):
- """Populate a ledger_lines attribute on each browse record that will be used
- by mako template"""
- objects, new_ids, context_report_values = self.compute_balance_data(data)
+ """Populate a ledger_lines attribute on each browse record that will
+ be used by mako template"""
+ objects, new_ids, context_report_values = self.\
+ compute_balance_data(data)
self.localcontext.update(context_report_values)
- return super(TrialBalanceWebkit, self).set_context(objects, data, new_ids,
- report_type=report_type)
+ return super(TrialBalanceWebkit, self).set_context(
+ objects, data, new_ids, report_type=report_type)
-HeaderFooterTextWebKitParser('report.account.account_report_trial_balance_webkit',
- 'account.account',
- 'addons/account_financial_report_webkit/report/templates/account_report_trial_balance.mako',
- parser=TrialBalanceWebkit)
+HeaderFooterTextWebKitParser(
+ 'report.account.account_report_trial_balance_webkit',
+ 'account.account',
+ 'addons/account_financial_report_webkit/report/templates/\
+ account_report_trial_balance.mako',
+ parser=TrialBalanceWebkit)
diff --git a/account_financial_report_webkit/report/webkit_parser_header_fix.py b/account_financial_report_webkit/report/webkit_parser_header_fix.py
index 4e97736e..c52b61af 100644
--- a/account_financial_report_webkit/report/webkit_parser_header_fix.py
+++ b/account_financial_report_webkit/report/webkit_parser_header_fix.py
@@ -56,7 +56,8 @@ _logger = logging.getLogger('financial.reports.webkit')
# them in the localcontext with a key 'additional_args'
# for instance:
# header_report_name = _('PARTNER LEDGER')
-# footer_date_time = self.formatLang(str(datetime.today()), date_time=True)
+# footer_date_time = self.formatLang(str(datetime.today()),
+# date_time=True)
# self.localcontext.update({
# 'additional_args': [
# ('--header-font-name', 'Helvetica'),
@@ -65,7 +66,8 @@ _logger = logging.getLogger('financial.reports.webkit')
# ('--footer-font-size', '7'),
# ('--header-left', header_report_name),
# ('--footer-left', footer_date_time),
-# ('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
+# ('--footer-right', ' '.join((_('Page'), '[page]', _('of'),
+# '[topage]'))),
# ('--footer-line',),
# ],
# })
@@ -82,8 +84,10 @@ def mako_template(text):
This template uses UTF-8 encoding
"""
- tmp_lookup = TemplateLookup() # we need it in order to allow inclusion and inheritance
- return Template(text, input_encoding='utf-8', output_encoding='utf-8', lookup=tmp_lookup)
+ tmp_lookup = TemplateLookup(
+ ) # we need it in order to allow inclusion and inheritance
+ return Template(text, input_encoding='utf-8', output_encoding='utf-8',
+ lookup=tmp_lookup)
class HeaderFooterTextWebKitParser(webkit_report.WebKitParser):
@@ -106,17 +110,29 @@ class HeaderFooterTextWebKitParser(webkit_report.WebKitParser):
command.extend(['--encoding', 'utf-8'])
if webkit_header.margin_top:
- command.extend(['--margin-top', str(webkit_header.margin_top).replace(',', '.')])
+ command.extend(
+ ['--margin-top',
+ str(webkit_header.margin_top).replace(',', '.')])
if webkit_header.margin_bottom:
- command.extend(['--margin-bottom', str(webkit_header.margin_bottom).replace(',', '.')])
+ command.extend(
+ ['--margin-bottom',
+ str(webkit_header.margin_bottom).replace(',', '.')])
if webkit_header.margin_left:
- command.extend(['--margin-left', str(webkit_header.margin_left).replace(',', '.')])
+ command.extend(
+ ['--margin-left',
+ str(webkit_header.margin_left).replace(',', '.')])
if webkit_header.margin_right:
- command.extend(['--margin-right', str(webkit_header.margin_right).replace(',', '.')])
+ command.extend(
+ ['--margin-right',
+ str(webkit_header.margin_right).replace(',', '.')])
if webkit_header.orientation:
- command.extend(['--orientation', str(webkit_header.orientation).replace(',', '.')])
+ command.extend(
+ ['--orientation',
+ str(webkit_header.orientation).replace(',', '.')])
if webkit_header.format:
- command.extend(['--page-size', str(webkit_header.format).replace(',', '.')])
+ command.extend(
+ ['--page-size',
+ str(webkit_header.format).replace(',', '.')])
if parser_instance.localcontext.get('additional_args', False):
for arg in parser_instance.localcontext['additional_args']:
@@ -143,10 +159,14 @@ class HeaderFooterTextWebKitParser(webkit_report.WebKitParser):
if not error_message:
error_message = _('No diagnosis message was provided')
else:
- error_message = _('The following diagnosis message was provided:\n') + error_message
+ error_message = _(
+ 'The following diagnosis message was provided:\n') + \
+ error_message
if status:
raise except_osv(_('Webkit error'),
- _("The command 'wkhtmltopdf' failed with error code = %s. Message: %s") % (status, error_message))
+ _("The command 'wkhtmltopdf' failed with \
+ error code = %s. Message: %s") %
+ (status, error_message))
with open(out_filename, 'rb') as pdf_file:
pdf = pdf_file.read()
os.close(fd)
@@ -161,7 +181,8 @@ class HeaderFooterTextWebKitParser(webkit_report.WebKitParser):
return pdf
# override needed to keep the attachments' storing procedure
- def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None):
+ def create_single_pdf(self, cursor, uid, ids, data, report_xml,
+ context=None):
"""generate the PDF"""
if context is None:
@@ -184,27 +205,30 @@ class HeaderFooterTextWebKitParser(webkit_report.WebKitParser):
template = False
if report_xml.report_file:
- path = addons.get_module_resource(*report_xml.report_file.split(os.path.sep))
+ path = addons.get_module_resource(
+ *report_xml.report_file.split(os.path.sep))
if os.path.exists(path):
template = file(path).read()
if not template and report_xml.report_webkit_data:
template = report_xml.report_webkit_data
if not template:
- raise except_osv(_('Error!'), _('Webkit Report template not found !'))
+ raise except_osv(
+ _('Error!'), _('Webkit Report template not found !'))
header = report_xml.webkit_header.html
if not header and report_xml.header:
raise except_osv(
- _('No header defined for this Webkit report!'),
- _('Please set a header in company settings.')
- )
+ _('No header defined for this Webkit report!'),
+ _('Please set a header in company settings.')
+ )
css = report_xml.webkit_header.css
if not css:
css = ''
translate_call = partial(self.translate_call, parser_instance)
- #default_filters=['unicode', 'entity'] can be used to set global filter
+ # default_filters=['unicode', 'entity'] can be used to set global
+ # filter
body_mako_tpl = mako_template(template)
helper = WebKitHelper(cursor, uid, report_xml.id, context)
if report_xml.precise_mode:
diff --git a/account_financial_report_webkit/wizard/balance_common.py b/account_financial_report_webkit/wizard/balance_common.py
index 5225b671..97a67ec5 100644
--- a/account_financial_report_webkit/wizard/balance_common.py
+++ b/account_financial_report_webkit/wizard/balance_common.py
@@ -47,6 +47,7 @@ def previous_year_date(date, nb_prev=1):
class AccountBalanceCommonWizard(orm.TransientModel):
+
"""Will launch trial balance report and pass required args"""
_inherit = "account.common.account.report"
@@ -66,53 +67,68 @@ class AccountBalanceCommonWizard(orm.TransientModel):
M2O_DYNAMIC_FIELDS = [f % index for f in ["comp%s_fiscalyear_id",
"comp%s_period_from",
"comp%s_period_to"]
- for index in range(COMPARISON_LEVEL)]
+ for index in range(COMPARISON_LEVEL)]
SIMPLE_DYNAMIC_FIELDS = [f % index for f in ["comp%s_filter",
"comp%s_date_from",
"comp%s_date_to"]
- for index in range(COMPARISON_LEVEL)]
+ for index in range(COMPARISON_LEVEL)]
DYNAMIC_FIELDS = M2O_DYNAMIC_FIELDS + SIMPLE_DYNAMIC_FIELDS
def _get_account_ids(self, cr, uid, context=None):
res = False
- if context.get('active_model', False) == 'account.account' and context.get('active_ids', False):
+ if context.get('active_model', False) == 'account.account' \
+ and context.get('active_ids', False):
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).'),
+ '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).'),
}
for index in range(COMPARISON_LEVEL):
_columns.update(
- {"comp%s_filter" % index: fields.selection(COMPARE_SELECTION, string='Compare By', required=True),
- "comp%s_fiscalyear_id" % index: fields.many2one('account.fiscalyear', 'Fiscal Year'),
- "comp%s_period_from" % index: fields.many2one('account.period', 'Start Period'),
- "comp%s_period_to" % index: fields.many2one('account.period', 'End Period'),
- "comp%s_date_from" % index: fields.date("Start Date"),
- "comp%s_date_to" % index: fields.date("End Date")})
+ {"comp%s_filter" % index:
+ fields.selection(
+ COMPARE_SELECTION, string='Compare By', required=True),
+ "comp%s_fiscalyear_id" % index:
+ fields.many2one('account.fiscalyear', 'Fiscal Year'),
+ "comp%s_period_from" % index:
+ fields.many2one('account.period', 'Start Period'),
+ "comp%s_period_to" % index:
+ fields.many2one('account.period', 'End Period'),
+ "comp%s_date_from" % index:
+ fields.date("Start Date"),
+ "comp%s_date_to" % index:
+ fields.date("End Date")})
_defaults = {
'account_ids': _get_account_ids,
}
def _check_fiscalyear(self, cr, uid, ids, context=None):
- obj = self.read(cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
+ obj = self.read(
+ cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
if not obj['fiscalyear_id'] and obj['filter'] == 'filter_no':
return False
return True
_constraints = [
- (_check_fiscalyear, 'When no Fiscal year is selected, you must choose to filter by periods or by date.', ['filter']),
+ (_check_fiscalyear,
+ 'When no Fiscal year is selected, you must choose to filter by \
+ periods or by date.', ['filter']),
]
def default_get(self, cr, uid, fields, context=None):
@@ -128,15 +144,19 @@ class AccountBalanceCommonWizard(orm.TransientModel):
@return: A dictionary which of fields with values.
"""
- res = super(AccountBalanceCommonWizard, self).default_get(cr, uid, fields, context=context)
+ res = super(AccountBalanceCommonWizard, self).default_get(
+ cr, uid, fields, context=context)
for index in range(self.COMPARISON_LEVEL):
field = "comp%s_filter" % (index,)
if not res.get(field, False):
res[field] = 'filter_no'
return res
- 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(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
+ 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(
+ cr, uid, view_id, view_type, context=context, toolbar=toolbar,
+ submenu=submenu)
res['fields'].update(self.fields_get(cr, uid,
allfields=self.DYNAMIC_FIELDS,
@@ -161,16 +181,23 @@ class AccountBalanceCommonWizard(orm.TransientModel):
modifiers_and_append(etree.Element(
'field',
{'name': "comp%s_filter" % index,
- 'on_change': "onchange_comp_filter(%(index)s, filter, comp%(index)s_filter, fiscalyear_id, date_from, date_to)" % {'index': index}}))
+ 'on_change': "onchange_comp_filter(%(index)s, filter,\
+ comp%(index)s_filter, fiscalyear_id, date_from, date_to)"
+ % {'index': index}}))
modifiers_and_append(etree.Element(
'field',
{'name': "comp%s_fiscalyear_id" % index,
'attrs':
- "{'required': [('comp%(index)s_filter','in',('filter_year','filter_opening'))]," \
- " 'invisible': [('comp%(index)s_filter','not in',('filter_year','filter_opening'))]}" % {'index': index}}))
+ "{'required': [('comp%(index)s_filter','in',\
+ ('filter_year','filter_opening'))],"
+ " 'invisible': [('comp%(index)s_filter','not in',\
+ ('filter_year','filter_opening'))]}" % {'index': index}}))
- dates_attrs = "{'required': [('comp%(index)s_filter','=','filter_date')], " \
- " 'invisible': [('comp%(index)s_filter','!=','filter_date')]}" % {'index': index}
+ dates_attrs = "{'required': [('comp%(index)s_filter','=',\
+ 'filter_date')], " \
+ " 'invisible': [('comp%(index)s_filter','!=',\
+ 'filter_date')]}" % {
+ 'index': index}
modifiers_and_append(etree.Element(
'separator',
{'string': _('Dates'),
@@ -185,8 +212,11 @@ class AccountBalanceCommonWizard(orm.TransientModel):
{'name': "comp%s_date_to" % index,
'attrs': dates_attrs}))
- periods_attrs = "{'required': [('comp%(index)s_filter','=','filter_period')]," \
- " 'invisible': [('comp%(index)s_filter','!=','filter_period')]}" % {'index': index}
+ periods_attrs = "{'required': [('comp%(index)s_filter','=',\
+ 'filter_period')]," \
+ " 'invisible': [('comp%(index)s_filter','!=',\
+ 'filter_period')]}" % {
+ 'index': index}
periods_domain = "[('special', '=', False)]"
modifiers_and_append(etree.Element(
'separator',
@@ -209,24 +239,34 @@ class AccountBalanceCommonWizard(orm.TransientModel):
res['arch'] = etree.tostring(eview)
return res
- def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
+ def onchange_filter(self, cr, uid, ids, filter='filter_no',
+ fiscalyear_id=False, context=None):
res = {}
if filter == 'filter_no':
- res['value'] = {'period_from': False, 'period_to': False, 'date_from': False, 'date_to': False}
+ res['value'] = {'period_from': False,
+ 'period_to': False,
+ 'date_from': False,
+ 'date_to': False}
if filter == 'filter_date':
if fiscalyear_id:
- fyear = self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id, context=context)
+ fyear = self.pool.get('account.fiscalyear').browse(
+ cr, uid, fiscalyear_id, context=context)
date_from = fyear.date_start
- date_to = fyear.date_stop > time.strftime('%Y-%m-%d') and time.strftime('%Y-%m-%d') or fyear.date_stop
+ date_to = fyear.date_stop > time.strftime(
+ '%Y-%m-%d') and time.strftime('%Y-%m-%d') \
+ or fyear.date_stop
else:
- date_from, date_to = time.strftime('%Y-01-01'), time.strftime('%Y-%m-%d')
- res['value'] = {'period_from': False, 'period_to': False, 'date_from': date_from, 'date_to': date_to}
+ date_from, date_to = time.strftime(
+ '%Y-01-01'), time.strftime('%Y-%m-%d')
+ res['value'] = {'period_from': False, 'period_to':
+ False, 'date_from': date_from, 'date_to': date_to}
if filter == 'filter_period' and fiscalyear_id:
start_period = end_period = False
cr.execute('''
SELECT * FROM (SELECT p.id
FROM account_period p
- LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
+ LEFT JOIN account_fiscalyear f
+ ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
AND COALESCE(p.special, FALSE) = FALSE
ORDER BY p.date_start ASC
@@ -234,31 +274,41 @@ class AccountBalanceCommonWizard(orm.TransientModel):
UNION ALL
SELECT * FROM (SELECT p.id
FROM account_period p
- LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
+ LEFT JOIN account_fiscalyear f
+ ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
AND p.date_start < NOW()
AND COALESCE(p.special, FALSE) = FALSE
ORDER BY p.date_stop DESC
- LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
+ LIMIT 1) AS period_stop''',
+ (fiscalyear_id, fiscalyear_id))
periods = [i[0] for i in cr.fetchall()]
if periods:
start_period = end_period = periods[0]
if len(periods) > 1:
end_period = periods[1]
- res['value'] = {'period_from': start_period, 'period_to': end_period, 'date_from': False, 'date_to': False}
+ res['value'] = {'period_from': start_period, 'period_to':
+ end_period, 'date_from': False, 'date_to': False}
return res
- def onchange_comp_filter(self, cr, uid, ids, index, main_filter='filter_no', comp_filter='filter_no', fiscalyear_id=False, start_date=False, stop_date=False, context=None):
+ def onchange_comp_filter(self, cr, uid, ids, index,
+ main_filter='filter_no', comp_filter='filter_no',
+ fiscalyear_id=False, start_date=False,
+ stop_date=False, context=None):
res = {}
fy_obj = self.pool.get('account.fiscalyear')
last_fiscalyear_id = False
if fiscalyear_id:
fiscalyear = fy_obj.browse(cr, uid, fiscalyear_id, context=context)
- last_fiscalyear_ids = fy_obj.search(cr, uid, [('date_stop', '<', fiscalyear.date_start)],
- limit=self.COMPARISON_LEVEL, order='date_start desc', context=context)
+ last_fiscalyear_ids = fy_obj.search(
+ cr, uid, [('date_stop', '<', fiscalyear.date_start)],
+ limit=self.COMPARISON_LEVEL, order='date_start desc',
+ context=context)
if last_fiscalyear_ids:
if len(last_fiscalyear_ids) > index:
- last_fiscalyear_id = last_fiscalyear_ids[index] # first element for the comparison 1, second element for the comparison 2
+ # first element for the comparison 1, second element for
+ # the comparison 2
+ last_fiscalyear_id = last_fiscalyear_ids[index]
fy_id_field = "comp%s_fiscalyear_id" % (index,)
period_from_field = "comp%s_period_from" % (index,)
@@ -268,37 +318,46 @@ class AccountBalanceCommonWizard(orm.TransientModel):
if comp_filter == 'filter_no':
res['value'] = {
- fy_id_field: False,
- period_from_field: False,
- period_to_field: False,
- date_from_field: False,
- date_to_field: False
- }
+ fy_id_field: False,
+ period_from_field: False,
+ period_to_field: False,
+ date_from_field: False,
+ date_to_field: False
+ }
if comp_filter in ('filter_year', 'filter_opening'):
res['value'] = {
- fy_id_field: last_fiscalyear_id,
- period_from_field: False,
- period_to_field: False,
- date_from_field: False,
- date_to_field: False
- }
+ fy_id_field: last_fiscalyear_id,
+ period_from_field: False,
+ period_to_field: False,
+ date_from_field: False,
+ date_to_field: False
+ }
if comp_filter == 'filter_date':
dates = {}
if main_filter == 'filter_date':
dates = {
- 'date_start': previous_year_date(start_date, index + 1).strftime('%Y-%m-%d'),
- 'date_stop': previous_year_date(stop_date, index + 1).strftime('%Y-%m-%d'),
- }
+ 'date_start': previous_year_date(start_date, index + 1).
+ strftime('%Y-%m-%d'),
+ 'date_stop': previous_year_date(stop_date, index + 1).
+ strftime('%Y-%m-%d'),
+ }
elif last_fiscalyear_id:
- dates = fy_obj.read(cr, uid, last_fiscalyear_id, ['date_start', 'date_stop'], context=context)
+ dates = fy_obj.read(
+ cr, uid, last_fiscalyear_id, ['date_start', 'date_stop'],
+ context=context)
- res['value'] = {fy_id_field: False, period_from_field: False, period_to_field: False, date_from_field: dates.get('date_start', False), date_to_field: dates.get('date_stop', False)}
+ res['value'] = {fy_id_field: False,
+ period_from_field: False,
+ period_to_field: False,
+ date_from_field: dates.get('date_start', False),
+ date_to_field: dates.get('date_stop', False)}
if comp_filter == 'filter_period' and last_fiscalyear_id:
start_period = end_period = False
cr.execute('''
SELECT * FROM (SELECT p.id
FROM account_period p
- LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
+ LEFT JOIN account_fiscalyear f
+ ON (p.fiscalyear_id = f.id)
WHERE f.id = %(fiscalyear)s
AND COALESCE(p.special, FALSE) = FALSE
ORDER BY p.date_start ASC
@@ -306,12 +365,14 @@ class AccountBalanceCommonWizard(orm.TransientModel):
UNION ALL
SELECT * FROM (SELECT p.id
FROM account_period p
- LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
+ LEFT JOIN account_fiscalyear f
+ ON (p.fiscalyear_id = f.id)
WHERE f.id = %(fiscalyear)s
AND p.date_start < NOW()
AND COALESCE(p.special, FALSE) = FALSE
ORDER BY p.date_stop DESC
- LIMIT 1) AS period_stop''', {'fiscalyear': last_fiscalyear_id})
+ LIMIT 1) AS period_stop''',
+ {'fiscalyear': last_fiscalyear_id})
periods = [i[0] for i in cr.fetchall()]
if periods and len(periods) > 1:
start_period = end_period = periods[0]
diff --git a/account_financial_report_webkit/wizard/general_ledger_wizard.py b/account_financial_report_webkit/wizard/general_ledger_wizard.py
index 79766563..f13a5816 100644
--- a/account_financial_report_webkit/wizard/general_ledger_wizard.py
+++ b/account_financial_report_webkit/wizard/general_ledger_wizard.py
@@ -25,6 +25,7 @@ from openerp.osv import fields, orm
class AccountReportGeneralLedgerWizard(orm.TransientModel):
+
"""Will launch general ledger report and pass required args"""
_inherit = "account.common.account.report"
@@ -33,7 +34,8 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
def _get_account_ids(self, cr, uid, context=None):
res = False
- if context.get('active_model', False) == 'account.account' and context.get('active_ids', False):
+ if context.get('active_model', False) == 'account.account' \
+ and context.get('active_ids', False):
res = context['active_ids']
return res
@@ -41,13 +43,18 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
'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.')
+ '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,
@@ -57,17 +64,21 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
}
def _check_fiscalyear(self, cr, uid, ids, context=None):
- obj = self.read(cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
+ obj = self.read(
+ cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
if not obj['fiscalyear_id'] and obj['filter'] == 'filter_no':
return False
return True
_constraints = [
- (_check_fiscalyear, 'When no Fiscal year is selected, you must choose to filter by periods or by date.', ['filter']),
+ (_check_fiscalyear,
+ 'When no Fiscal year is selected, you must choose to filter by \
+ periods or by date.', ['filter']),
]
def pre_print_report(self, cr, uid, ids, data, context=None):
- data = super(AccountReportGeneralLedgerWizard, self).pre_print_report(cr, uid, ids, data, context)
+ data = super(AccountReportGeneralLedgerWizard, self).pre_print_report(
+ cr, uid, ids, data, context)
# will be used to attach the report on the main account
data['ids'] = [data['form']['chart_account_id']]
vals = self.read(cr, uid, ids,
@@ -79,34 +90,40 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
data['form'].update(vals)
return data
- def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
+ def onchange_filter(self, cr, uid, ids, filter='filter_no',
+ fiscalyear_id=False, context=None):
res = {}
if filter == 'filter_no':
res['value'] = {
- 'period_from': False,
- 'period_to': False,
- 'date_from': False,
- 'date_to': False,
- }
+ 'period_from': False,
+ 'period_to': False,
+ 'date_from': False,
+ 'date_to': False,
+ }
if filter == 'filter_date':
if fiscalyear_id:
- fyear = self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id, context=context)
+ fyear = self.pool.get('account.fiscalyear').browse(
+ cr, uid, fiscalyear_id, context=context)
date_from = fyear.date_start
- date_to = fyear.date_stop > time.strftime('%Y-%m-%d') and time.strftime('%Y-%m-%d') or fyear.date_stop
+ date_to = fyear.date_stop > time.strftime(
+ '%Y-%m-%d') and time.strftime('%Y-%m-%d') \
+ or fyear.date_stop
else:
- date_from, date_to = time.strftime('%Y-01-01'), time.strftime('%Y-%m-%d')
+ date_from, date_to = time.strftime(
+ '%Y-01-01'), time.strftime('%Y-%m-%d')
res['value'] = {
- 'period_from': False,
- 'period_to': False,
- 'date_from': date_from,
- 'date_to': date_to
- }
+ 'period_from': False,
+ 'period_to': False,
+ 'date_from': date_from,
+ 'date_to': date_to
+ }
if filter == 'filter_period' and fiscalyear_id:
start_period = end_period = False
cr.execute('''
SELECT * FROM (SELECT p.id
FROM account_period p
- LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
+ LEFT JOIN account_fiscalyear f
+ ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
AND COALESCE(p.special, FALSE) = FALSE
ORDER BY p.date_start ASC
@@ -114,18 +131,21 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
UNION ALL
SELECT * FROM (SELECT p.id
FROM account_period p
- LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
+ LEFT JOIN account_fiscalyear f
+ ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
AND p.date_start < NOW()
AND COALESCE(p.special, FALSE) = FALSE
ORDER BY p.date_stop DESC
- LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
+ LIMIT 1) AS period_stop''',
+ (fiscalyear_id, fiscalyear_id))
periods = [i[0] for i in cr.fetchall()]
if periods:
start_period = end_period = periods[0]
if len(periods) > 1:
end_period = periods[1]
- res['value'] = {'period_from': start_period, 'period_to': end_period, 'date_from': False, 'date_to': False}
+ res['value'] = {'period_from': start_period, 'period_to':
+ end_period, 'date_from': False, 'date_to': False}
return res
def _print_report(self, cursor, uid, ids, data, context=None):
diff --git a/account_financial_report_webkit/wizard/open_invoices_wizard.py b/account_financial_report_webkit/wizard/open_invoices_wizard.py
index 4e18a8b7..7b57423c 100644
--- a/account_financial_report_webkit/wizard/open_invoices_wizard.py
+++ b/account_financial_report_webkit/wizard/open_invoices_wizard.py
@@ -22,6 +22,7 @@ from openerp.osv import fields, orm
class AccountReportOpenInvoicesWizard(orm.TransientModel):
+
"""Will launch partner ledger report and pass required args"""
_inherit = "partners.ledger.webkit"
@@ -30,20 +31,27 @@ class AccountReportOpenInvoicesWizard(orm.TransientModel):
_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.
+ '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).
+By default, this date is equal to the the end date (ie: 31/12/2011 if you
+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)?'
+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)?'
""")}
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
- obj = self.read(cr, uid, ids[0], ['fiscalyear_id', 'period_to', 'date_to', 'until_date'], context=context)
+ obj = self.read(cr, uid, ids[0], [
+ 'fiscalyear_id', 'period_to', 'date_to', 'until_date'],
+ context=context)
min_date = self.default_until_date(cr, uid, ids,
get_key_id(obj, 'fiscalyear_id'),
get_key_id(obj, 'period_to'),
@@ -54,59 +62,78 @@ By amending the clearance date, you will be, for instance, able to answer the qu
return True
_constraints = [
- (_check_until_date, 'Clearance date must be the very last date of the last period or later.', ['until_date']),
+ (_check_until_date, 'Clearance date must be the very last date of the \
+ last period or later.', ['until_date']),
]
- def default_until_date(self, cr, uid, ids, fiscalyear_id=False, period_id=False, date_to=False, context=None):
+ def default_until_date(self, cr, uid, ids, fiscalyear_id=False,
+ period_id=False, date_to=False, context=None):
res_date = False
# first priority: period or date filters
if period_id:
- res_date = self.pool.get('account.period').read(cr, uid, period_id, ['date_stop'], context=context)['date_stop']
+ res_date = self.pool.get('account.period').read(
+ cr, uid, period_id, ['date_stop'],
+ context=context)['date_stop']
elif date_to:
res_date = date_to
elif fiscalyear_id:
- res_date = self.pool.get('account.fiscalyear').read(cr, uid, fiscalyear_id, ['date_stop'], context=context)['date_stop']
+ res_date = self.pool.get('account.fiscalyear').read(
+ cr, uid, fiscalyear_id, ['date_stop'],
+ context=context)['date_stop']
return res_date
- def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None):
+ def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False,
+ period_id=False, date_to=False, until_date=False,
+ context=None):
res = {'value': {}}
- res['value']['until_date'] = self.default_until_date(cr, uid, ids,
- fiscalyear_id=fiscalyear,
- period_id=period_id,
- date_to=date_to,
- context=context)
+ res['value']['until_date'] = self.default_until_date(
+ cr, uid, ids,
+ fiscalyear_id=fiscalyear,
+ period_id=period_id,
+ date_to=date_to,
+ context=context)
return res
- def onchange_date_to(self, cr, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None):
+ def onchange_date_to(self, cr, uid, ids, fiscalyear=False, period_id=False,
+ date_to=False, until_date=False, context=None):
res = {'value': {}}
- res['value']['until_date'] = self.default_until_date(cr, uid, ids,
- fiscalyear_id=fiscalyear,
- period_id=period_id,
- date_to=date_to,
- context=context)
+ res['value']['until_date'] = self.default_until_date(
+ cr, uid, ids,
+ fiscalyear_id=fiscalyear,
+ period_id=period_id,
+ date_to=date_to,
+ context=context)
return res
- def onchange_period_to(self, cr, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None):
+ def onchange_period_to(self, cr, uid, ids, fiscalyear=False,
+ period_id=False, date_to=False, until_date=False,
+ context=None):
res = {'value': {}}
- res['value']['until_date'] = self.default_until_date(cr, uid, ids,
- fiscalyear_id=fiscalyear,
- period_id=period_id,
- date_to=date_to,
- context=context)
+ res['value']['until_date'] = self.default_until_date(
+ cr, uid, ids,
+ fiscalyear_id=fiscalyear,
+ period_id=period_id,
+ date_to=date_to,
+ context=context)
return res
- def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
- res = super(AccountReportOpenInvoicesWizard, self).onchange_filter(cr, uid, ids, filter=filter, fiscalyear_id=fiscalyear_id, context=context)
+ def onchange_filter(self, cr, uid, ids, filter='filter_no',
+ fiscalyear_id=False, context=None):
+ res = super(AccountReportOpenInvoicesWizard, self).onchange_filter(
+ cr, uid, ids, filter=filter, fiscalyear_id=fiscalyear_id,
+ context=context)
if res.get('value', False):
- res['value']['until_date'] = self.default_until_date(cr, uid, ids,
- fiscalyear_id=fiscalyear_id,
- period_id=res['value'].get('period_to', False),
- date_to=res['value'].get('date_to', False),
- context=context)
+ res['value']['until_date'] = self.default_until_date(
+ cr, uid, ids,
+ fiscalyear_id=fiscalyear_id,
+ period_id=res['value'].get('period_to', False),
+ date_to=res['value'].get('date_to', False),
+ context=context)
return res
def pre_print_report(self, cr, uid, ids, data, context=None):
- data = super(AccountReportOpenInvoicesWizard, self).pre_print_report(cr, uid, ids, data, context)
+ data = super(AccountReportOpenInvoicesWizard, self).pre_print_report(
+ cr, uid, ids, data, context)
vals = self.read(cr, uid, ids,
['until_date', 'group_by_currency'],
context=context)[0]
diff --git a/account_financial_report_webkit/wizard/partner_balance_wizard.py b/account_financial_report_webkit/wizard/partner_balance_wizard.py
index 755278d8..36bbe420 100644
--- a/account_financial_report_webkit/wizard/partner_balance_wizard.py
+++ b/account_financial_report_webkit/wizard/partner_balance_wizard.py
@@ -23,6 +23,7 @@ from openerp.osv import fields, orm
class AccountPartnerBalanceWizard(orm.TransientModel):
+
"""Will launch partner balance report and pass required args"""
_inherit = "account.common.balance.report"
@@ -30,12 +31,15 @@ class AccountPartnerBalanceWizard(orm.TransientModel):
_description = "Partner Balance Report"
_columns = {
- 'result_selection': fields.selection([('customer', 'Receivable Accounts'),
- ('supplier', 'Payable Accounts'),
- ('customer_supplier', 'Receivable and Payable Accounts')],
- "Partner's", required=True),
- 'partner_ids': fields.many2many('res.partner', string='Filter on partner',
- help="Only selected partners will be printed. Leave empty to print all partners."),
+ 'result_selection': fields.selection(
+ [('customer', 'Receivable Accounts'),
+ ('supplier', 'Payable Accounts'),
+ ('customer_supplier', 'Receivable and Payable Accounts')],
+ "Partner's", required=True),
+ 'partner_ids': fields.many2many(
+ 'res.partner', string='Filter on partner',
+ help="Only selected partners will be printed. \
+ Leave empty to print all partners."),
}
_defaults = {
@@ -43,7 +47,8 @@ class AccountPartnerBalanceWizard(orm.TransientModel):
}
def pre_print_report(self, cr, uid, ids, data, context=None):
- data = super(AccountPartnerBalanceWizard, self).pre_print_report(cr, uid, ids, data, context)
+ data = super(AccountPartnerBalanceWizard, self).\
+ pre_print_report(cr, uid, ids, data, context)
vals = self.read(cr, uid, ids,
['result_selection', 'partner_ids'],
context=context)[0]
diff --git a/account_financial_report_webkit/wizard/partners_ledger_wizard.py b/account_financial_report_webkit/wizard/partners_ledger_wizard.py
index b4204a56..48a33396 100644
--- a/account_financial_report_webkit/wizard/partners_ledger_wizard.py
+++ b/account_financial_report_webkit/wizard/partners_ledger_wizard.py
@@ -24,6 +24,7 @@ from openerp.osv import fields, orm
class AccountReportPartnersLedgerWizard(orm.TransientModel):
+
"""Will launch partner ledger report and pass required args"""
_inherit = "account.common.partner.report"
@@ -33,14 +34,18 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel):
_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).'),
+ '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,
@@ -48,7 +53,8 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel):
}
def _check_fiscalyear(self, cr, uid, ids, context=None):
- obj = self.read(cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
+ obj = self.read(
+ cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
if not obj['fiscalyear_id'] and obj['filter'] == 'filter_no':
return False
return True
@@ -60,25 +66,35 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel):
['filter']),
]
- def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
+ def onchange_filter(self, cr, uid, ids, filter='filter_no',
+ fiscalyear_id=False, context=None):
res = {}
if filter == 'filter_no':
- res['value'] = {'period_from': False, 'period_to': False, 'date_from': False, 'date_to': False}
+ res['value'] = {'period_from': False,
+ 'period_to': False,
+ 'date_from': False,
+ 'date_to': False}
if filter == 'filter_date':
if fiscalyear_id:
- fyear = self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id, context=context)
+ fyear = self.pool.get('account.fiscalyear').browse(
+ cr, uid, fiscalyear_id, context=context)
date_from = fyear.date_start
- date_to = fyear.date_stop > time.strftime('%Y-%m-%d') and time.strftime('%Y-%m-%d') or fyear.date_stop
+ date_to = fyear.date_stop > time.strftime(
+ '%Y-%m-%d') and time.strftime('%Y-%m-%d') \
+ or fyear.date_stop
else:
- date_from, date_to = time.strftime('%Y-01-01'), time.strftime('%Y-%m-%d')
- res['value'] = {'period_from': False, 'period_to': False, 'date_from': date_from, 'date_to': date_to}
+ date_from, date_to = time.strftime(
+ '%Y-01-01'), time.strftime('%Y-%m-%d')
+ res['value'] = {'period_from': False, 'period_to':
+ False, 'date_from': date_from, 'date_to': date_to}
if filter == 'filter_period' and fiscalyear_id:
start_period = end_period = False
cr.execute('''
SELECT * FROM (SELECT p.id
FROM account_period p
- LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
+ LEFT JOIN account_fiscalyear f
+ ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
AND COALESCE(p.special, FALSE) = FALSE
ORDER BY p.date_start ASC
@@ -86,22 +102,26 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel):
UNION ALL
SELECT * FROM (SELECT p.id
FROM account_period p
- LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
+ LEFT JOIN account_fiscalyear f
+ ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
AND p.date_start < NOW()
AND COALESCE(p.special, FALSE) = FALSE
ORDER BY p.date_stop DESC
- LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
+ LIMIT 1) AS period_stop''',
+ (fiscalyear_id, fiscalyear_id))
periods = [i[0] for i in cr.fetchall()]
if periods:
start_period = end_period = periods[0]
if len(periods) > 1:
end_period = periods[1]
- res['value'] = {'period_from': start_period, 'period_to': end_period, 'date_from': False, 'date_to': False}
+ res['value'] = {'period_from': start_period, 'period_to':
+ end_period, 'date_from': False, 'date_to': False}
return res
def pre_print_report(self, cr, uid, ids, data, context=None):
- data = super(AccountReportPartnersLedgerWizard, self).pre_print_report(cr, uid, ids, data, context)
+ data = super(AccountReportPartnersLedgerWizard, self).pre_print_report(
+ cr, uid, ids, data, context)
if context is None:
context = {}
# will be used to attach the report on the main account
diff --git a/account_financial_report_webkit/wizard/print_journal.py b/account_financial_report_webkit/wizard/print_journal.py
index c669308e..b1bad692 100644
--- a/account_financial_report_webkit/wizard/print_journal.py
+++ b/account_financial_report_webkit/wizard/print_journal.py
@@ -7,13 +7,13 @@
#
# This file is a part of account_financial_report_webkit
#
-# account_financial_report_webkit 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.
+# account_financial_report_webkit 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.
#
-# account_financial_report_webkit is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# account_financial_report_webkit 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.
#
@@ -24,10 +24,10 @@
from openerp.osv import fields, orm
import time
-from lxml import etree
class AccountReportPrintJournalWizard(orm.TransientModel):
+
"""Will launch print journal report and pass requiered args"""
_inherit = "account.common.account.report"
@@ -35,7 +35,8 @@ class AccountReportPrintJournalWizard(orm.TransientModel):
_description = "Journals Report"
_columns = {
- 'amount_currency': fields.boolean("With Currency", help="It adds the currency column"),
+ 'amount_currency': fields.boolean("With Currency",
+ help="It adds the currency column"),
}
_defaults = {
@@ -45,17 +46,20 @@ class AccountReportPrintJournalWizard(orm.TransientModel):
}
def _check_fiscalyear(self, cr, uid, ids, context=None):
- obj = self.read(cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
+ obj = self.read(cr, uid, ids[0], ['fiscalyear_id', 'filter'],
+ context=context)
if not obj['fiscalyear_id'] and obj['filter'] == 'filter_no':
return False
return True
_constraints = [
- (_check_fiscalyear, 'When no Fiscal year is selected, you must choose to filter by periods or by date.', ['filter']),
+ (_check_fiscalyear, 'When no Fiscal year is selected, you must choose \
+ to filter by periods or by date.', ['filter']),
]
def pre_print_report(self, cr, uid, ids, data, context=None):
- data = super(AccountReportPrintJournalWizard, self).pre_print_report(cr, uid, ids, data, context)
+ data = super(AccountReportPrintJournalWizard, self).\
+ pre_print_report(cr, uid, ids, data, context)
# will be used to attach the report on the main account
data['ids'] = [data['form']['chart_account_id']]
vals = self.read(cr, uid, ids,
@@ -66,24 +70,34 @@ class AccountReportPrintJournalWizard(orm.TransientModel):
data['form'].update(vals)
return data
- def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
+ def onchange_filter(self, cr, uid, ids, filter='filter_no',
+ fiscalyear_id=False, context=None):
res = {}
if filter == 'filter_no':
- res['value'] = {'period_from': False, 'period_to': False, 'date_from': False, 'date_to': False}
+ res['value'] = {'period_from': False,
+ 'period_to': False,
+ 'date_from': False,
+ 'date_to': False}
if filter == 'filter_date':
if fiscalyear_id:
- fyear = self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id, context=context)
+ fyear = self.pool.get('account.fiscalyear').browse(
+ cr, uid, fiscalyear_id, context=context)
date_from = fyear.date_start
- date_to = fyear.date_stop > time.strftime('%Y-%m-%d') and time.strftime('%Y-%m-%d') or fyear.date_stop
+ date_to = fyear.date_stop > time.strftime(
+ '%Y-%m-%d') and time.strftime('%Y-%m-%d') \
+ or fyear.date_stop
else:
- date_from, date_to = time.strftime('%Y-01-01'), time.strftime('%Y-%m-%d')
- res['value'] = {'period_from': False, 'period_to': False, 'date_from': date_from, 'date_to': date_to}
+ date_from, date_to = time.strftime(
+ '%Y-01-01'), time.strftime('%Y-%m-%d')
+ res['value'] = {'period_from': False, 'period_to':
+ False, 'date_from': date_from, 'date_to': date_to}
if filter == 'filter_period' and fiscalyear_id:
start_period = end_period = False
cr.execute('''
SELECT * FROM (SELECT p.id
FROM account_period p
- LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
+ LEFT JOIN account_fiscalyear f
+ ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
AND COALESCE(p.special, FALSE) = FALSE
ORDER BY p.date_start ASC
@@ -91,18 +105,21 @@ class AccountReportPrintJournalWizard(orm.TransientModel):
UNION ALL
SELECT * FROM (SELECT p.id
FROM account_period p
- LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
+ LEFT JOIN account_fiscalyear f
+ ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
AND p.date_start < NOW()
AND COALESCE(p.special, FALSE) = FALSE
ORDER BY p.date_stop DESC
- LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
+ LIMIT 1) AS period_stop''',
+ (fiscalyear_id, fiscalyear_id))
periods = [i[0] for i in cr.fetchall()]
if periods:
start_period = end_period = periods[0]
if len(periods) > 1:
end_period = periods[1]
- res['value'] = {'period_from': start_period, 'period_to': end_period, 'date_from': False, 'date_to': False}
+ res['value'] = {'period_from': start_period, 'period_to':
+ end_period, 'date_from': False, 'date_to': False}
return res
def _print_report(self, cursor, uid, ids, data, context=None):
@@ -112,7 +129,3 @@ class AccountReportPrintJournalWizard(orm.TransientModel):
return {'type': 'ir.actions.report.xml',
'report_name': 'account.account_report_print_journal_webkit',
'datas': data}
-
-AccountReportPrintJournalWizard()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/account_financial_report_webkit/wizard/trial_balance_wizard.py b/account_financial_report_webkit/wizard/trial_balance_wizard.py
index 6981a947..b34ce6c5 100644
--- a/account_financial_report_webkit/wizard/trial_balance_wizard.py
+++ b/account_financial_report_webkit/wizard/trial_balance_wizard.py
@@ -37,5 +37,3 @@ class AccountTrialBalanceWizard(orm.TransientModel):
return {'type': 'ir.actions.report.xml',
'report_name': 'account.account_report_trial_balance_webkit',
'datas': data}
-
-AccountTrialBalanceWizard()