Browse Source

translations, extra fields, better inheritance support

pull/7/merge
Luc De Meyer 11 years ago
parent
commit
d504361b0d
  1. 12
      account_move_line_report_xls/__openerp__.py
  2. 21
      account_move_line_report_xls/account_move_line.py
  3. 111
      account_move_line_report_xls/i18n/fr.po
  4. 111
      account_move_line_report_xls/i18n/nl.po
  5. 89
      account_move_line_report_xls/report/move_line_list_xls.py
  6. BIN
      account_move_line_report_xls/static/src/img/icon.png

12
account_move_line_report_xls/__openerp__.py

@ -22,12 +22,20 @@
{
'name': 'Account Move Line XLS export',
'version': '0.2',
'version': '0.5',
'license': 'AGPL-3',
'author': 'Noviat',
'category' : 'Accounting & Finance',
'description': """
This module adds a button on the journal items ('account.move.line') list view in order to export the selected lines.
Journal Items Excel Export
==========================
This module adds a button on the journal items ('account.move.line') list view in order to export the selected lines.
If you are installing this module manually, you need also the module 'report_xls', that is located in:
https://launchpad.net/openerp-reporting-engines"
""",
'depends': ['account', 'report_xls'],
'demo_xml': [],

21
account_move_line_report_xls/account_move_line.py

@ -20,7 +20,9 @@
#
##############################################################################
from openerp.osv import fields, orm
from openerp.osv import orm
from openerp.addons.report_xls.utils import rowcol_to_cell, _render
from openerp.tools.translate import _
class account_move_line(orm.Model):
_inherit = 'account.move.line'
@ -30,4 +32,21 @@ class account_move_line(orm.Model):
return [
'move', 'name', 'date', 'period', 'partner', 'account',
'date_maturity', 'debit', 'credit', 'balance', 'reconcile', 'reconcile_partial',
#'amount_currency', 'currency_name',
]
# Change/Add Template entries
def _report_xls_template(self, cr, uid, context=None):
"""
Template updates, e.g.
my_change = {
'move':{
'header': [1, 20, 'text', _('My Move Title')],
'lines': [1, 0, 'text', _render("line.move_id.name or ''")],
'totals': [1, 0, 'text', None]},
}
return my_change
"""
return {}

111
account_move_line_report_xls/i18n/fr.po

@ -0,0 +1,111 @@
# French translation of OpenERP Server 6.1.
# This file contains the translation of the following modules:
# * account_move_line_report_xls
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Report-Msgid-Bugs-To: support@noviat.be\n"
"POT-Creation-Date: 2013-11-23 16:11:12.706000\n"
"PO-Revision-Date: 2013-11-23 16:11:12.706000\n"
"Last-Translator: Luc De Meyer (Noviat nv/sa)\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Journal Items"
msgstr "Écritures comptables"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Entry"
msgstr "Écriture"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Name"
msgstr "Nom"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Reference"
msgstr "Référence"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Effective Date"
msgstr "Date"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Period"
msgstr "Période"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Partner"
msgstr "Partenaire"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Partner Reference"
msgstr "Réf. Partenaire"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Account"
msgstr "Compte"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Maturity Date"
msgstr "Date d'échéance"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Debit"
msgstr "Débit"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Credit"
msgstr "Crédit"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Balance"
msgstr "Solde"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Rec."
msgstr "Let."
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Part. Rec."
msgstr "Let. Part."
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Tax Code"
msgstr "Case TVA"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Tax/Base Amount"
msgstr "Montant TVA/Base"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Am. Currency"
msgstr "Montant devise"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Curr."
msgstr "Dev."

111
account_move_line_report_xls/i18n/nl.po

@ -0,0 +1,111 @@
# Dutch translation of OpenERP Server 6.1.
# This file contains the translation of the following modules:
# * account_move_line_report_xls
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Report-Msgid-Bugs-To: support@noviat.be\n"
"POT-Creation-Date: 2013-11-23 16:11:12.702000\n"
"PO-Revision-Date: 2013-11-23 16:11:12.702000\n"
"Last-Translator: Luc De Meyer (Noviat nv/sa)\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Journal Items"
msgstr "Boekingsregels"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Entry"
msgstr "Boeking"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Name"
msgstr "Naam"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Reference"
msgstr "Referentie"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Effective Date"
msgstr "Datum"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Period"
msgstr "Periode"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Partner"
msgstr "Partner"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Partner Reference"
msgstr "Ref. Partner"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Account"
msgstr "Rekening"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Maturity Date"
msgstr "Vervaldatum"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Debit"
msgstr "Debet"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Credit"
msgstr "Credit"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Balance"
msgstr "Saldo"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Rec."
msgstr "Rec."
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Part. Rec."
msgstr "Rec. Part."
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Tax Code"
msgstr "BTW vak"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Tax/Base Amount"
msgstr "Bedrag BTW/Mvh"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Am. Currency"
msgstr "Bedrag valuta"
#. module: account_move_line_report_xls
#: report:move.line.list.xls:0
msgid "Curr."
msgstr "Val."

89
account_move_line_report_xls/report/move_line_list_xls.py

@ -23,26 +23,36 @@
import xlwt
import time
from datetime import datetime
from openerp.osv import orm
from openerp.report import report_sxw
from openerp.addons.report_xls.report_xls import report_xls
from openerp.addons.report_xls.utils import rowcol_to_cell, _render
from openerp.tools.translate import _
from openerp.tools.translate import translate, _
from openerp import pooler
import logging
_logger = logging.getLogger(__name__)
_ir_translation_name = 'move.line.list.xls'
class move_line_xls_parser(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(move_line_xls_parser, self).__init__(cr, uid, name, context=context)
move_obj = self.pool.get('account.move.line')
self.context = context
wanted_list = self.pool.get('account.move.line')._report_xls_fields(cr, uid, context)
wanted_list = move_obj._report_xls_fields(cr, uid, context)
template_changes = move_obj._report_xls_template(cr, uid, context)
self.localcontext.update({
'datetime': datetime,
'wanted_list': wanted_list,
'template_changes': template_changes,
'_': self._,
})
def _(self, src):
lang = self.context.get('lang', 'en_US')
return translate(self.cr, _ir_translation_name, 'report', lang, src) or src
class move_line_xls(report_xls):
def __init__(self, name, table, rml=False, parser=False, header=True, store=False):
@ -70,86 +80,109 @@ class move_line_xls(report_xls):
# XLS Template
self.col_specs_template = {
'move':{
'header': [1, 20, 'text', _('Move')],
'header': [1, 20, 'text', _render("_('Entry')")],
'lines': [1, 0, 'text', _render("line.move_id.name or ''")],
'totals': [1, 0, 'text', None]},
'name':{
'header': [1, 42, 'text', _('Name')],
'header': [1, 42, 'text', _render("_('Name')")],
'lines': [1, 0, 'text', _render("line.name or ''")],
'totals': [1, 0, 'text', None]},
'ref':{
'header': [1, 42, 'text', _('Reference')],
'header': [1, 42, 'text', _render("_('Reference')")],
'lines': [1, 0, 'text', _render("line.ref or ''")],
'totals': [1, 0, 'text', None]},
'date':{
'header': [1, 13, 'text', _('Effective Date')],
'header': [1, 13, 'text', _render("_('Effective Date')")],
'lines': [1, 0, 'date', _render("datetime.strptime(line.date,'%Y-%m-%d')"), None, self.aml_cell_style_date],
'totals': [1, 0, 'text', None]},
'period':{
'header': [1, 12, 'text', _('Period')],
'lines': [1, 0, 'text', _render("line.period_id.code or ''")],
'header': [1, 12, 'text', _render("_('Period')")],
'lines': [1, 0, 'text', _render("line.period_id.code or line.period_id.name")],
'totals': [1, 0, 'text', None]},
'partner':{
'header': [1, 36, 'text', _('Partner')],
'header': [1, 36, 'text', _render("_('Partner')")],
'lines': [1, 0, 'text', _render("line.partner_id and line.partner_id.name or ''")],
'totals': [1, 0, 'text', None]},
'partner_ref':{
'header': [1, 36, 'text', _('Partner Reference')],
'header': [1, 36, 'text', _render("_('Partner Reference')")],
'lines': [1, 0, 'text', _render("line.partner_id and line.partner_id.ref or ''")],
'totals': [1, 0, 'text', None]},
'account':{
'header': [1, 12, 'text', _('Account')],
'header': [1, 12, 'text', _render("_('Account')")],
'lines': [1, 0, 'text', _render("line.account_id.code")],
'totals': [1, 0, 'text', None]},
'date_maturity':{
'header': [1, 13, 'text', _('Maturity Date')],
'header': [1, 13, 'text', _render("_('Maturity Date')")],
'lines': [1, 0, _render("line.date_maturity.val and 'date' or 'text'"),
_render("line.date_maturity.val and datetime.strptime(line.date_maturity,'%Y-%m-%d') or None"),
None, self.aml_cell_style_date],
'totals': [1, 0, 'text', None]},
'debit':{
'header': [1, 18, 'text', _('Debit'), None, self.rh_cell_style_right],
'header': [1, 18, 'text', _render("_('Debit')"), None, self.rh_cell_style_right],
'lines': [1, 0, 'number', _render("line.debit"), None, self.aml_cell_style_decimal],
'totals': [1, 0, 'number', None, _render("debit_formula"), self.rt_cell_style_decimal]},
'credit':{
'header': [1, 18, 'text', _('Credit'), None, self.rh_cell_style_right],
'header': [1, 18, 'text', _render("_('Credit')"), None, self.rh_cell_style_right],
'lines': [1, 0, 'number', _render("line.credit"), None, self.aml_cell_style_decimal],
'totals': [1, 0, 'number', None, _render("credit_formula"), self.rt_cell_style_decimal]},
'balance':{
'header': [1, 18, 'text', _('Balance'), None, self.rh_cell_style_right],
'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':{
'header': [1, 12, 'text', _('Rec.'), None, self.rh_cell_style_center],
'header': [1, 12, 'text', _render("_('Rec.')"), None, self.rh_cell_style_center],
'lines': [1, 0, 'text', _render("line.reconcile_id.name or ''"), None, self.aml_cell_style_center],
'totals': [1, 0, 'text', None]},
'reconcile_partial':{
'header': [1, 12, 'text', _('Part. Rec.'), None, self.rh_cell_style_center],
'header': [1, 12, 'text', _render("_('Part. Rec.')"), None, self.rh_cell_style_center],
'lines': [1, 0, 'text', _render("line.reconcile_partial_id.name or ''"), None, self.aml_cell_style_center],
'totals': [1, 0, 'text', None]},
'tax_code':{
'header': [1, 12, 'text', _('Tax Code'), None, self.rh_cell_style_center],
'header': [1, 12, 'text', _render("_('Tax Code')"), None, self.rh_cell_style_center],
'lines': [1, 0, 'text', _render("line.tax_code_id.code or ''"), None, self.aml_cell_style_center],
'totals': [1, 0, 'text', None]},
'tax_amount':{
'header': [1, 18, 'text', _('Tax/Base Amount'), None, self.rh_cell_style_right],
'header': [1, 18, 'text', _render("_('Tax/Base Amount')"), None, self.rh_cell_style_right],
'lines': [1, 0, 'number', _render("line.tax_amount"), None, self.aml_cell_style_decimal],
'totals': [1, 0, 'text', None]},
'amount_currency':{
'header': [1, 18, 'text', _render("_('Am. Currency')"), None, self.rh_cell_style_right],
'lines': [1, 0, _render("line.amount_currency and 'number' or 'text'"),
_render("line.amount_currency or None"),
None, self.aml_cell_style_decimal],
'totals': [1, 0, 'text', None]},
'currency_name':{
'header': [1, 6, 'text', _render("_('Curr.')"), None, self.rh_cell_style_center],
'lines': [1, 0, 'text', _render("line.currency_id and line.currency_id.name or ''"), None, self.aml_cell_style_center],
'totals': [1, 0, 'text', None]},
'journal': {
'header': [1, 6, 'text', _('Journal')],
'lines': [1, 0, 'text', _render("line.journal_id.code or ''")],
'totals': [1, 0, 'text', None]},
'company_currency': {
'header': [1, 6, 'text', _('Company currency')],
'lines': [1, 0, 'text', _render("line.company_id.currency_id.name or ''")],
'totals': [1, 0, 'text', None]},
'analytic_account': {
'header': [1, 6, 'text', _('Analytic Account')],
'lines': [1, 0, 'text', _render("line.analytic_account_id.code or ''")],
'totals': [1, 0, 'text', None]},
}
def generate_xls_report(self, _p, _xs, data, objects, wb):
wanted_list = _p.wanted_list
self.col_specs_template.update(_p.template_changes)
_ = _p._
if 'balance' in wanted_list:
try:
debit_pos = wanted_list.index('debit')
credit_pos = wanted_list.index('credit')
except:
raise osv.except_osv(_('Customisation Error!'),
_("The 'Balance' field is a calculated XLS field requiring the presence of the 'Debit' and 'Credit' fields !"))
debit_pos = 'debit' in wanted_list and wanted_list.index('debit')
credit_pos = 'credit' in wanted_list and wanted_list.index('credit')
if not (credit_pos and debit_pos) and 'balance' in wanted_list:
raise orm.except_orm(_('Customisation Error!'),
_("The 'Balance' field is a calculated XLS field requiring the presence of the 'Debit' and 'Credit' fields !"))
report_name = objects[0]._description or objects[0]._name
#report_name = objects[0]._description or objects[0]._name
report_name = _("Journal Items")
ws = wb.add_sheet(report_name[:31])
ws.panes_frozen = True
ws.remove_splits = True
@ -171,7 +204,7 @@ class move_line_xls(report_xls):
row_pos += 1
# Column headers
c_specs = map(lambda x: self.render(x, self.col_specs_template, 'header', render_space={}), wanted_list)
c_specs = map(lambda x: self.render(x, self.col_specs_template, 'header', render_space={'_': _p._}), wanted_list)
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.rh_cell_style, set_column_size=True)
ws.set_horz_split_pos(row_pos)

BIN
account_move_line_report_xls/static/src/img/icon.png

After

Width: 88  |  Height: 85  |  Size: 11 KiB

Loading…
Cancel
Save