~renatonlima/account-payment/account-payment-extension-7.0

« back to all changes in this revision

Viewing changes to account_renumber/test/create_moves.py

  • Committer: dani-ds
  • Date: 2012-11-16 14:14:37 UTC
  • Revision ID: danielcampos@avanzosc.com-20121116141437-pfbos8hfgofgtvb3
[ADD] account_renumber

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# -*- encoding: utf-8 -*-
 
3
##############################################################################
 
4
#
 
5
#    OpenERP - Account renumber wizard
 
6
#    Copyright (C) 2009 Pexego Sistemas Informáticos. All Rights Reserved
 
7
#    $Id$
 
8
#
 
9
#    This program is free software: you can redistribute it and/or modify
 
10
#    it under the terms of the GNU General Public License as published by
 
11
#    the Free Software Foundation, either version 3 of the License, or
 
12
#    (at your option) any later version.
 
13
#
 
14
#    This program is distributed in the hope that it will be useful,
 
15
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
#    GNU General Public License for more details.
 
18
#
 
19
#    You should have received a copy of the GNU General Public License
 
20
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
#
 
22
##############################################################################
 
23
 
 
24
"""
 
25
Script that creates large amounts of account moves on different days,
 
26
that can be used later for testing the renumber wizard.
 
27
"""
 
28
__author__ = "Borja López Soilán (Pexego)"
 
29
 
 
30
import sys
 
31
import re
 
32
import xmlrpclib
 
33
import socket
 
34
import netsvc
 
35
logger = netsvc.Logger()
 
36
 
 
37
def create_lots_of_account_moves(dbname, user, passwd, howmany):
 
38
    """
 
39
    Small OpenERP function that will create lots of account moves
 
40
    on the selected database, that can later be used for
 
41
    testing the renumber wizard.
 
42
    Note: The database must have demo data, and a fiscal year 2009 created.
 
43
    """
 
44
    url_template = "http://%s:%s/xmlrpc/%s"
 
45
    server = "localhost"
 
46
    port = 8069
 
47
    user_id = 0
 
48
 
 
49
    login_facade = xmlrpclib.ServerProxy(url_template % (server, port, 'common'))
 
50
    user_id = login_facade.login(dbname, user, passwd)
 
51
    object_facade = xmlrpclib.ServerProxy(url_template % (server, port, 'object'))
 
52
        
 
53
        
 
54
    for i in range(1, howmany):
 
55
        #
 
56
        # Create one account move
 
57
        #
 
58
        move_id = object_facade.execute(dbname, user_id, passwd,
 
59
                'account.move', 'create', {
 
60
                    'ref': 'Test%s' % i,
 
61
                    'type': 'journal_voucher',
 
62
                    'journal_id': 5,
 
63
                    'line_id': [
 
64
                        (0, 0, {
 
65
                            'analytic_account_id': False,
 
66
                            'currency_id': False,
 
67
                            'tax_amount': False,
 
68
                            'account_id': 2,
 
69
                            'partner_id': False,
 
70
                            'tax_code_id': False,
 
71
                            'credit': 1000.0,
 
72
                            'date_maturity': False,
 
73
                            'debit': False,
 
74
                            'amount_currency': False,
 
75
                            'ref': False,
 
76
                            'name': 'Test_l1'
 
77
                        }),
 
78
                        (0, 0, {
 
79
                            'analytic_account_id': False,
 
80
                            'currency_id': False,
 
81
                            'tax_amount': False,
 
82
                            'account_id': 4,
 
83
                            'partner_id': False,
 
84
                            'tax_code_id': False,
 
85
                            'credit': False,
 
86
                            'date_maturity': False,
 
87
                            'debit': 1000.0,
 
88
                            'amount_currency': False,
 
89
                            'ref': False,
 
90
                            'name': 'Test_l2'})
 
91
                        ],
 
92
                        'period_id': 1,
 
93
                        'date': '2009-01-%s' % ((i % 31) or 1),
 
94
                        'partner_id': False,
 
95
                        'to_check': 0
 
96
                },
 
97
                {})
 
98
 
 
99
        # Validate the move
 
100
        object_facade.execute(dbname, user_id, passwd,
 
101
                    u'account.move', 'button_validate', [move_id], {})
 
102
       
 
103
# ------------------------------------------------------------------------
 
104
# ------------------------------------------------------------------------
 
105
# ------------------------------------------------------------------------
 
106
    
 
107
if __name__ == "__main__":
 
108
    if len(sys.argv) < 5:
 
109
        logger.notifyChannel(u"Usage: %s <dbname> <user> <password> <howmany>" % sys.argv[0])
 
110
    else:
 
111
        create_lots_of_account_moves(sys.argv[1], sys.argv[2], sys.argv[3], int(sys.argv[4]))
 
112
    
 
113
    
 
114