Files
account-financial-tools/account_renumber/test/create_moves.py
Joaquin Gutierrez 57c24565d0 [FIX+IMP] account_renumber: General Refactoring:
[FIX] Changed types to orm.Model, orm.TransientModel and orm.AbstractModel.
[FIX] Change renumbering assistants in renumbering, show results and cancellation to version 7.
[FIX] Remove legacy code calls.
[FIX] Contributions have been written in the standard format of the community.
[FIX] Changes in the form to work as a real wizard.
[FIX] Remove 'init_xml' keys, because it's no longer needed in v7.
[FIX] Rename 'demo_xml' key to the new standard 'demo'.
[FIX] Rename menu entry to "Renumber journal entries".
[FIX] Change imports calls.
[FIX] Remove __author__ variables in files, because authors are put on manifest file (__openerp__.py).
[FIX] Increased compatibility with standard PEP8.
[FIX] Delete test folder. On the next review I'll be able to create with YAML.
[IMP] In selecting these come peridos sorted correctly. I modified the code to renumber the entries from period to period with this order.
[FIX] Wizard in new windows.
[FIX] Add oe_link class to close botton.
[FIX] Remove import time, it's not required.
[FIX] Delete "_process" method, it's not requerired.
[FIX] Delete "_get_id", now use the method "next_by_id" of object ir.sequence.
[FIX] Refactoring get_sequence_id_for_fiscalyear_id. At the core there is no method to get the id of a sequence based on the fiscal year. Change sql querys for browser method.
[FIX] Change order "Renumber" and "Cancel" buttons.
[FIX] Identation for return sequence_id in method get_sequence_id_for_fiscalyear_id
[FIX] Change variable name seq_facade for sequences.
[FIX] Revision for PEP8
2019-02-18 09:34:36 +01:00

114 lines
5.2 KiB
Python

# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP - Account renumber wizard
# Copyright (C) 2009 Pexego Sistemas Informáticos. All Rights Reserved
# $Id$
#
# 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/>.
#
##############################################################################
"""
Script that creates large amounts of account moves on different days,
that can be used later for testing the renumber wizard.
"""
__author__ = "Borja López Soilán (Pexego)"
import sys
import re
import xmlrpclib
import socket
import logging
logger = logging.getLogger("create_lots_of_account_moves")
def create_lots_of_account_moves(dbname, user, passwd, howmany):
"""
Small OpenERP function that will create lots of account moves
on the selected database, that can later be used for
testing the renumber wizard.
Note: The database must have demo data, and a fiscal year 2009 created.
"""
url_template = "http://%s:%s/xmlrpc/%s"
server = "localhost"
port = 8069
user_id = 0
login_facade = xmlrpclib.ServerProxy(
url_template % (server, port, 'common'))
user_id = login_facade.login(dbname, user, passwd)
object_facade = xmlrpclib.ServerProxy(
url_template % (server, port, 'object'))
for i in range(1, howmany):
#
# Create one account move
#
move_id = object_facade.execute(dbname, user_id, passwd,
'account.move', 'create', {
'ref': 'Test%s' % i,
'type': 'journal_voucher',
'journal_id': 5,
'line_id': [
(0, 0, {
'analytic_account_id': False,
'currency_id': False,
'tax_amount': False,
'account_id': 2,
'partner_id': False,
'tax_code_id': False,
'credit': 1000.0,
'date_maturity': False,
'debit': False,
'amount_currency': False,
'ref': False,
'name': 'Test_l1'
}),
(0, 0, {
'analytic_account_id': False,
'currency_id': False,
'tax_amount': False,
'account_id': 4,
'partner_id': False,
'tax_code_id': False,
'credit': False,
'date_maturity': False,
'debit': 1000.0,
'amount_currency': False,
'ref': False,
'name': 'Test_l2'})
],
'period_id': 1,
'date': '2009-01-%s' % ((i % 31) or 1),
'partner_id': False,
'to_check': 0
},
{})
# Validate the move
object_facade.execute(dbname, user_id, passwd,
u'account.move', 'button_validate', [move_id], {})
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
if __name__ == "__main__":
if len(sys.argv) < 5:
logger.info(u"Usage: %s <dbname> <user> <password> <howmany>" % sys.argv[0])
else:
create_lots_of_account_moves(
sys.argv[1], sys.argv[2], sys.argv[3], int(sys.argv[4]))