From 78205e0ee4f295b77598c3b72f3766e44cf1bed8 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Fri, 27 Jun 2014 16:12:59 +0200 Subject: [PATCH 01/23] [IMP] modify menu item for item search extension --- .../account_view.xml | 4 ++-- account_move_line_search_extension/i18n/fr.po | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 account_move_line_search_extension/i18n/fr.po diff --git a/account_move_line_search_extension/account_view.xml b/account_move_line_search_extension/account_view.xml index 4dcbe197a..de3c19586 100644 --- a/account_move_line_search_extension/account_view.xml +++ b/account_move_line_search_extension/account_view.xml @@ -12,11 +12,11 @@ - + diff --git a/account_move_line_search_extension/i18n/fr.po b/account_move_line_search_extension/i18n/fr.po new file mode 100644 index 000000000..42e13374c --- /dev/null +++ b/account_move_line_search_extension/i18n/fr.po @@ -0,0 +1,22 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_move_line_search_extension +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-06-27 13:15+0000\n" +"PO-Revision-Date: 2014-06-27 13:15+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_move_line_search_extension +#: model:ir.actions.act_window,name:account_move_line_search_extension.action_account_move_line_search_extension +#: model:ir.ui.menu,name:account_move_line_search_extension.menu_account_move_line_search_extension +msgid "Journal Items Search All" +msgstr "Écritures comptables" From d61d5d72bac6cd5997de98c12d69a3bb7d8c5be9 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 27 Jun 2014 14:56:25 +0200 Subject: [PATCH 02/23] [ADD] module account_balance_line --- account_balance_line/__init__.py | 21 ++++++++ account_balance_line/__openerp__.py | 52 ++++++++++++++++++ account_balance_line/account_move_line.py | 42 +++++++++++++++ .../account_move_line_view.xml | 30 +++++++++++ .../i18n/account_balance_line.pot | 53 +++++++++++++++++++ account_balance_line/i18n/fr.po | 53 +++++++++++++++++++ 6 files changed, 251 insertions(+) create mode 100644 account_balance_line/__init__.py create mode 100644 account_balance_line/__openerp__.py create mode 100644 account_balance_line/account_move_line.py create mode 100644 account_balance_line/account_move_line_view.xml create mode 100644 account_balance_line/i18n/account_balance_line.pot create mode 100644 account_balance_line/i18n/fr.po diff --git a/account_balance_line/__init__.py b/account_balance_line/__init__.py new file mode 100644 index 000000000..e05fd7715 --- /dev/null +++ b/account_balance_line/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Vincent Renaville (Camptocamp) +# Copyright 2010-2014 Camptocamp SA +# +# 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 # noqa diff --git a/account_balance_line/__openerp__.py b/account_balance_line/__openerp__.py new file mode 100644 index 000000000..cab71b749 --- /dev/null +++ b/account_balance_line/__openerp__.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Vincent Renaville (Camptocamp) +# Copyright 2010-2014 Camptocamp SA +# +# 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' : 'Balance on lines', + 'summary': 'Display balance totals in move line view', + 'version' : '1.1', + 'author' : 'Camptocamp', + 'maintainter' : 'Camptocamp', + 'category': 'Accounting', + 'depends' : ['account'], + 'description': """ +Balance for a line +================== + +Add a balance total for grouped lines in move line view. + +Balance field will only be shown when move lines are grouped by account +or filtered by account. + +Contributors +------------ + +* Vincent revaville +* Yannick Vaucher +""", + 'website': 'http://www.camptocamp.com', + 'data': [ + 'account_move_line_view.xml', + ], + 'tests': [], + 'installable': True, + 'auto_install': False, + 'license': 'AGPL-3', + 'application': False, +} diff --git a/account_balance_line/account_move_line.py b/account_balance_line/account_move_line.py new file mode 100644 index 000000000..53c83271b --- /dev/null +++ b/account_balance_line/account_move_line.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Vincent Renaville (Camptocamp) +# Copyright 2010-2014 Camptocamp SA +# +# 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 openerp.osv import osv, fields + + +class account_move_line(osv.Model): + _inherit = "account.move.line" + + def _line_balance(self, cr, uid, ids, field, arg, context=None): + res = {} + move_lines = self.read(cr, uid, ids, + ['debit', 'credit'], + context=context) + + for line in move_lines: + res[line['id']] = line['debit'] - line['credit'] + return res + + _columns = { + 'line_balance': fields.function( + _line_balance, method=True, + string='Balance', + store=True), + } diff --git a/account_balance_line/account_move_line_view.xml b/account_balance_line/account_move_line_view.xml new file mode 100644 index 000000000..22be69ccb --- /dev/null +++ b/account_balance_line/account_move_line_view.xml @@ -0,0 +1,30 @@ + + + + + + Journal Items add visibilty for balance + account.move.line + + + + {'invisible_balance': False} + + + {'group_by': 'account_id', 'invisible_balance': False} + + + + + + account_move_line_balance_custom + account.move.line + + + + + + + + + diff --git a/account_balance_line/i18n/account_balance_line.pot b/account_balance_line/i18n/account_balance_line.pot new file mode 100644 index 000000000..4330edce5 --- /dev/null +++ b/account_balance_line/i18n/account_balance_line.pot @@ -0,0 +1,53 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_balance_line +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-06-20 14:11+0000\n" +"PO-Revision-Date: 2014-06-20 14:11+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_balance_line +#: view:account.move.line:0 +msgid "Account" +msgstr "" + +#. module: account_balance_line +#: model:ir.model,name:account_balance_line.model_account_move_line +msgid "Entry lines" +msgstr "" + +#. module: account_balance_line +#: code:_description:0 +#, python-format +msgid "Journal Items" +msgstr "" + +#. module: account_balance_line +#: field:account.move.line,line_balance:0 +msgid "Balance" +msgstr "" + +#. module: account_balance_line +#: view:account.move.line:0 +msgid "Total Balance" +msgstr "" + +#. module: account_balance_line +#: view:account.move.line:0 +msgid "{'group_by': 'account_id', 'invisible_balance': False}" +msgstr "" + +#. module: account_balance_line +#: view:account.move.line:0 +msgid "{'invisible_balance': False}" +msgstr "" + diff --git a/account_balance_line/i18n/fr.po b/account_balance_line/i18n/fr.po new file mode 100644 index 000000000..31f766975 --- /dev/null +++ b/account_balance_line/i18n/fr.po @@ -0,0 +1,53 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_balance_line +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-06-20 14:11+0000\n" +"PO-Revision-Date: 2014-06-20 14:11+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_balance_line +#: view:account.move.line:0 +msgid "Account" +msgstr "Compte" + +#. module: account_balance_line +#: model:ir.model,name:account_balance_line.model_account_move_line +msgid "Entry lines" +msgstr "Lignes d'écriture" + +#. module: account_balance_line +#: code:_description:0 +#, python-format +msgid "Journal Items" +msgstr "Écritures comptables" + +#. module: account_balance_line +#: field:account.move.line,line_balance:0 +msgid "Balance" +msgstr "Balance" + +#. module: account_balance_line +#: view:account.move.line:0 +msgid "Total Balance" +msgstr "Balance Totale" + +#. module: account_balance_line +#: view:account.move.line:0 +msgid "{'group_by': 'account_id', 'invisible_balance': False}" +msgstr "" + +#. module: account_balance_line +#: view:account.move.line:0 +msgid "{'invisible_balance': False}" +msgstr "" + From 1e7dbe9dbbc56deea0defd3452011b1731064ec6 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 15 Jul 2014 14:44:39 -0400 Subject: [PATCH 03/23] currency_rate_update: fix wrong use of timetuple. - remove error "TypeError: argument must be 9-item sequence, not datetime.datetime" --- currency_rate_update/currency_rate_update.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/currency_rate_update/currency_rate_update.py b/currency_rate_update/currency_rate_update.py index 4f9bc8808..1b22de90c 100644 --- a/currency_rate_update/currency_rate_update.py +++ b/currency_rate_update/currency_rate_update.py @@ -119,13 +119,14 @@ class Currency_rate_update(osv.Model): _name = "currency.rate.update" _description = "Currency Rate Update" # Dict that represent a cron object + nextcall_time = (datetime.today() + timedelta(days=1)).timetuple() + nextcall = time.strftime("%Y-%m-%d %H:%M:%S", nextcall_time) cron = { 'active': False, 'priority': 1, 'interval_number': 1, 'interval_type': 'weeks', - 'nextcall': time.strftime("%Y-%m-%d %H:%M:%S", - datetime.today() + timedelta(days=1)).timetuple(), + 'nextcall': nextcall, 'numbercall': -1, 'doall': True, 'model': 'currency.rate.update', From 801d6274b32b8832f81972b19ec68a84f314570a Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 15 Jul 2014 15:48:37 -0400 Subject: [PATCH 04/23] currency_rate_update: use date format of openerp.tools. - DEFAULT_SERVER_DATETIME_FORMAT and DEFAULT_SERVER_DATE_FORMAT --- currency_rate_update/currency_rate_update.py | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/currency_rate_update/currency_rate_update.py b/currency_rate_update/currency_rate_update.py index 1b22de90c..0b99ed7b9 100644 --- a/currency_rate_update/currency_rate_update.py +++ b/currency_rate_update/currency_rate_update.py @@ -36,7 +36,9 @@ import logging import time -from datetime import datetime, timedelta +from datetime import datetime +from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT +from openerp.tools import DEFAULT_SERVER_DATE_FORMAT from openerp.osv import fields, osv, orm from openerp.tools.translate import _ @@ -119,8 +121,8 @@ class Currency_rate_update(osv.Model): _name = "currency.rate.update" _description = "Currency Rate Update" # Dict that represent a cron object - nextcall_time = (datetime.today() + timedelta(days=1)).timetuple() - nextcall = time.strftime("%Y-%m-%d %H:%M:%S", nextcall_time) + nextcall_time = datetime.today() + timedelta(days=1) + nextcall = nextcall_time.strftime(DEFAULT_SERVER_DATETIME_FORMAT) cron = { 'active': False, 'priority': 1, @@ -220,7 +222,7 @@ class Currency_rate_update(osv.Model): main_curr, service.max_delta_days ) - rate_name = time.strftime('%Y-%m-%d') + rate_name = time.strftime(DEFAULT_SERVER_DATE_FORMAT) for curr in service.currency_to_update: if curr.name == main_curr: continue @@ -245,12 +247,12 @@ class Currency_rate_update(osv.Model): # Show the most recent note at the top msg = "%s \n%s currency updated. %s" % \ (log_info or '', - datetime.strftime(datetime.today(), '%Y-%m-%d %H:%M:%S'), + datetime.strftime(datetime.today(), DEFAULT_SERVER_DATETIME_FORMAT), note) service.write({'note': msg}) except Exception as exc: error_msg = "\n%s ERROR : %s %s" %\ - (datetime.strftime(datetime.today(), '%Y-%m-%d %H:%M:%S'), + (datetime.strftime(datetime.today(), DEFAULT_SERVER_DATETIME_FORMAT), repr(exc), note) _logger.info(repr(exc)) @@ -398,8 +400,8 @@ class Curreny_getter_interface(object): ) # We always have a warning when rate_date != today - rate_date_str = datetime.strftime(rate_date, '%Y-%m-%d') - if rate_date_str != datetime.strftime(datetime.today(), '%Y-%m-%d'): + rate_date_str = datetime.strftime(rate_date, DEFAULT_SERVER_DATE_FORMAT) + if rate_date_str != datetime.strftime(datetime.today(), DEFAULT_SERVER_DATE_FORMAT): msg = "The rate timestamp (%s) is not today's date" self.log_info = ("WARNING : %s %s") % (msg, rate_date_str) _logger.warning(msg, rate_date_str) @@ -459,7 +461,7 @@ class Admin_ch_getter(Curreny_getter_interface): _logger.debug("Admin.ch sent a valid XML file") adminch_ns = {'def': 'http://www.afd.admin.ch/publicdb/newdb/mwst_kurse'} rate_date = dom.xpath('/def:wechselkurse/def:datum/text()', namespaces=adminch_ns)[0] - rate_date_datetime = datetime.strptime(rate_date, '%Y-%m-%d') + rate_date_datetime = datetime.strptime(rate_date, DEFAULT_SERVER_DATE_FORMAT) self.check_rate_date(rate_date_datetime, max_delta_days) # we dynamically update supported currencies self.supported_currency_array = dom.xpath("/def:wechselkurse/def:devise/@code", namespaces=adminch_ns) @@ -529,7 +531,7 @@ class ECB_getter(Curreny_getter_interface): } rate_date = dom.xpath('/gesmes:Envelope/def:Cube/def:Cube/@time', namespaces=ecb_ns)[0] - rate_date_datetime = datetime.strptime(rate_date, '%Y-%m-%d') + rate_date_datetime = datetime.strptime(rate_date, DEFAULT_SERVER_DATE_FORMAT) self.check_rate_date(rate_date_datetime, max_delta_days) # We dynamically update supported currencies self.supported_currency_array = dom.xpath("/gesmes:Envelope/def:Cube/def:Cube/def:Cube/@currency", @@ -586,7 +588,7 @@ class PL_NBP_getter(Curreny_getter_interface): ns = {} # Cool, there are no namespaces ! _logger.debug("NBP.pl sent a valid XML file") rate_date = dom.xpath('/tabela_kursow/data_publikacji/text()', namespaces=ns)[0] - rate_date_datetime = datetime.strptime(rate_date, '%Y-%m-%d') + rate_date_datetime = datetime.strptime(rate_date, DEFAULT_SERVER_DATE_FORMAT) self.check_rate_date(rate_date_datetime, max_delta_days) # We dynamically update supported currencies self.supported_currency_array = dom.xpath('/tabela_kursow/pozycja/kod_waluty/text()', namespaces=ns) From 5300e2fa2c7003ec793a82f3bd2aca65b1bbb804 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 15 Jul 2014 16:06:38 -0400 Subject: [PATCH 05/23] currency_rate_update: fix, forget to add import timedelta --- currency_rate_update/currency_rate_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/currency_rate_update/currency_rate_update.py b/currency_rate_update/currency_rate_update.py index 0b99ed7b9..c670abbd5 100644 --- a/currency_rate_update/currency_rate_update.py +++ b/currency_rate_update/currency_rate_update.py @@ -36,7 +36,7 @@ import logging import time -from datetime import datetime +from datetime import datetime, timedelta from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT from openerp.tools import DEFAULT_SERVER_DATE_FORMAT from openerp.osv import fields, osv, orm From f57d917e5a24f67f25e600c7bb22e2ba82cca20d Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 18 Jul 2014 18:31:33 -0400 Subject: [PATCH 06/23] currency_rate_update : mini date fix in currency_rate_update.py --- currency_rate_update/currency_rate_update.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/currency_rate_update/currency_rate_update.py b/currency_rate_update/currency_rate_update.py index c670abbd5..94492137c 100644 --- a/currency_rate_update/currency_rate_update.py +++ b/currency_rate_update/currency_rate_update.py @@ -247,12 +247,12 @@ class Currency_rate_update(osv.Model): # Show the most recent note at the top msg = "%s \n%s currency updated. %s" % \ (log_info or '', - datetime.strftime(datetime.today(), DEFAULT_SERVER_DATETIME_FORMAT), + datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT), note) service.write({'note': msg}) except Exception as exc: error_msg = "\n%s ERROR : %s %s" %\ - (datetime.strftime(datetime.today(), DEFAULT_SERVER_DATETIME_FORMAT), + (datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT), repr(exc), note) _logger.info(repr(exc)) @@ -401,7 +401,7 @@ class Curreny_getter_interface(object): # We always have a warning when rate_date != today rate_date_str = datetime.strftime(rate_date, DEFAULT_SERVER_DATE_FORMAT) - if rate_date_str != datetime.strftime(datetime.today(), DEFAULT_SERVER_DATE_FORMAT): + if rate_date.date() != datetime.today().date(): msg = "The rate timestamp (%s) is not today's date" self.log_info = ("WARNING : %s %s") % (msg, rate_date_str) _logger.warning(msg, rate_date_str) From f22f27f4f507e0fcee0b147d6769a1b378ef9666 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Thu, 31 Jul 2014 13:29:17 +0200 Subject: [PATCH 07/23] replace osv.Model by orm.Model --- account_balance_line/account_move_line.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account_balance_line/account_move_line.py b/account_balance_line/account_move_line.py index 53c83271b..e6c77260e 100644 --- a/account_balance_line/account_move_line.py +++ b/account_balance_line/account_move_line.py @@ -18,10 +18,10 @@ # along with this program. If not, see . # ############################################################################## -from openerp.osv import osv, fields +from openerp.osv import orm, fields -class account_move_line(osv.Model): +class account_move_line(orm.Model): _inherit = "account.move.line" def _line_balance(self, cr, uid, ids, field, arg, context=None): From 86886cad44ebc9eac5e6c96fd33439ede60519f2 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Thu, 31 Jul 2014 13:29:50 +0200 Subject: [PATCH 08/23] remove noqa --- account_balance_line/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_balance_line/__init__.py b/account_balance_line/__init__.py index e05fd7715..373e5a269 100644 --- a/account_balance_line/__init__.py +++ b/account_balance_line/__init__.py @@ -18,4 +18,4 @@ # along with this program. If not, see . # ############################################################################## -from . import account_move_line # noqa +from . import account_move_line From cdbb3e9329c9fbc316b23c58cd92df4add83b900 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 12 Aug 2014 13:52:58 +0200 Subject: [PATCH 09/23] [IMP] use latest version of quality tools and experiment include feature --- .travis.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index e2d1c7b3c..4f3443d59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,29 @@ +# Config file .travis.yml + language: python + python: - "2.7" -virtualenv: - system_site_packages: true - -before_install: - - git clone https://github.com/nbessi/maintainer-quality-tools.git $HOME/maintainer-quality-tools -b consolidated - - git clone https://github.com/OCA/connector $HOME/connector -b 7.0 - env: - - PATH=$HOME/maintainer-quality-tools/travis:$PATH + - VERSION="7.0" ODOO_REPO="odoo/odoo" EXCLUDE="account_constraints" + - VERSION="7.0" ODOO_REPO="odoo/odoo" INCLUDE="account_constraints" + - VERSION="7.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_constraints" + - VERSION="7.0" ODOO_REPO="OCA/OCB" INCLUDE="account_constraints" services: - postgresql +virtualenv: + system_site_packages: true + install: - - $HOME/maintainer-quality-tools/travis/travis_install_nightly 7.0 - - pip install coveralls flake8 + - git clone https://github.com/dreispt/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools -b add-include-env + - git clone https://github.com/OCA/connector $HOME/connector -b ${VERSION} script: - - travis_run_flake8 steps - - travis_run_tests_encapsulated 7.0 account $HOME/connector + # - travis_run_flake8 + - travis_run_tests after_success: coveralls From 9a4fc93937a960a53238b8b599ea176986da47b3 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 12 Aug 2014 14:05:03 +0200 Subject: [PATCH 10/23] [FIX] remove postges service --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4f3443d59..5ef289317 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,6 @@ env: - VERSION="7.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_constraints" - VERSION="7.0" ODOO_REPO="OCA/OCB" INCLUDE="account_constraints" -services: - - postgresql - virtualenv: system_site_packages: true From dedeb9cf23c62a887a27671b82d256366e73e33d Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 12 Aug 2014 14:09:34 +0200 Subject: [PATCH 11/23] [FIX] source travis files --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5ef289317..b9a4937b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ virtualenv: install: - git clone https://github.com/dreispt/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools -b add-include-env - git clone https://github.com/OCA/connector $HOME/connector -b ${VERSION} + - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} script: # - travis_run_flake8 From 28470c82ec86ae1b993e3e1ff5c901a3bb8fbfa8 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 12 Aug 2014 14:14:42 +0200 Subject: [PATCH 12/23] [FIX] use install nightly --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b9a4937b7..3b7514d2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ install: - git clone https://github.com/dreispt/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools -b add-include-env - git clone https://github.com/OCA/connector $HOME/connector -b ${VERSION} - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} - + - travis_install_nightly ${VERSION} script: # - travis_run_flake8 - travis_run_tests From 3cd67a8e9aea2cdb3096e1192d3b766e8805bef2 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 12 Aug 2014 14:28:09 +0200 Subject: [PATCH 13/23] [FIX] account_partner_required must be separated --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b7514d2a..96c8a2a43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,13 @@ python: - "2.7" env: - - VERSION="7.0" ODOO_REPO="odoo/odoo" EXCLUDE="account_constraints" + - VERSION="7.0" ODOO_REPO="odoo/odoo" EXCLUDE="account_constraints,account_partner_required" - VERSION="7.0" ODOO_REPO="odoo/odoo" INCLUDE="account_constraints" - - VERSION="7.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_constraints" + - VERSION="7.0" ODOO_REPO="odoo/odoo" INCLUDE="account_partner_required" + - VERSION="7.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_constraints, account_partner_required" - VERSION="7.0" ODOO_REPO="OCA/OCB" INCLUDE="account_constraints" + - VERSION="7.0" ODOO_REPO="OCA/OCB" INCLUDE="account_partner_required" + virtualenv: system_site_packages: true From 67d22e58f0455ab7c57693f2c201dd92bcd7498f Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 12 Aug 2014 14:38:51 +0200 Subject: [PATCH 14/23] [FIX] async_move_line_importer should be launched separately --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 96c8a2a43..2d684a83b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,12 +6,15 @@ python: - "2.7" env: - - VERSION="7.0" ODOO_REPO="odoo/odoo" EXCLUDE="account_constraints,account_partner_required" + - VERSION="7.0" ODOO_REPO="odoo/odoo" EXCLUDE="account_constraints,account_partner_required,async_move_line_importer" - VERSION="7.0" ODOO_REPO="odoo/odoo" INCLUDE="account_constraints" - VERSION="7.0" ODOO_REPO="odoo/odoo" INCLUDE="account_partner_required" - - VERSION="7.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_constraints, account_partner_required" + - VERSION="7.0" ODOO_REPO="odoo/odoo" INCLUDE="async_move_line_importer" + + - VERSION="7.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_constraints, account_partner_required,async_move_line_importer" - VERSION="7.0" ODOO_REPO="OCA/OCB" INCLUDE="account_constraints" - VERSION="7.0" ODOO_REPO="OCA/OCB" INCLUDE="account_partner_required" + - VERSION="7.0" ODOO_REPO="odoo/odoo" INCLUDE="async_move_line_importer" virtualenv: From 072c87e36f7568da0c6db4305181deebc55f4376 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 12 Aug 2014 15:59:46 +0200 Subject: [PATCH 15/23] [FIX] spacing and carriage --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2d684a83b..2c051b876 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,15 +16,15 @@ env: - VERSION="7.0" ODOO_REPO="OCA/OCB" INCLUDE="account_partner_required" - VERSION="7.0" ODOO_REPO="odoo/odoo" INCLUDE="async_move_line_importer" - virtualenv: system_site_packages: true install: - - git clone https://github.com/dreispt/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools -b add-include-env - - git clone https://github.com/OCA/connector $HOME/connector -b ${VERSION} - - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} - - travis_install_nightly ${VERSION} + - git clone https://github.com/dreispt/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools -b add-include-env + - git clone https://github.com/OCA/connector $HOME/connector -b ${VERSION} + - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} + - travis_install_nightly ${VERSION} + script: # - travis_run_flake8 - travis_run_tests From 3fa781a25a16e963a0f1d6e8a7bf2faaa9a2ae28 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Wed, 13 Aug 2014 12:04:29 +0200 Subject: [PATCH 16/23] [FIX] use official quality tools branch --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2c051b876..d5df1a17a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ virtualenv: system_site_packages: true install: - - git clone https://github.com/dreispt/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools -b add-include-env + - git clone https://github.com/oca/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools - git clone https://github.com/OCA/connector $HOME/connector -b ${VERSION} - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} - travis_install_nightly ${VERSION} From 581855f7c51586ba3ea4a5fc642023d92c6df2fe Mon Sep 17 00:00:00 2001 From: Adrien Peiffer Date: Wed, 6 Aug 2014 14:05:20 +0200 Subject: [PATCH 17/23] [ADD] Add account_journal_period_close_module --- account_journal_period_close/__init__.py | 31 +++ account_journal_period_close/__openerp__.py | 53 +++++ .../model/__init__.py | 29 +++ account_journal_period_close/model/account.py | 86 ++++++++ .../tests/__init__.py | 30 +++ .../test_account_journal_period_close.py | 196 ++++++++++++++++++ .../view/account_view.xml | 34 +++ 7 files changed, 459 insertions(+) create mode 100644 account_journal_period_close/__init__.py create mode 100644 account_journal_period_close/__openerp__.py create mode 100644 account_journal_period_close/model/__init__.py create mode 100644 account_journal_period_close/model/account.py create mode 100644 account_journal_period_close/tests/__init__.py create mode 100644 account_journal_period_close/tests/test_account_journal_period_close.py create mode 100644 account_journal_period_close/view/account_view.xml diff --git a/account_journal_period_close/__init__.py b/account_journal_period_close/__init__.py new file mode 100644 index 000000000..dcf937772 --- /dev/null +++ b/account_journal_period_close/__init__.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# +# +# Authors: Adrien Peiffer +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 model +from . import tests diff --git a/account_journal_period_close/__openerp__.py b/account_journal_period_close/__openerp__.py new file mode 100644 index 000000000..99c2f6894 --- /dev/null +++ b/account_journal_period_close/__openerp__.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# +# +# Authors: Adrien Peiffer +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 Journal Period Close", + "version": "1.0", + "author": "ACSONE SA/NV", + "maintainer": "ACSONE SA/NV", + "website": "http://www.acsone.eu", + "images": [], + "category": "Accounting", + "depends": [ + "account"], + "description": """ +Account Journal Period Close +============================== +this module allows to add some account move in a close period. +To do this, you have to specify account journals on which will allow writing of account move on the period form view +""", + "data": ['view/account_view.xml'], + "demo": [], + "test": [], + "licence": "AGPL-3", + "installable": True, + "auto_install": False, + "application": True, +} diff --git a/account_journal_period_close/model/__init__.py b/account_journal_period_close/model/__init__.py new file mode 100644 index 000000000..123722270 --- /dev/null +++ b/account_journal_period_close/model/__init__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# +# +# Authors: Adrien Peiffer +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 diff --git a/account_journal_period_close/model/account.py b/account_journal_period_close/model/account.py new file mode 100644 index 000000000..ecaa924d4 --- /dev/null +++ b/account_journal_period_close/model/account.py @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- +# +# +# Authors: Adrien Peiffer +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 openerp.osv import orm, fields +from openerp.tools.translate import _ + + +class account_period(orm.Model): + _inherit = 'account.period' + _columns = { + 'journal_period_ids': fields.one2many('account.journal.period', + 'period_id', 'Journal states'), + } + + +class account_journal_period(orm.Model): + _inherit = 'account.journal.period' + _order = "type,name" + _columns = { + 'type': fields.related('journal_id', 'type', type='char', + relation='account.journal', + string='Journal Type', + store=True, readonly=True) + } + + def _check(self, cr, uid, ids, context=None): + return True + + def action_draft(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'state': 'draft'}) + + def action_done(self, cr, uid, ids, context=None): + for journal_period in self.browse(cr, uid, ids, context=context): + draft_move_ids = self.pool.get('account.move')\ + .search(cr, uid, [('period_id', '=', + journal_period.period_id.id), + ('state', '=', "draft"), + ('journal_id', '=', + journal_period.journal_id.id)], + context=context) + if draft_move_ids: + raise orm.except_orm(_('Invalid Action!'), + _('In order to close a journal,' + ' you must first post related' + ' journal entries.')) + return self.write(cr, uid, ids, {'state': 'done'}) + + def create(self, cr, uid, values, context=None): + if 'name' not in values: + if values.get('period_id') and values.get('journal_id'): + journal = self.pool.get('account.journal')\ + .browse(cr, uid, values['journal_id'], context=context) + period = self.pool.get('account.period')\ + .browse(cr, uid, values['period_id'], context=context) + values.update({'name': (journal.code or journal.name)+':' + + (period.name or '')}), + return super(account_journal_period, self).create(cr, + uid, + values, + context=context) diff --git a/account_journal_period_close/tests/__init__.py b/account_journal_period_close/tests/__init__.py new file mode 100644 index 000000000..d503a5aa8 --- /dev/null +++ b/account_journal_period_close/tests/__init__.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# +# +# Authors: Adrien Peiffer +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 test_account_journal_period_close diff --git a/account_journal_period_close/tests/test_account_journal_period_close.py b/account_journal_period_close/tests/test_account_journal_period_close.py new file mode 100644 index 000000000..ed175a425 --- /dev/null +++ b/account_journal_period_close/tests/test_account_journal_period_close.py @@ -0,0 +1,196 @@ +# -*- coding: utf-8 -*- +# +# +# Authors: Adrien Peiffer +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs. +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contact a Free Software +# Service Company. +# +# 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 openerp.tests.common as common +from openerp.osv import orm +from datetime import datetime + +DB = common.DB +ADMIN_USER_ID = common.ADMIN_USER_ID + + +def get_simple_account_move_values(self, period_id, journal_id): + sale_product_account_id = self.ref('account.a_sale') + cash_account_id = self.ref('account.cash') + partner_id = self.ref('base.res_partner_2') + year = datetime.now().strftime('%Y') + return {'partner_id': partner_id, + 'period_id': period_id, + 'date': year + '-01-01', + 'journal_id': journal_id, + 'line_id': [(0, 0, {'name': 'test', + 'account_id': cash_account_id, + 'debit': 50.0, + }), + (0, 0, {'name': 'test_conterpart', + 'account_id': sale_product_account_id, + 'credit': 50.0, + }) + ] + } + + +def close_period(self, period_id, context=None): + close_period_wizard_id =\ + self.registry('account.period.close').create(self.cr, + self.uid, + {'sure': True + }, + context=context) + context.update({'active_ids': [period_id]}) + self.registry('account.period.close')\ + .data_save(self.cr, + self.uid, + [close_period_wizard_id], + context=context) + + +def create_journal_period(self, period_id, journal_id, context): + jour_per_obj = self.registry('account.journal.period') + journal_period_id = jour_per_obj.create(self.cr, + self.uid, + {'period_id': period_id, + 'journal_id': journal_id, + }, + context=context) + return journal_period_id + + +def journal_period_done(self, journal_period_id, context): + jour_per_obj = self.registry('account.journal.period') + jour_per_obj.action_done(self.cr, + self.uid, + [journal_period_id], + context=context) + + +def journal_period_draft(self, journal_period_id, context): + jour_per_obj = self.registry('account.journal.period') + jour_per_obj.action_draft(self.cr, + self.uid, + [journal_period_id], + context=context) + + +class TestAccountConstraintChronology(common.TransactionCase): + + def setUp(self): + super(TestAccountConstraintChronology, self).setUp() + + def test_close_period_open_journal(self): + context = {} + journal_id = self.ref('account.sales_journal') + period_id = self.ref('account.period_1') + close_period(self, period_id, context) + journal_period_id = create_journal_period(self, + period_id, + journal_id, + context) + journal_period_draft(self, journal_period_id, context) + self.registry('account.move')\ + .create(self.cr, + self.uid, + get_simple_account_move_values(self, + period_id, + journal_id), + context=context) + # Here, no exception should be raised because the journal's state is + # draft although the period is closed + + def test_open_period_close_journal(self): + context = {} + journal_id = self.ref('account.sales_journal') + period_id = self.ref('account.period_1') + journal_period_id = create_journal_period(self, + period_id, + journal_id, + context) + journal_period_done(self, journal_period_id, context) + move_values = get_simple_account_move_values(self, + period_id, + journal_id) + # I check if the exception is correctly raised at create of an account + # move which is linked with a closed journal + self.assertRaises(orm.except_orm, + self.registry('account.move').create, + self.cr, self.uid, move_values, context=context) + + def test_change_journal_on_move(self): + context = {} + journal_id = self.ref('account.sales_journal') + journal_cash_id = self.ref('account.cash_journal') + period_id = self.ref('account.period_1') + journal_period_id = create_journal_period(self, + period_id, + journal_id, + context) + journal_period_done(self, journal_period_id, context) + move_values = get_simple_account_move_values(self, + period_id, + journal_cash_id) + self.registry('account.move').create(self.cr, + self.uid, + move_values, + context=context) + # Standard of Odoo doesn't check account_journal_period at write on + # account_move + # issue on Odoo github : #1633 + + # I check if the exception is correctly raised + """self.assertRaises(orm.except_orm, + self.registry('account.move').write, + self.cr, self.uid, [move_id], + {'journal_id': journal_id}, context=context)""" + + def test_draft_move_close_journal(self): + context = {} + + jour_per_obj = self.registry('account.journal.period') + journal_id = self.ref('account.sales_journal') + period_id = self.ref('account.period_1') + move_values = get_simple_account_move_values(self, + period_id, + journal_id) + self.registry('account.move').create(self.cr, + self.uid, + move_values, + context=context) + journal_period_ids =\ + jour_per_obj.search(self.cr, + self.uid, + [('period_id', '=', period_id), + ('journal_id', '=', journal_id), + ], + context=context) + # I check if the exception is correctly raised at closing journal that + # contains some draft account move + self.assertRaises(orm.except_orm, + jour_per_obj.action_done, + self.cr, self.uid, journal_period_ids, + context=context) diff --git a/account_journal_period_close/view/account_view.xml b/account_journal_period_close/view/account_view.xml new file mode 100644 index 000000000..f4301b169 --- /dev/null +++ b/account_journal_period_close/view/account_view.xml @@ -0,0 +1,34 @@ + + + + + account.period.form + (account_journal_period_close) + account.period + + + + + + + + + + +