clearcorp team mailing list archive
-
clearcorp team
-
Mailing list archive
-
Message #00243
lp:~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_accounting_report_library into lp:openerp-costa-rica
Armando Soto Rodríguez has proposed merging lp:~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_accounting_report_library into lp:openerp-costa-rica.
Requested reviews:
CLEARCORP drivers (clearcorp-drivers)
For more details, see:
https://code.launchpad.net/~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_accounting_report_library/+merge/116030
[FIX] Branch diverged fixed
--
https://code.launchpad.net/~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_accounting_report_library/+merge/116030
Your team CLEARCORP development team is subscribed to branch lp:openerp-costa-rica.
=== added directory 'l10n_cr_accounting_report_library'
=== added file 'l10n_cr_accounting_report_library/__init__.py'
--- l10n_cr_accounting_report_library/__init__.py 1970-01-01 00:00:00 +0000
+++ l10n_cr_accounting_report_library/__init__.py 2012-07-20 16:45:40 +0000
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by CLEARCORP S.A.
+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import account
+import l10n_cr_accounting_report_library
=== added file 'l10n_cr_accounting_report_library/__openerp__.py'
--- l10n_cr_accounting_report_library/__openerp__.py 1970-01-01 00:00:00 +0000
+++ l10n_cr_accounting_report_library/__openerp__.py 2012-07-20 16:45:40 +0000
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by CLEARCORP S.A.
+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+{
+ 'name': 'Accounting Reports Library',
+ 'description': "",
+ 'version': '1.0',
+ 'author': 'CLEARCORP S.A.',
+ 'category': 'Hidden',
+ 'website': "http://clearcorp.co.cr",
+ 'images': [],
+ 'depends': ['account' ],
+ 'init_xml': [],
+ 'demo_xml' : [],
+ 'update_xml': [
+ ],
+ 'test': [],
+ 'active': False,
+ 'installable': True,
+ 'license': 'AGPL-3',
+}
=== added file 'l10n_cr_accounting_report_library/l10n_cr_accounting_report_library.py'
--- l10n_cr_accounting_report_library/l10n_cr_accounting_report_library.py 1970-01-01 00:00:00 +0000
+++ l10n_cr_accounting_report_library/l10n_cr_accounting_report_library.py 2012-07-20 16:45:40 +0000
@@ -0,0 +1,140 @@
+#-*- coding:utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# d$
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import netsvc
+from osv import fields, orm
+import tools
+from tools.translate import _
+
+class AccountingReportLibrary(orm.Model):
+ _name = "accounting.report.library"
+ _description = "Library for Accounting Reports"
+
+ def get_move_lines(self, cr, uid, account_ids, filter_type='', filter_data=None, fiscalyear=None, target_move='all', unreconcile = False, context=None):
+ account_obj = self.pool.get('account.account')
+ move_line_obj = self.pool.get('account.move.line')
+ move_lines_ids = []
+
+ if unreconcile == False:
+ if target_move == 'all':
+ if filter_type == '' and filter_data == None and fiscalyear == None:
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids)], context=context)
+ elif filter_type == 'filter_date':
+ date_stop = filter_data[1]
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('date', '<=', date_stop)], context=context)
+ elif filter_type == 'filter_period':
+ periods_ids = self.pool.get('account.period').search(cr, uid, [('date_stop', '<=', filter_data[1].date_stop)])
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('period_id.id', 'in', periods_ids)], context=context)
+ elif filter_type == '' and fiscalyear != None:
+ date_stop = fiscalyear.date_stop
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('date', '<=', date_stop)], context=context)
+ elif target_move == 'posted':
+ if filter_type == '' and filter_data == None and fiscalyear == None:
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('move_id.state', '=', 'posted')], context=context)
+ elif filter_type == 'filter_date':
+ date_stop = filter_data[1]
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('date', '<=', date_stop), ('move_id.state', '=', 'posted')], context=context)
+ elif filter_type == 'filter_period':
+ periods_ids = self.pool.get('account.period').search(cr, uid, [('date_stop', '<=', filter_data[1].date_stop)])
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('period_id.id', 'in', periods_ids), ('move_id.state', '=', 'posted')], context=context)
+ elif filter_type == '' and fiscalyear != None:
+ date_stop = fiscalyear.date_stop
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('date', '<=', date_stop), ('move_id.state', '=', 'posted')], context=context)
+ else:
+ if target_move == 'all':
+ if filter_type == '' and filter_data == None and fiscalyear == None:
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('reconcile_id', '=', False)], context=context)
+ elif filter_type == 'filter_date':
+ date_stop = filter_data[1]
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('date', '<=', date_stop), ('reconcile_id', '=', False)], context=context)
+ move_line_ids = move_line_ids + self.get_move_lines_unconciled(cr, uid, account_ids, filter_type=filter_type, filter_data=filter_data, context=context)
+ elif filter_type == 'filter_period':
+ periods_ids = self.pool.get('account.period').search(cr, uid, [('date_stop', '<=', filter_data[1].date_stop)])
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('period_id.id', 'in', periods_ids), ('reconcile_id', '=', False)], context=context)
+ move_line_ids = move_line_ids + self.get_move_lines_unconciled(cr, uid, account_ids, filter_type=filter_type, filter_data=filter_data, context=context)
+ elif filter_type == '' and fiscalyear != None:
+ date_stop = fiscalyear.date_stop
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('date', '<=', date_stop), ('reconcile_id', '=', False)], context=context)
+ move_line_ids = move_line_ids + self.get_move_lines_unconciled(cr, uid, account_ids, fiscalyear=fiscalyear, context=context)
+ elif target_move == 'posted':
+ if filter_type == '' and filter_data == None and fiscalyear == None:
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('move_id.state', '=', 'posted'), ('reconcile_id', '=', False)], context=context)
+ elif filter_type == 'filter_date':
+ date_stop = filter_data[1]
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('date', '<=', date_stop), ('move_id.state', '=', 'posted'), ('reconcile_id', '=', False)], context=context)
+ move_line_ids = move_line_ids + self.get_move_lines_unconciled(cr, uid, account_ids, filter_type=filter_type, filter_data=filter_data, context=context)
+ elif filter_type == 'filter_period':
+ periods_ids = self.pool.get('account.period').search(cr, uid, [('date_stop', '<=', filter_data[1].date_stop)])
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('period_id.id', 'in', periods_ids), ('move_id.state', '=', 'posted'), ('reconcile_id', '=', False)], context=context)
+ move_line_ids = move_line_ids + self.get_move_lines_unconciled(cr, uid, account_ids, filter_type=filter_type, filter_data=filter_data, context=context)
+ elif filter_type == '' and fiscalyear != None:
+ date_stop = fiscalyear.date_stop
+ move_line_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('date', '<=', date_stop), ('move_id.state', '=', 'posted'), ('reconcile_id', '=', False)], context=context)
+ move_line_ids = move_line_ids + self.get_move_lines_unconciled(cr, uid, account_ids, fiscalyear=fiscalyear, context=context)
+
+ move_lines = move_line_ids and move_line_obj.browse(cr, uid, move_line_ids) or []
+
+ return move_lines
+
+ def get_move_lines_unconciled(self, cr, uid, account_ids, filter_type='', filter_data=None, fiscalyear=None, context=None):
+ account_obj = self.pool.get('account.account')
+ move_line_obj = self.pool.get('account.move.line')
+ move_reconcile_obj = self.pool.get('account.move.reconcile')
+ move_lines_conciled_ids = []
+ move_lines_ids = []
+
+ if filter_type == 'filter_date':
+ date_stop = filter_data[1]
+ move_lines_conciled_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('date', '<=', date_stop), ('reconcile_id', '!=', False)], context=context)
+ elif filter_type == 'filter_period':
+ periods_ids = self.pool.get('account.period').search(cr, uid, [('date_stop', '<=', filter_data[1].date_stop)])
+ move_lines_conciled_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('period_id.id', 'in', periods_ids), ('reconcile_id', '!=', False)], context=context)
+ elif filter_type == '' and fiscalyear != None:
+ date_stop = fiscalyear.date_stop
+ move_lines_conciled_ids = move_line_obj.search(cr, uid, [('account_id', 'in', account_ids), ('date', '<=', date_stop), ('reconcile_id', '!=', False)], context=context)
+
+ move_lines_conciled = move_lines_conciled_ids and move_line_obj.browse(cr, uid, move_lines_conciled_ids) or []
+
+ for move_line_conciled in move_lines_conciled:
+ move_reconcile = move_line_conciled.reconcile_id
+ for line in move_reconcile.line_id:
+ if filter_type == 'filter_period':
+ if line.period_id.id not in periods_ids:
+ move_lines_ids.append(move_line_conciled.id)
+ break
+ else:
+ if line.date >= date_stop:
+ move_lines_ids.append(move_line_conciled.id)
+ break
+
+ return move_lines_ids
+
+ def get_balance(self, cr, uid, account_ids, field_names, arg=None, context=None,
+ query='', query_params=()):
+ account_obj = self.pool.get('account.account')
+
+ res = account_obj._account_account__compute(cr, uid, account_ids, field_names, arg=arg, context=context,
+ query=query, query_params=query_params)
+
+ return res
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Follow ups