Error in calling trytond.modules.company.tests.tools 's create_company, get_company

52 views
Skip to first unread message

Dr Praveen Bhatia

unread,
Sep 28, 2016, 1:09:44 PM9/28/16
to tryton
I have written the following program based on scenario_reports.rst (in account module's test) but keep getting error when I call create_company. What is my mistake and how to solve it?

"Program : 

#========================
#Account Reports Scenario
#========================

#Imports::

import datetime
from dateutil.relativedelta import relativedelta
from decimal import Decimal
from proteus import config, Model, Wizard, Report
from trytond.modules.company.tests.tools import create_company, get_company
from trytond.modules.account.tests.tools import create_fiscalyear, create_chart, get_accounts
today = datetime.date.today()

#Create database::

config = config.set_trytond()
config.pool.test = True

#Install account::

Module = Model.get('ir.module')
module, = Module.find([ ('name', '=', 'account'), ])
module.click('install')
Wizard('ir.module.install_upgrade').execute('upgrade')
#Create company::

_ = create_company()
#company = get_company()





#Error that I get :

python mytest1.py
/home/ubuntu/Envs/tryton/local/lib/python2.7/site-packages/trytond/ir/action.py:393: DeprecationWarning: on_change_with argument is deprecated, use the depends decorator
  on_change_with=['name', 'template_extension']),

Traceback (most recent call last):
  File "mytest1.py", line 29, in <module>
    _ = create_company()
  File "/home/ubuntu/Envs/tryton/local/lib/python2.7/site-packages/trytond/modules/company/tests/tools.py", line 21, in create_company
    party.save()
  File "/home/ubuntu/Envs/tryton/local/lib/python2.7/site-packages/proteus/__init__.py", line 101, in newfunc
    return self.func(owner, [instance], *args, **kwargs)
  File "/home/ubuntu/Envs/tryton/local/lib/python2.7/site-packages/proteus/__init__.py", line 758, in save
    ids = proxy.create(values, context)
  File "/home/ubuntu/Envs/tryton/local/lib/python2.7/site-packages/proteus/config.py", line 174, in __call__
    result = rpc.result(meth(*args, **kwargs))
  File "/home/ubuntu/Envs/tryton/local/lib/python2.7/site-packages/trytond/modules/party/party.py", line 164, in create
    return super(Party, cls).create(vlist)
  File "/home/ubuntu/Envs/tryton/local/lib/python2.7/site-packages/trytond/model/modelsql.py", line 601, in create
    cls._validate(sub_records)
  File "/home/ubuntu/Envs/tryton/local/lib/python2.7/site-packages/trytond/model/modelstorage.py", line 1004, in _validate
    field_name)
  File "/home/ubuntu/Envs/tryton/local/lib/python2.7/site-packages/trytond/model/modelstorage.py", line 988, in required_test
    error_args=cls._get_error_args(field_name))
  File "/home/ubuntu/Envs/tryton/local/lib/python2.7/site-packages/trytond/error.py", line 74, in raise_user_error
    raise UserError(error)
trytond.exceptions.UserError: ('UserError', (u'The field "Account Payable" on "Party" is required.', ''))


Cédric Krier

unread,
Sep 30, 2016, 3:55:03 AM9/30/16
to tryton
On 2016-09-28 09:28, Dr Praveen Bhatia wrote:
> import datetime
> from dateutil.relativedelta import relativedelta
> from decimal import Decimal
> from proteus import config, Model, Wizard, Report
> from trytond.modules.company.tests.tools import create_company, get_company
> from trytond.modules.account.tests.tools import create_fiscalyear,
> create_chart, get_accounts
> today = datetime.date.today()
>
> #Create database::
>
> config = config.set_trytond()
> config.pool.test = True
>
> #Install account::
>
> Module = Model.get('ir.module')
> module, = Module.find([ ('name', '=', 'account'), ])
> module.click('install')
> Wizard('ir.module.install_upgrade').execute('upgrade')
> #Create company::
>
> _ = create_company()
> #company = get_company()

> trytond.exceptions.UserError: ('UserError', (u'The field "Account Payable"
> on "Party" is required.', ''))

If you run on an existing database where 'account' module is already
installed. This is normal to fail because the method create_company
needs to create a party but if the user is already in a company than the
account fields are required.
You must run from an empty database.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Dr Praveen Bhatia

unread,
Sep 30, 2016, 11:10:04 AM9/30/16
to tryton

Got it! Thanks.
  
Starting with empty database solved the problem. 

Dr Praveen Bhatia

unread,
Sep 30, 2016, 11:10:04 AM9/30/16
to tryton


If you run on an existing database where 'account' module is already
installed. This is normal to fail because the method create_company
needs to create a party but if the user is already in a company than the
account fields are required.
You must run from an empty database.


Reply all
Reply to author
Forward
0 new messages