[MRG] add webkit journal report on account_financial_webkit_report
commit
9c09eb7b8e
|
@ -115,7 +115,7 @@ date can be outside its logical period and the initial balance could
|
|||
be different when computed by data or by initial balance for the
|
||||
period). The opening period is assumed to be the Jan. 1st of the year
|
||||
with an opening flag and the first period of the year must start also
|
||||
on Jan 1st.
|
||||
on Jan 1st.
|
||||
|
||||
Totals for amounts in currencies are effective if the partner belongs to
|
||||
an account with a secondary currency.
|
||||
|
@ -147,6 +147,7 @@ wkhtmltopdf. The texts are defined inside the report classes.
|
|||
'wizard/trial_balance_wizard_view.xml',
|
||||
'wizard/partner_balance_wizard_view.xml',
|
||||
'wizard/open_invoices_wizard_view.xml',
|
||||
'wizard/print_journal_view.xml',
|
||||
'report_menus.xml',
|
||||
],
|
||||
# tests order matter
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,3 +8,4 @@ from . import webkit_parser_header_fix
|
|||
from . import trial_balance
|
||||
from . import partner_balance
|
||||
from . import open_invoices
|
||||
from . import print_journal
|
||||
|
|
|
@ -56,6 +56,9 @@ class CommonReportHeaderWebkit(common_report_header):
|
|||
return self.pool.get(model).browse(self.cursor, self.uid, info)
|
||||
return False
|
||||
|
||||
def _get_journals_br(self, data):
|
||||
return self._get_info(data, 'journal_ids', 'account.journal')
|
||||
|
||||
def _get_display_account(self, data):
|
||||
val = self._get_form_param('display_account', data)
|
||||
if val == 'bal_all':
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# account_financial_report_webkit module for OpenERP, Webkit based extended report financial report
|
||||
# Copyright (C) 2012 SYLEAM Info Services (<http://www.syleam.fr/>)
|
||||
# Sebastien LANGE <sebastien.lange@syleam.fr>
|
||||
#
|
||||
# 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 distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from report import report_sxw
|
||||
from tools.translate import _
|
||||
import pooler
|
||||
from datetime import datetime
|
||||
|
||||
from common_reports import CommonReportHeaderWebkit
|
||||
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)
|
||||
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 = company_obj.browse(self.cr, uid, company_id, context=context)
|
||||
header_report_name = ' - '.join((_('JOURNALS'), company.name, company.currency_id.name))
|
||||
|
||||
footer_date_time = self.formatLang(str(datetime.today()), date_time=True)
|
||||
|
||||
self.localcontext.update({
|
||||
'cr': cursor,
|
||||
'uid': uid,
|
||||
'report_name': _('Journals'),
|
||||
'display_account_raw': self._get_display_account_raw,
|
||||
'filter_form': self._get_filter,
|
||||
'target_move': self._get_target_move,
|
||||
'initial_balance': self._get_initial_balance,
|
||||
'amount_currency': self._get_amount_currency,
|
||||
'display_partner_account': self._get_display_partner_account,
|
||||
'display_target_move': self._get_display_target_move,
|
||||
'journals': self._get_journals_br,
|
||||
'additional_args': [
|
||||
('--header-font-name', 'Helvetica'),
|
||||
('--footer-font-name', 'Helvetica'),
|
||||
('--header-font-size', '10'),
|
||||
('--footer-font-size', '6'),
|
||||
('--header-left', header_report_name),
|
||||
('--header-spacing', '2'),
|
||||
('--footer-left', footer_date_time),
|
||||
('--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"""
|
||||
|
||||
# Reading form
|
||||
main_filter = self._get_form_param('filter', data, default='filter_no')
|
||||
target_move = self._get_form_param('target_move', data, default='all')
|
||||
start_date = self._get_form_param('date_from', data)
|
||||
stop_date = self._get_form_param('date_to', data)
|
||||
start_period = self.get_start_period_br(data)
|
||||
stop_period = self.get_end_period_br(data)
|
||||
fiscalyear = self.get_fiscalyear_br(data)
|
||||
journal_ids = self._get_form_param('journal_ids', data)
|
||||
chart_account = self._get_chart_account_id_br(data)
|
||||
account_period_obj = self.pool.get('account.period')
|
||||
|
||||
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),
|
||||
]
|
||||
# computation of move lines
|
||||
elif main_filter == 'filter_date':
|
||||
domain += [
|
||||
('date', '>=', start_date),
|
||||
('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)
|
||||
domain = [
|
||||
('period_id', 'in', period_ids),
|
||||
]
|
||||
if target_move == 'posted':
|
||||
domain += [('state', '=', 'posted')]
|
||||
account_journal_period_obj = self.pool.get('account.journal.period')
|
||||
new_ids = account_journal_period_obj.search(self.cursor, self.uid, [
|
||||
('journal_id', 'in', journal_ids),
|
||||
('period_id', 'in', period_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')
|
||||
for journal_period in objects:
|
||||
domain_arg = [
|
||||
('journal_id', '=', journal_period.journal_id.id),
|
||||
('period_id', '=', journal_period.period_id.id),
|
||||
]
|
||||
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)
|
||||
# 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))
|
||||
|
||||
self.localcontext.update({
|
||||
'fiscalyear': fiscalyear,
|
||||
'start_date': start_date,
|
||||
'stop_date': stop_date,
|
||||
'start_period': start_period,
|
||||
'stop_period': stop_period,
|
||||
'chart_account': chart_account,
|
||||
})
|
||||
|
||||
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)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -111,5 +111,25 @@
|
|||
<field eval="'ir.actions.report.xml,'+str(ref('account_financial_report_webkit.account_report_open_invoices_webkit'))" model="ir.actions.report.xml" name="res_id"/>
|
||||
</record>
|
||||
|
||||
<record id="account_report_print_journal_webkit" model="ir.actions.report.xml">
|
||||
<field name="report_type">webkit</field>
|
||||
<field name="report_name">account.account_report_print_journal_webkit</field>
|
||||
<field eval="[(6,0,[])]" name="groups_id"/>
|
||||
<field eval="0" name="multi"/>
|
||||
<field eval="0" name="auto"/>
|
||||
<field eval="1" name="header"/>
|
||||
<field name="model">account.move</field>
|
||||
<field name="type">ir.actions.report.xml</field>
|
||||
<field name="name">Journals</field>
|
||||
<field name="report_rml">account_financial_report_webkit/report/templates/account_report_print_journal.mako</field>
|
||||
<field name="report_file">account_financial_report_webkit/report/templates/account_report_print_journal.mako</field>
|
||||
</record>
|
||||
<record id="property_account_report_open_invoices_webkit" model="ir.property">
|
||||
<field name="name">account_report_print_journal_webkit</field>
|
||||
<field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
|
||||
<field eval="'ir.header_webkit,'+str(ref('account_financial_report_webkit.financial_landscape_header'))" model="ir.header_webkit" name="value"/>
|
||||
<field eval="'ir.actions.report.xml,'+str(ref('account_financial_report_webkit.account_report_print_journal_webkit'))" model="ir.actions.report.xml" name="res_id"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
.overflow_ellipsis {
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
${css}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%!
|
||||
def amount(text):
|
||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||
%>
|
||||
|
||||
<%setLang(user.lang)%>
|
||||
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row labels">
|
||||
<div class="act_as_cell">${_('Chart of Account')}</div>
|
||||
<div class="act_as_cell">${_('Fiscal Year')}</div>
|
||||
<div class="act_as_cell">
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${_('Dates Filter')}
|
||||
%else:
|
||||
${_('Periods Filter')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Journal Filter')}</div>
|
||||
<div class="act_as_cell">${_('Target Moves')}</div>
|
||||
</div>
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${ chart_account.name }</div>
|
||||
<div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
|
||||
<div class="act_as_cell">
|
||||
${_('From:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${formatLang(start_date, date=True) if start_date else u'' }
|
||||
%else:
|
||||
${start_period.name if start_period else u''}
|
||||
%endif
|
||||
${_('To:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${ formatLang(stop_date, date=True) if stop_date else u'' }
|
||||
%else:
|
||||
${stop_period.name if stop_period else u'' }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">
|
||||
%if journals(data):
|
||||
${', '.join([journal.name for journal in journals(data)])}
|
||||
%else:
|
||||
${_('All')}
|
||||
%endif
|
||||
|
||||
</div>
|
||||
<div class="act_as_cell">${ display_target_move(data) }</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
%for journal_period in objects:
|
||||
<%
|
||||
account_total_debit = 0.0
|
||||
account_total_credit = 0.0
|
||||
account_total_currency = 0.0
|
||||
%>
|
||||
|
||||
<div class="account_title bg" style="width: 1080px; margin-top: 20px; font-size: 12px;">${journal_period.journal_id.name} - ${journal_period.period_id.name}</div>
|
||||
|
||||
<!-- we use div with css instead of table for tabular data because div do not cut rows at half at page breaks -->
|
||||
<div class="act_as_table list_table" style="margin-top: 5px;">
|
||||
<div class="act_as_thead">
|
||||
<div class="act_as_row labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column">${_('Date')}</div>
|
||||
## move
|
||||
<div class="act_as_cell">${_('Entry')}</div>
|
||||
## account code
|
||||
<div class="act_as_cell">${_('Account')}</div>
|
||||
## date
|
||||
<div class="act_as_cell">${_('Due Date')}</div>
|
||||
## partner
|
||||
<div class="act_as_cell" style="width: 280px;">${_('Partner')}</div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 310px;">${_('Label')}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${_('Debit')}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${_('Credit')}</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left">${_('Curr. Balance')}</div>
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="text-align: right;">${_('Curr.')}</div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
%for move in journal_period.moves:
|
||||
<%
|
||||
new_move = True
|
||||
%>
|
||||
|
||||
%for line in move.line_id:
|
||||
<div class="act_as_tbody">
|
||||
<%
|
||||
account_total_debit += line.debit or 0.0
|
||||
account_total_credit += line.credit or 0.0
|
||||
%>
|
||||
<div class="act_as_row lines">
|
||||
## date
|
||||
<div class="act_as_cell first_column">${formatLang(move.date, date=True) if new_move else ''}</div>
|
||||
## move
|
||||
<div class="act_as_cell">${move.name if new_move else ''}</div>
|
||||
## account code
|
||||
<div class="act_as_cell">${line.account_id.code}</div>
|
||||
## date
|
||||
<div class="act_as_cell">${formatLang(line.date_maturity or '', date=True)}</div>
|
||||
## partner
|
||||
<div class="act_as_cell overflow_ellipsis" style="width: 280px;">${line.partner_id.name if new_move else ''}</div>
|
||||
## label
|
||||
<div class="act_as_cell overflow_ellipsis" style="width: 310px;">${line.name}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(line.debit) if line.debit else ''}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(line.credit) if line.credit else ''}</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left">${formatLang(line.amount_currency) if line.amount_currency else ''}</div>
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="text-align: right;">${line.currency_id.symbol or ''}</div>
|
||||
%endif
|
||||
</div>
|
||||
<%
|
||||
new_move = False
|
||||
%>
|
||||
</div>
|
||||
%endfor
|
||||
%endfor
|
||||
<div class="act_as_row lines labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column"></div>
|
||||
## move
|
||||
<div class="act_as_cell"></div>
|
||||
## account code
|
||||
<div class="act_as_cell"></div>
|
||||
## date
|
||||
<div class="act_as_cell"></div>
|
||||
## partner
|
||||
<div class="act_as_cell" style="width: 280px;"></div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 310px;"></div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(account_total_debit) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(account_total_credit) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left"></div>
|
||||
## currency code
|
||||
<div class="act_as_cell" style="text-align: right; right;"></div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
%endfor
|
||||
</body>
|
||||
</html>
|
|
@ -22,5 +22,14 @@
|
|||
parent="account.next_id_22" action="action_account_open_invoices_menu_webkit"
|
||||
groups="account.group_account_manager,account.group_account_user" id="menu_account_open_invoices"/>
|
||||
|
||||
<menuitem icon="STOCK_PRINT" name="Journals"
|
||||
parent="account.menu_journals_report" action="action_account_print_journal_menu_webkit"
|
||||
groups="account.group_account_manager,account.group_account_user" id="account.menu_account_print_journal"/>
|
||||
|
||||
<menuitem icon="STOCK_PRINT" name="Sale/Purchase Journals"
|
||||
parent="account.menu_journals_report" action="action_account_print_journal_sale_purchase_menu_webkit"
|
||||
groups="account.group_account_manager,account.group_account_user" id="account.menu_account_print_sale_purchase_journal"
|
||||
sequence="1"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi. Copyright Camptocamp SA
|
||||
# Copyright (C) 2012 SYLEAM Info Services (<http://www.syleam.fr/>)
|
||||
# Sebastien LANGE <sebastien.lange@syleam.fr>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -24,3 +26,4 @@ from . import partners_ledger_wizard
|
|||
from . import trial_balance_wizard
|
||||
from . import partner_balance_wizard
|
||||
from . import open_invoices_wizard
|
||||
from . import print_journal
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# account_financial_report_webkit module for OpenERP
|
||||
# Copyright (C) 2012 SYLEAM Info Services (<http://www.syleam.fr/>)
|
||||
# Sebastien LANGE <sebastien.lange@syleam.fr>
|
||||
#
|
||||
# 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 distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
import time
|
||||
from lxml import etree
|
||||
|
||||
|
||||
class AccountReportPrintJournalWizard(osv.osv_memory):
|
||||
"""Will launch print journal report and pass requiered args"""
|
||||
|
||||
_inherit = "account.common.account.report"
|
||||
_name = "print.journal.webkit"
|
||||
_description = "Journals Report"
|
||||
|
||||
_columns = {
|
||||
'amount_currency': fields.boolean("With Currency", help="It adds the currency column"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'amount_currency': False,
|
||||
'journal_ids': False,
|
||||
'filter': 'filter_period',
|
||||
}
|
||||
|
||||
def _check_fiscalyear(self, cr, uid, ids, context=None):
|
||||
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']),
|
||||
]
|
||||
|
||||
def pre_print_report(self, cr, uid, ids, data, context=None):
|
||||
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,
|
||||
['amount_currency',
|
||||
'display_account',
|
||||
'journal_ids'],
|
||||
context=context)[0]
|
||||
data['form'].update(vals)
|
||||
return data
|
||||
|
||||
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}
|
||||
if filter == 'filter_date':
|
||||
if fiscalyear_id:
|
||||
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
|
||||
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}
|
||||
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)
|
||||
WHERE f.id = %s
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_start ASC
|
||||
LIMIT 1) AS period_start
|
||||
UNION ALL
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
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))
|
||||
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}
|
||||
return res
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
'''
|
||||
used to set the domain on 'journal_ids' field: we exclude or only propose the journals of type
|
||||
sale/purchase (+refund) accordingly to the presence of the key 'sale_purchase_only' in the context.
|
||||
'''
|
||||
if context is None:
|
||||
context = {}
|
||||
res = super(AccountReportPrintJournalWizard, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
|
||||
doc = etree.XML(res['arch'])
|
||||
|
||||
if context.get('sale_purchase_only'):
|
||||
domain = "[('type', 'in', ('sale','purchase','sale_refund','purchase_refund'))]"
|
||||
else:
|
||||
domain = "[('type', 'not in', ('sale','purchase','sale_refund','purchase_refund'))]"
|
||||
nodes = doc.xpath("//field[@name='journal_ids']")
|
||||
for node in nodes:
|
||||
node.set('domain', domain)
|
||||
res['arch'] = etree.tostring(doc)
|
||||
return res
|
||||
|
||||
def _print_report(self, cursor, uid, ids, data, context=None):
|
||||
context = context or {}
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
||||
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:
|
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
##############################################################################
|
||||
#
|
||||
# account_financial_report_webkit module for OpenERP, Webkit based extended report financial report
|
||||
# Copyright (C) 2012 SYLEAM Info Services ([http://www.syleam.fr/])
|
||||
# Sebastien LANGE [sebastien.lange@syleam.fr]
|
||||
#
|
||||
# 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 distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
<record id="account_report_print_journal_view_webkit" model="ir.ui.view">
|
||||
<field name="name">Journals</field>
|
||||
<field name="model">print.journal.webkit</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[@string='']" position="replace">
|
||||
<separator string="Journals" colspan="4"/>
|
||||
<label nolabel="1" colspan="4" string="This report allows you to print or generate a pdf of your print journal with details of all your account journals"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='target_move']" position="after">
|
||||
<field name="amount_currency"/>
|
||||
<newline/>
|
||||
<field name="filter" on_change="onchange_filter(filter, fiscalyear_id)" colspan="4" invisible="1"/>
|
||||
<separator string="Periods" colspan="4"/>
|
||||
<field name="period_from" domain="[('fiscalyear_id', '=', fiscalyear_id)]" required="1" colspan="4"/>
|
||||
<field name="period_to" domain="[('fiscalyear_id', '=', fiscalyear_id)]" required="1" colspan="4"/>
|
||||
<separator string="Journals" colspan="4"/>
|
||||
<field name="journal_ids" colspan="4" nolabel="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='filters']" position="replace">
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='journal_ids']" position="replace">
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="account_report_print_journal_view_inherit" model="ir.ui.view">
|
||||
<field name="name">Journals</field>
|
||||
<field name="model">print.journal.webkit</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.account_report_print_journal"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="fiscalyear_id" position="replace">
|
||||
<field name="fiscalyear_id" on_change="onchange_fiscalyear(fiscalyear_id)"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_print_journal_menu_webkit" model="ir.actions.act_window">
|
||||
<field name="name">Journals</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">print.journal.webkit</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_report_print_journal_view_webkit"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_account_print_journal_values_webkit">
|
||||
<field name="model_id" ref="account.model_account_account"/>
|
||||
<field name="object" eval="1"/>
|
||||
<field name="name">Journals</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value"
|
||||
eval="'ir.actions.act_window,' +str(ref('action_account_print_journal_menu_webkit'))"/>
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.journal.period</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_print_journal_sale_purchase_menu_webkit" model="ir.actions.act_window">
|
||||
<field name="name">Journals</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">print.journal.webkit</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_report_print_journal_view_webkit"/>
|
||||
<field name="context">{'sale_purchase_only':True}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue