Browse Source

coding guidelines improvement

pull/7/merge
Luc De Meyer 11 years ago
parent
commit
0064b81dce
  1. 10
      account_journal_report_xls/__openerp__.py
  2. 5
      account_journal_report_xls/account_journal.py
  3. 1
      account_journal_report_xls/report/__init__.py
  4. 107
      account_journal_report_xls/report/nov_account_journal.py
  5. 62
      account_journal_report_xls/report/nov_account_journal_xls.py
  6. 19
      account_journal_report_xls/wizard/print_journal_wizard.py

10
account_journal_report_xls/__openerp__.py

@ -25,7 +25,7 @@
'version': '0.1',
'license': 'AGPL-3',
'author': 'Noviat',
'category' : 'Accounting & Finance',
'category': 'Accounting & Finance',
'description': """
Journal Reports
@ -39,17 +39,17 @@ This module adds journal reports by period and by fiscal year with
These reports are available in PDF and XLS format.
If you are installing this module manually, you need also the module 'report_xls', that is located in:
https://launchpad.net/openerp-reporting-engines"
This module depends upon the 'report_xls' module,
cf. https://launchpad.net/openerp-reporting-engines
""",
'depends': [
'account_voucher',
'report_xls'
'report_xls',
],
'demo_xml': [],
'init_xml': [],
'update_xml' : [
'update_xml': [
'wizard/print_journal_wizard.xml',
],
}

5
account_journal_report_xls/account_journal.py

@ -24,6 +24,7 @@ from openerp.osv import orm
from openerp.addons.report_xls.utils import rowcol_to_cell, _render
from openerp.tools.translate import _
class account_journal(orm.Model):
_inherit = 'account.journal'
@ -32,7 +33,7 @@ class account_journal(orm.Model):
select_extra = ""
join_extra = ""
where_extra = ""
return [select_extra, join_extra, where_extra]
return (select_extra, join_extra, where_extra)
# allow inherited modules to add document references
def _report_xls_document_extra(self, cr, uid, context):
@ -74,7 +75,7 @@ class account_journal(orm.Model):
my_change = {
'move_name':{
'header': [1, 20, 'text', _('My Move Title')],
'header': [1, 20, 'text', _render("_('My Move Title')")],
'lines': [1, 0, 'text', _render("l['move_name'] != '/' and l['move_name'] or ('*'+str(l['move_id']))")],
'totals': [1, 0, 'text', None]},
}

1
account_journal_report_xls/report/__init__.py

@ -24,4 +24,3 @@ import nov_account_journal
import nov_account_journal_xls
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

107
account_journal_report_xls/report/nov_account_journal.py

@ -28,6 +28,7 @@ _logger = logging.getLogger(__name__)
_ir_translation_name = 'nov.account.journal.print'
class nov_journal_print(report_sxw.rml_parse):
def set_context(self, objects, data, ids, report_type=None):
@ -40,7 +41,7 @@ class nov_journal_print(report_sxw.rml_parse):
if data['target_move'] == 'posted':
self.move_states = ['posted']
else:
self.move_states = ['draft','posted']
self.move_states = ['draft', 'posted']
self.display_currency = self.localcontext['display_currency'] = data['display_currency']
self.group_entries = data['group_entries']
self.print_by = data['print_by']
@ -104,11 +105,10 @@ class nov_journal_print(report_sxw.rml_parse):
if ids_journal_period:
self.cr.execute(
'update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s',
('printed', journal_id, period_id, 'draft')
)
('printed', journal_id, period_id, 'draft'))
else:
self.pool.get('account.journal.period').create(self.cr, self.uid, {
'name': (journal.code or journal.name)+':'+(period.name or ''),
'name': (journal.code or journal.name) + ':' + (period.name or ''),
'journal_id': journal.id,
'period_id': period.id,
'state': 'printed',
@ -121,60 +121,59 @@ class nov_journal_print(report_sxw.rml_parse):
select_extra, join_extra, where_extra = j_obj._report_xls_query_extra(self.cr, self.uid, self.context)
self.cr.execute("SELECT l.move_id AS move_id, l.id AS aml_id, " \
"am.name AS move_name, coalesce(am.ref,'') AS move_ref, am.date AS move_date, " \
"aa.id AS account_id, aa.code AS acc_code, " \
"coalesce(rp.name,'') AS partner_name, coalesce(rp.ref,'') AS partner_ref, rp.id AS partner_id, " \
"coalesce(l.name,'') AS aml_name, " \
"l.date_maturity AS date_maturity, " \
"coalesce(ap.code, ap.name) AS period, " \
"coalesce(atc.code,'') AS tax_code, atc.id AS tax_code_id, coalesce(l.tax_amount,0.0) AS tax_amount, " \
"coalesce(l.debit,0.0) AS debit, coalesce(l.credit,0.0) AS credit, " \
"coalesce(amr.name,'') AS reconcile, coalesce(amrp.name,'') AS reconcile_partial, " \
"coalesce(l.amount_currency,0.0) AS amount_currency, " \
"rc.id AS currency_id, rc.name AS currency_name, rc.symbol AS currency_symbol, " \
"coalesce(ai.internal_number,'-') AS inv_number, coalesce(abs.name,'-') AS st_number, coalesce(av.number,'-') AS voucher_number " \
+ select_extra + \
"FROM account_move_line l " \
"INNER JOIN account_move am ON l.move_id = am.id " \
"INNER JOIN account_account aa ON l.account_id = aa.id " \
"INNER JOIN account_period ap ON l.period_id = ap.id " \
"LEFT OUTER JOIN account_invoice ai ON ai.move_id = am.id " \
"LEFT OUTER JOIN account_voucher av ON av.move_id = am.id " \
"LEFT OUTER JOIN account_bank_statement abs ON l.statement_id = abs.id " \
"LEFT OUTER JOIN res_partner rp ON l.partner_id = rp.id " \
"LEFT OUTER JOIN account_tax_code atc ON l.tax_code_id = atc.id " \
"LEFT OUTER JOIN account_move_reconcile amr ON l.reconcile_id = amr.id " \
"LEFT OUTER JOIN account_move_reconcile amrp ON l.reconcile_partial_id = amrp.id " \
"LEFT OUTER JOIN res_currency rc ON l.currency_id = rc.id " \
+ join_extra + \
"WHERE l.period_id IN %s AND l.journal_id = %s " \
"AND am.state IN %s " \
+ where_extra + \
self.cr.execute("SELECT l.move_id AS move_id, l.id AS aml_id, "
"am.name AS move_name, coalesce(am.ref,'') AS move_ref, am.date AS move_date, "
"aa.id AS account_id, aa.code AS acc_code, "
"coalesce(rp.name,'') AS partner_name, coalesce(rp.ref,'') AS partner_ref, rp.id AS partner_id, "
"coalesce(l.name,'') AS aml_name, "
"l.date_maturity AS date_maturity, "
"coalesce(ap.code, ap.name) AS period, "
"coalesce(atc.code,'') AS tax_code, atc.id AS tax_code_id, coalesce(l.tax_amount,0.0) AS tax_amount, "
"coalesce(l.debit,0.0) AS debit, coalesce(l.credit,0.0) AS credit, "
"coalesce(amr.name,'') AS reconcile, coalesce(amrp.name,'') AS reconcile_partial, "
"coalesce(l.amount_currency,0.0) AS amount_currency, "
"rc.id AS currency_id, rc.name AS currency_name, rc.symbol AS currency_symbol, "
"coalesce(ai.internal_number,'-') AS inv_number, coalesce(abs.name,'-') AS st_number, coalesce(av.number,'-') AS voucher_number "
+ select_extra +
"FROM account_move_line l "
"INNER JOIN account_move am ON l.move_id = am.id "
"INNER JOIN account_account aa ON l.account_id = aa.id "
"INNER JOIN account_period ap ON l.period_id = ap.id "
"LEFT OUTER JOIN account_invoice ai ON ai.move_id = am.id "
"LEFT OUTER JOIN account_voucher av ON av.move_id = am.id "
"LEFT OUTER JOIN account_bank_statement abs ON l.statement_id = abs.id "
"LEFT OUTER JOIN res_partner rp ON l.partner_id = rp.id "
"LEFT OUTER JOIN account_tax_code atc ON l.tax_code_id = atc.id "
"LEFT OUTER JOIN account_move_reconcile amr ON l.reconcile_id = amr.id "
"LEFT OUTER JOIN account_move_reconcile amrp ON l.reconcile_partial_id = amrp.id "
"LEFT OUTER JOIN res_currency rc ON l.currency_id = rc.id "
+ join_extra +
"WHERE l.period_id IN %s AND l.journal_id = %s "
"AND am.state IN %s "
+ where_extra +
"ORDER BY " + self.sort_selection + ", move_date, move_id, acc_code",
(tuple(period_ids), journal_id, tuple(self.move_states))
)
(tuple(period_ids), journal_id, tuple(self.move_states)))
lines = self.cr.dictfetchall()
# add reference of corresponding origin document
if journal.type in ['sale', 'sale_refund', 'purchase', 'purchase_refund']:
map(lambda x: x.update({'docname' : (_('Invoice') + ': ' + x['inv_number']) or (_('Voucher') + ': ' + x['voucher_number']) or '-'}), lines)
elif journal.type in ['bank', 'cash']:
map(lambda x: x.update({'docname' : (_('Statement') + ': ' + x['st_number']) or (_('Voucher') + ': ' + x['voucher_number']) or '-'}), lines)
if journal.type in ('sale', 'sale_refund', 'purchase', 'purchase_refund'):
[x.update({'docname': (_('Invoice') + ': ' + x['inv_number']) or (_('Voucher') + ': ' + x['voucher_number']) or '-'}) for x in lines]
elif journal.type in ('bank', 'cash'):
[x.update({'docname': (_('Statement') + ': ' + x['st_number']) or (_('Voucher') + ': ' + x['voucher_number']) or '-'}) for x in lines]
else:
code_string = j_obj._report_xls_document_extra(self.cr, self.uid, self.context)
#_logger.warn('code_string= %s', code_string)
map(lambda x: x.update({'docname' : eval(code_string) or '-'}), lines)
[x.update({'docname': eval(code_string) or '-'}) for x in lines]
# format debit, credit, amount_currency for pdf report
if self.display_currency and self.report_type == 'pdf':
curr_obj = self.pool.get('res.currency')
map(lambda x: x.update({
'amount1': self.formatLang(x['debit']-x['credit']),
'amount2': self.formatLang(x['amount_currency'], monetary=True, currency_obj=curr_obj.browse(self.cr, self.uid, x['currency_id']))
}), lines)
[x.update({
'amount1': self.formatLang(x['debit'] - x['credit']),
'amount2': self.formatLang(x['amount_currency'], monetary=True, currency_obj=curr_obj.browse(self.cr, self.uid, x['currency_id'])),
}) for x in lines]
else:
map(lambda x: x.update({'amount1': self.formatLang(x['debit']), 'amount2': self.formatLang(x['credit'])}), lines)
[x.update({'amount1': self.formatLang(x['debit']), 'amount2': self.formatLang(x['credit'])}) for x in lines]
# group lines
if self.group_entries:
@ -182,8 +181,8 @@ class nov_journal_print(report_sxw.rml_parse):
# insert a flag in every move_line to indicate the end of a move
# this flag will be used to draw a full line between moves
for cnt in range(len(lines)-1):
if lines[cnt]['move_id'] <> lines[cnt+1]['move_id']:
for cnt in range(len(lines) - 1):
if lines[cnt]['move_id'] != lines[cnt + 1]['move_id']:
lines[cnt]['draw_line'] = 1
else:
lines[cnt]['draw_line'] = 0
@ -209,18 +208,18 @@ class nov_journal_print(report_sxw.rml_parse):
lines_grouped[key]['tax_amount'] += line['tax_amount']
lines_grouped[key]['aml_name'] = _('Grouped Entries')
lines_out = lines_grouped.values()
lines_out.sort(key=lambda x:x['acc_code'])
lines_out.sort(key=lambda x: x['acc_code'])
return lines_out
lines_out = []
grouped_lines = [lines_in[0]]
move_id = lines_in[0]['move_id']
line_cnt = len(lines_in)
for i in range(1,line_cnt):
for i, line in enumerate(lines_in):
line = lines_in[i]
if line['move_id'] == move_id:
grouped_lines.append(line)
if i == line_cnt-1:
if i == line_cnt - 1:
lines_out += group_move(grouped_lines)
else:
lines_out += group_move(grouped_lines)
@ -238,8 +237,8 @@ class nov_journal_print(report_sxw.rml_parse):
fiscalyear = object[1]
period_ids = [x.id for x in fiscalyear.period_ids]
self.cr.execute(
"SELECT distinct tax_code_id FROM account_move_line l " \
"INNER JOIN account_move am ON l.move_id = am.id " \
"SELECT distinct tax_code_id FROM account_move_line l "
"INNER JOIN account_move am ON l.move_id = am.id "
"WHERE l.period_id in %s AND l.journal_id=%s AND l.tax_code_id IS NOT NULL AND am.state IN %s",
(tuple(period_ids), journal_id, tuple(self.move_states)))
ids = map(lambda x: x[0], self.cr.fetchall())
@ -263,7 +262,7 @@ class nov_journal_print(report_sxw.rml_parse):
"INNER JOIN account_move am ON l.move_id = am.id " \
"WHERE l.period_id IN %s AND l.journal_id=%s AND am.state IN %s"
if field == 'tax_amount':
select += " AND tax_code_id=%s" %tax_code_id
select += " AND tax_code_id=%s" % tax_code_id
self.cr.execute(select, (tuple(period_ids), journal_id, tuple(self.move_states)))
return self.cr.fetchone()[0] or 0.0

62
account_journal_report_xls/report/nov_account_journal_xls.py

@ -32,6 +32,7 @@ from openerp.tools.translate import _
import logging
_logger = logging.getLogger(__name__)
class account_journal_xls_parser(nov_journal_print):
def __init__(self, cr, uid, name, context):
@ -46,6 +47,7 @@ class account_journal_xls_parser(nov_journal_print):
'template_changes': template_changes,
})
class account_journal_xls(report_xls):
def __init__(self, name, table, rml=False, parser=False, header=True, store=False):
@ -62,97 +64,97 @@ class account_journal_xls(report_xls):
aml_cell_format = _xs['borders_all']
self.aml_cell_style = xlwt.easyxf(aml_cell_format)
self.aml_cell_style_center = xlwt.easyxf(aml_cell_format + _xs['center'])
self.aml_cell_style_date = xlwt.easyxf(aml_cell_format + _xs['left'], num_format_str = report_xls.date_format)
self.aml_cell_style_decimal = xlwt.easyxf(aml_cell_format + _xs['right'], num_format_str = report_xls.decimal_format)
self.aml_cell_style_date = xlwt.easyxf(aml_cell_format + _xs['left'], num_format_str=report_xls.date_format)
self.aml_cell_style_decimal = xlwt.easyxf(aml_cell_format + _xs['right'], num_format_str=report_xls.decimal_format)
# totals
rt_cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all']
self.rt_cell_style = xlwt.easyxf(rt_cell_format)
self.rt_cell_style_right = xlwt.easyxf(rt_cell_format + _xs['right'])
self.rt_cell_style_decimal = xlwt.easyxf(rt_cell_format + _xs['right'], num_format_str = report_xls.decimal_format)
self.rt_cell_style_decimal = xlwt.easyxf(rt_cell_format + _xs['right'], num_format_str=report_xls.decimal_format)
# XLS Template Journal Items
self.col_specs_lines_template = {
'move_name':{
'move_name': {
'header': [1, 20, 'text', _render("_('Entry')")],
'lines': [1, 0, 'text', _render("l['move_name'] != '/' and l['move_name'] or ('*'+str(l['move_id']))")],
'totals': [1, 0, 'text', None]},
'move_date':{
'move_date': {
'header': [1, 13, 'text', _render("_('Date')")],
'lines': [1, 0, 'date', _render("datetime.strptime(l['move_date'],'%Y-%m-%d')"), None, self.aml_cell_style_date],
'totals': [1, 0, 'text', None]},
'acc_code':{
'acc_code': {
'header': [1, 12, 'text', _render("_('Account')")],
'lines': [1, 0, 'text', _render("l['acc_code']")],
'totals': [1, 0, 'text', None]},
'aml_name':{
'aml_name': {
'header': [1, 42, 'text', _render("_('Description')")],
'lines': [1, 0, 'text', _render("l['aml_name']")],
'totals': [1, 0, 'text', None]},
'period':{
'period': {
'header': [1, 12, 'text', _render("_('Period')")],
'lines': [1, 0, 'text', _render("l['period']")],
'totals': [1, 0, 'text', None]},
'partner_name':{
'partner_name': {
'header': [1, 36, 'text', _render("_('Partner')")],
'lines': [1, 0, 'text', _render("l['partner_name']")],
'totals': [1, 0, 'text', None]},
'partner_ref':{
'partner_ref': {
'header': [1, 36, 'text', _render("_('Partner Reference')")],
'lines': [1, 0, 'text', _render("l['partner_ref']")],
'totals': [1, 0, 'text', None]},
'date_maturity':{
'date_maturity': {
'header': [1, 13, 'text', _render("_('Maturity Date')")],
'lines': [1, 0, _render("l['date_maturity'] and 'date' or 'text'"),
_render("l['date_maturity'] and datetime.strptime(l['date_maturity'],'%Y-%m-%d') or None"),
None, self.aml_cell_style_date],
'totals': [1, 0, 'text', None]},
'debit':{
'debit': {
'header': [1, 18, 'text', _render("_('Debit')"), None, self.rh_cell_style_right],
'lines': [1, 0, 'number', _render("l['debit']"), None, self.aml_cell_style_decimal],
'totals': [1, 0, 'number', None, _render("debit_formula"), self.rt_cell_style_decimal]},
'credit':{
'credit': {
'header': [1, 18, 'text', _render("_('Credit')"), None, self.rh_cell_style_right],
'lines': [1, 0, 'number', _render("l['credit']"), None, self.aml_cell_style_decimal],
'totals': [1, 0, 'number', None, _render("credit_formula"), self.rt_cell_style_decimal]},
'balance':{
'balance': {
'header': [1, 18, 'text', _render("_('Balance')"), None, self.rh_cell_style_right],
'lines': [1, 0, 'number', None, _render("bal_formula"), self.aml_cell_style_decimal],
'totals': [1, 0, 'number', None, _render("bal_formula"), self.rt_cell_style_decimal]},
'reconcile':{
'reconcile': {
'header': [1, 12, 'text', _render("_('Rec.')"), None, self.rh_cell_style_center],
'lines': [1, 0, 'text', _render("l['reconcile']"), None, self.aml_cell_style_center],
'totals': [1, 0, 'text', None]},
'reconcile_partial':{
'reconcile_partial': {
'header': [1, 12, 'text', _render("_('Part. Rec.')"), None, self.rh_cell_style_center],
'lines': [1, 0, 'text', _render("l['reconcile_partial']"), None, self.aml_cell_style_center],
'totals': [1, 0, 'text', None]},
'tax_code':{
'tax_code': {
'header': [1, 6, 'text', _render("_('VAT')"), None, self.rh_cell_style_center],
'lines': [1, 0, 'text', _render("l['tax_code']"), None, self.aml_cell_style_center],
'totals': [1, 0, 'text', None]},
'tax_amount':{
'tax_amount': {
'header': [1, 18, 'text', _render("_('VAT Amount')"), None, self.rh_cell_style_right],
'lines': [1, 0, 'number', _render("l['tax_amount']"), None, self.aml_cell_style_decimal],
'totals': [1, 0, 'text', None]},
'amount_currency':{
'amount_currency': {
'header': [1, 18, 'text', _render("_('Am. Currency')"), None, self.rh_cell_style_right],
'lines': [1, 0, _render("l['amount_currency'] and 'number' or 'text'"),
_render("l['amount_currency'] or None"),
None, self.aml_cell_style_decimal],
'totals': [1, 0, 'text', None]},
'currency_name':{
'currency_name': {
'header': [1, 6, 'text', _render("_('Curr.')"), None, self.rh_cell_style_center],
'lines': [1, 0, 'text', _render("l['currency_name']"), None, self.aml_cell_style_center],
'totals': [1, 0, 'text', None]},
'docname':{
'docname': {
'header': [1, 35, 'text', _render("_('Document')")],
'lines': [1, 0, 'text', _render("l['docname']")],
'totals': [1, 0, 'text', None]},
'move_ref':{
'move_ref': {
'header': [1, 25, 'text', _render("_('Entry Reference')")],
'lines': [1, 0, 'text', _render("l['move_ref']")],
'totals': [1, 0, 'text', None]},
'move_id':{
'move_id': {
'header': [1, 10, 'text', _render("_('Entry Id')")],
'lines': [1, 0, 'text', _render("str(l['move_id'])")],
'totals': [1, 0, 'text', None]},
@ -160,20 +162,20 @@ class account_journal_xls(report_xls):
# XLS Template VAT Summary
self.col_specs_vat_summary_template = {
'tax_case_name':{
'tax_case_name': {
'header': [1, 45, 'text', _render("_('Description')")],
'tax_totals': [1, 0, 'text', _render("t.name")]},
'tax_code':{
'tax_code': {
'header': [1, 6, 'text', _render("_('Case')")],
'tax_totals': [1, 0, 'text', _render("t.code")]},
'tax_amount':{
'tax_amount': {
'header': [1, 18, 'text', _render("_('Amount')"), None, self.rh_cell_style_right],
'tax_totals': [1, 0, 'number', _render("sum_vat(o,t)"), None, self.aml_cell_style_decimal]},
}
def _journal_title(self, o, ws, _p, row_pos, xlwt, _xs):
cell_style = xlwt.easyxf(_xs['xls_title'])
report_name = (10*' ').join([
report_name = (10 * ' ').join([
_p.company.name,
_p.title(o)[0],
_p.title(o)[1],
@ -216,10 +218,10 @@ class account_journal_xls(report_xls):
# Totals
debit_start = rowcol_to_cell(aml_start_pos, debit_pos)
debit_stop = rowcol_to_cell(row_pos - 1, debit_pos)
debit_formula = 'SUM(%s:%s)' %(debit_start, debit_stop)
debit_formula = 'SUM(%s:%s)' % (debit_start, debit_stop)
credit_start = rowcol_to_cell(aml_start_pos, credit_pos)
credit_stop = rowcol_to_cell(row_pos - 1, credit_pos)
credit_formula = 'SUM(%s:%s)' %(credit_start, credit_stop)
credit_formula = 'SUM(%s:%s)' % (credit_start, credit_stop)
debit_cell = rowcol_to_cell(row_pos, debit_pos)
credit_cell = rowcol_to_cell(row_pos, credit_pos)
bal_formula = debit_cell + '-' + credit_cell
@ -296,7 +298,7 @@ class account_journal_xls(report_xls):
ws = wb.add_sheet(sheet_name)
ws.panes_frozen = True
ws.remove_splits = True
ws.portrait = 0 # Landscape
ws.portrait = 0 # Landscape
ws.fit_width_to_pages = 1
row_pos = 0

19
account_journal_report_xls/wizard/print_journal_wizard.py

@ -27,6 +27,7 @@ import time
import logging
_logger = logging.getLogger(__name__)
class account_print_journal_xls(orm.TransientModel):
_inherit = 'account.print.journal'
_name = 'account.print.journal.xls'
@ -35,7 +36,7 @@ class account_print_journal_xls(orm.TransientModel):
'journal_ids': fields.many2many('account.journal', string='Journals', required=True),
'group_entries': fields.boolean('Group Entries', help="Group entries with same General Account & Tax Code."),
}
_defaults={
_defaults = {
'group_entries': True,
}
@ -58,12 +59,12 @@ class account_print_journal_xls(orm.TransientModel):
def fy_period_ids(self, cr, uid, fiscalyear_id):
""" returns all periods from a fiscalyear sorted by date """
fy_period_ids = []
cr.execute('SELECT id, coalesce(special, False) AS special FROM account_period ' \
cr.execute('SELECT id, coalesce(special, False) AS special FROM account_period '
'WHERE fiscalyear_id=%s ORDER BY date_start, special DESC',
(fiscalyear_id,))
res = cr.fetchall()
if res:
fy_period_ids = map(lambda x: x[0], res)
fy_period_ids = [x[0] for x in res]
return fy_period_ids
def onchange_fiscalyear_id(self, cr, uid, ids, fiscalyear_id=False, context=None):
@ -97,18 +98,18 @@ class account_print_journal_xls(orm.TransientModel):
else:
period_from = wiz_form.period_from
period_to = wiz_form.period_to
cr.execute("SELECT id, coalesce(special, False) AS special FROM account_period ap " \
"WHERE ap.date_start>=%s AND ap.date_stop<=%s AND company_id=%s " \
cr.execute("SELECT id, coalesce(special, False) AS special FROM account_period ap "
"WHERE ap.date_start>=%s AND ap.date_stop<=%s AND company_id=%s "
"ORDER BY date_start, special DESC",
(period_from.date_start, period_to.date_stop, company_id))
wiz_period_ids = map(lambda x: x[0], cr.fetchall())
wiz_period_ids = [x[0] for x in cr.fetchall()]
wiz_journal_ids = [j.id for j in wiz_form.journal_ids]
# sort journals
cr.execute('SELECT id FROM account_journal ' \
cr.execute('SELECT id FROM account_journal '
'WHERE id IN %s ORDER BY type DESC',
(tuple(wiz_journal_ids),))
wiz_journal_ids = map(lambda x: x[0], cr.fetchall())
wiz_journal_ids = [x[0] for x in cr.fetchall()]
datas = {
'model': 'account.journal',
@ -122,7 +123,7 @@ class account_print_journal_xls(orm.TransientModel):
if wiz_form.target_move == 'posted':
move_states = ['posted']
else:
move_states = ['draft','posted']
move_states = ['draft', 'posted']
if print_by == 'fiscalyear':
journal_fy_ids = []

Loading…
Cancel
Save