From e588686d5f868228017f71bbf251d7611c7acd6f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 17 Feb 2014 14:46:01 +0100 Subject: [PATCH] Add module account_move_line_start_end_dates_xls. --- .../__init__.py | 23 +++++++ .../__openerp__.py | 43 +++++++++++++ .../account_move_line.py | 61 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 account_move_line_start_end_dates_xls/__init__.py create mode 100644 account_move_line_start_end_dates_xls/__openerp__.py create mode 100644 account_move_line_start_end_dates_xls/account_move_line.py diff --git a/account_move_line_start_end_dates_xls/__init__.py b/account_move_line_start_end_dates_xls/__init__.py new file mode 100644 index 0000000..a4a72bd --- /dev/null +++ b/account_move_line_start_end_dates_xls/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Account Move Line Start End Dates XLS module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com/) +# @author: Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import account_move_line diff --git a/account_move_line_start_end_dates_xls/__openerp__.py b/account_move_line_start_end_dates_xls/__openerp__.py new file mode 100644 index 0000000..26857fa --- /dev/null +++ b/account_move_line_start_end_dates_xls/__openerp__.py @@ -0,0 +1,43 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Move Line Start End Dates XLS module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com/) +# @author: Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +{ + 'name': 'Account Move Line Start End Dates XLS', + 'version': '0.1', + 'category': 'Accounting & Finance', + 'license': 'AGPL-3', + 'summary': 'Adds start and end dates in the XLS export of the move lines', + 'description': """ +Account Move Line Start End Dates XLS +===================================== + +This module adds *Start Date* and *End Date* in the XLS export of the account move lines. + +Please contact Alexis de Lattre from Akretion for any help or question about this module. +""", + 'author': 'Akretion', + 'website': 'http://www.akretion.com/', + 'depends': ['account_cutoff_prepaid', 'account_move_line_report_xls'], + 'data': [], + 'active': False, +} diff --git a/account_move_line_start_end_dates_xls/account_move_line.py b/account_move_line_start_end_dates_xls/account_move_line.py new file mode 100644 index 0000000..53c38fa --- /dev/null +++ b/account_move_line_start_end_dates_xls/account_move_line.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Account Move Line Start End Dates XLS module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com/) +# @author: Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import xlwt +from openerp.osv import orm +from openerp.addons.report_xls.utils import _render +from openerp.addons.report_xls.report_xls import report_xls + + +class account_move_line(orm.Model): + _inherit = 'account.move.line' + + def _report_xls_template(self, cr, uid, context=None): + res = super(account_move_line, self)._report_xls_template( + cr, uid, context=context) + bc = '22' + aml_cell_style_date = xlwt.easyxf( + 'borders: left thin, right thin, top thin, bottom thin, ' + 'left_colour %s, right_colour %s, top_colour %s, ' + 'bottom_colour %s; align: horz left;' + % (bc, bc, bc, bc), num_format_str=report_xls.date_format) + res.update({ + 'start_date': { + 'header': [1, 13, 'text', _render("_('Start Date')")], + 'lines': [1, 0, _render( + "line.start_date and line.start_date != 'False' and " + "'date' or 'text'"), _render( + "line.start_date and line.start_date != 'False' and " + "datetime.strptime(line.start_date, '%Y-%m-%d') or None"), + None, aml_cell_style_date], + 'totals': [1, 0, 'text', None]}, + 'end_date': { + 'header': [1, 13, 'text', _render("_('End Date')")], + 'lines': [1, 0, _render( + "line.end_date and line.end_date != 'False' and " + "'date' or 'text'"), _render( + "line.end_date and line.end_date != 'False' and " + "datetime.strptime(line.end_date, '%Y-%m-%d') or None"), + None, aml_cell_style_date], + 'totals': [1, 0, 'text', None]}, + }) + return res