Hi,
pip install --editable /home/awes7/projects/training/tryton-training/modules/library
trytond-admin -c trytond.conf -d training -u library
I get this error:
AttributeError: 'NoneType' object has no attribute 'put_connection'
Thanks in advance.
import csv
from proteus import config, Model
# Configure the Tryton connection
config_file = '/home/awes7/projects/training/tryton-training/modules/library/tryton.cfg' # Replace with your Tryton configuration file path
config.set_trytond(config_file)
# Establish a connection to the Tryton database
database_name = 'training' # Replace with your database name
config.CONNECTION.database = database_name
config.CONNECTION.login = 'admin' # Replace with your Tryton username
config.CONNECTION.password = 'admin' # Replace with your Tryton password
# CSV file with party data
csv_file = 'parties.csv' # Replace with the path to your CSV file
# Function to create a party record
def create_party(party_data):
Party = Model.get('party.party')
party = Party(**party_data)
party.save()
return party
# Read and process the CSV file
with open(csv_file, mode='r') as file:
csv_reader = csv.DictReader(file)
for row in csv_reader:
party_data = {
'name': row['Name'],
'address': row['Address'],
'city': row['City'],
'zip': row['ZIP'],
'country': row['Country'],
'phone': row['Phone'],
'email': row['Email']
# Add other fields as needed
}
create_party(party_data)
print(f'Created party: {party_data["name"]}')
trytond-admin -c trytond.conf -d training -u library
195238 140250126897152 [2023-09-01 23:53:14,270] ERROR trytond.backend.postgresql.database connection to "home/awes7/projects/training/tryton-training/modules/library/tryton.cfg" failed
Traceback (most recent call last):
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/modules/__init__.py", line 52, in import_module
module = importlib.import_module(fullname)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'trytond.modules.library'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/backend/postgresql/database.py", line 230, in __new__
inst._connpool = ThreadedConnectionPool(
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/psycopg2/pool.py", line 161, in __init__
AbstractConnectionPool.__init__(
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/psycopg2/pool.py", line 59, in __init__
self._connect()
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/psycopg2/pool.py", line 63, in _connect
conn = psycopg2.connect(*self._args, **self._kwargs)
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: database "home/awes7/projects/training/tryton-training/modules/library/tr" does not exist
Traceback (most recent call last):
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/modules/__init__.py", line 52, in import_module
module = importlib.import_module(fullname)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'trytond.modules.library'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/transaction.py", line 179, in start
database = backend.Database(database_name).connect()
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/backend/postgresql/database.py", line 230, in __new__
inst._connpool = ThreadedConnectionPool(
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/psycopg2/pool.py", line 161, in __init__
AbstractConnectionPool.__init__(
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/psycopg2/pool.py", line 59, in __init__
self._connect()
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/psycopg2/pool.py", line 63, in _connect
conn = psycopg2.connect(*self._args, **self._kwargs)
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: database "home/awes7/projects/training/tryton-training/modules/library/tr" does not exist
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/transaction.py", line 239, in stop
self.rollback()
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/transaction.py", line 355, in rollback
for datamanager in self._datamanagers:
AttributeError: 'Transaction' object has no attribute '_datamanagers'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/awes7/projects/training/.my_new_env/bin/trytond-admin", line 31, in <module>
admin.run(options)
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/admin.py", line 57, in run
pool.init(update=options.update, lang=list(lang),
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/pool.py", line 155, in init
self.start()
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/pool.py", line 108, in start
register_classes(with_test=cls.test)
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/modules/__init__.py", line 365, in register_classes
the_module = import_module(module)
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/modules/__init__.py", line 76, in import_module
module = spec.loader.load_module()
File "<frozen importlib._bootstrap_external>", line 548, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 1063, in load_module
File "<frozen importlib._bootstrap_external>", line 888, in load_module
File "<frozen importlib._bootstrap>", line 290, in _load_module_shim
File "<frozen importlib._bootstrap>", line 719, in _load
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/awes7/projects/training/tryton-training/modules/library/__init__.py", line 3, in <module>
import library
File "/home/awes7/projects/training/tryton-training/modules/library/library.py", line 6, in <module>
config.set_trytond(config_file)
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/proteus/config.py", line 329, in set_trytond
_CONFIG.current = TrytondConfig(database, user, config_file=config_file)
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/proteus/config.py", line 282, in __init__
self.pool.init()
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/pool.py", line 167, in init
restart = not load_modules(
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/modules/__init__.py", line 455, in load_modules
with Transaction().start(database_name, 0):
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/transaction.py", line 218, in start
self.stop(False)
File "/home/awes7/projects/training/.my_new_env/lib/python3.10/site-packages/trytond/transaction.py", line 241, in stop
self.database.put_connection(
AttributeError: 'NoneType' object has no attribute 'put_connection'