Hello everyone, I hope you are all well.
I'm trying to import records via a CSV file, specifically from the account.account template, but when I run the module, I get the following error:
psycopg2.errors.NotNullViolation: null value in column "create_asset" of relation "account_account" violates not-null constraint
DETAIL: Failing row contains (284, null, 1, 1, asset_cash, {"en_US": "Caja Principal"}, null, null, f, f, f, 2025-06-05 15:41:55.655359, 2025-06-05 15:41:55.655359, null, null, null).
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/service/server.py", line 1328, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/tools/func.py", line 97, in locked
return func(inst, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/modules/registry.py", line 127, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 480, in load_modules
processed_modules += load_marked_modules(env, graph,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 365, in load_marked_modules
loaded, processed = load_module_graph(
^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 228, in load_module_graph
load_data(env, idref, mode, kind='data', package=package)
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 72, in load_data
tools.convert_file(env, package.name, filename, idref, mode, noupdate, kind)
File "/home/odoo/src/odoo/odoo/tools/convert.py", line 604, in convert_file
convert_csv_import(env, module, pathname, fp.read(), idref, mode, noupdate)
File "/home/odoo/src/odoo/odoo/tools/convert.py", line 646, in convert_csv_import
result = env[model].with_context(**context).load(fields, datas)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/models.py", line 1429, in load
flush()
File "/home/odoo/src/odoo/odoo/models.py", line 1378, in flush
messages.append(dict(info, type='error', **PGERROR_TO_OE[e.pgcode](self, fg, info, e)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/models.py", line 7539, in convert_pgerror_not_null
field = fields[field_name]
~~~~~~^^^^^^^^^^^^
KeyError: 'create_asset'
I investigate and see that the value "no" can be assigned, since there are other records of the same model, so I adjust the structure:
id,code,name,account_type,reconcile,create_asset
l10n_ve_chart_account_cta_1_1_1_01_01,1.1.1.01.01,Main Cash,asset_cash,False,no
l10n_ve_chart_account_cta_1_1_1_01_02,1.1.1.01.02,Caja Chica Bolivares,asset_cash,True,no
And when I compile the module:
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/service/server.py", line 1328, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/tools/func.py", line 97, in locked
return func(inst, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/modules/registry.py", line 127, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 480, in load_modules
processed_modules += load_marked_modules(env, graph,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 365, in load_marked_modules
loaded, processed = load_module_graph(
^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 228, in load_module_graph
load_data(env, idref, mode, kind='data', package=package)
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 72, in load_data
tools.convert_file(env, package.name, filename, idref, mode, noupdate, kind)
File "/home/odoo/src/odoo/odoo/tools/convert.py", line 604, in convert_file
convert_csv_import(env, module, pathname, fp.read(), idref, mode, noupdate)
File "/home/odoo/src/odoo/odoo/tools/convert.py", line 646, in convert_csv_import
result = env[model].with_context(**context).load(fields, datas)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/models.py", line 1418, in load
for id, xid, record, info in converted:
File "/home/odoo/src/odoo/odoo/models.py", line 1599, in _convert_records
for stream_index, (record, extras) in enumerate(records):
File "/home/odoo/src/odoo/odoo/models.py", line 1484, in _extract_records
raise ValueError(f'Invalid field name {fname!r}')
ValueError: Invalid field name 'create_asset'
So, if I don't include it, it tells me the value is missing, but if I include it, it tells me the field is invalid.
I appreciate the advice on how to correctly import the accounting accounts I want to set up for a location. Thank you very much.