psycopg2.errors.UndefinedTable: relation "model_id_seq" does not exist while migration of my module

hi, im try to use trytond-admin -d test -u z_nurse_call command, to add my own module to gnuhealth and this is my module:

class NurseCall(ModelSQL, ModelView):
	"Nurse Call"
	__name__ = "arnika.nurseCall"
	__rec_name = "name"
	name = fields.Many2One('gnuhealth.patient', 'Patient')
	date = fields.DateTime('Date')
	bed = fields.Many2One('gnuhealth.hospital.bed', 'Hospital Bed',)
	health_professional = fields.Many2One('gnuhealth.healthprofessional','Health Professional', readonly=True)
	
	@classmethod
	def __setup__(cls):
	   super().__setup__()
	   t = cls.__table__()
	   cls._sql_constraints = [
	       ('name_uniq', Unique(t, t.name), 'The Name must be unique !'),]

and i get this error :

3636 140440737433408 [2023-04-05 13:21:46,503] WARNING py.warnings /usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, imp, stat

Traceback (most recent call last):
  File "gnuhealth/tryton/server/trytond-6.0.27/bin/trytond-admin", line 23, in <module>
    admin.run(options)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/admin.py", line 53, in run
    pool.init(update=options.update, lang=list(lang),
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/pool.py", line 164, in init
    restart = not load_modules(
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/modules/__init__.py", line 438, in load_modules
    _load_modules(update)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/modules/__init__.py", line 406, in _load_modules
    load_module_graph(graph, pool, update, lang)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/modules/__init__.py", line 238, in load_module_graph
    cls.__register__(module)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/model/modelsql.py", line 228, in __register__
    table = cls.__table_handler__(module_name)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/model/modelsql.py", line 212, in __table_handler__
    return backend.TableHandler(cls, module_name, history=history)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/backend/postgresql/table.py", line 56, in __init__
    cursor.execute(
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/backend/postgresql/database.py", line 74, in execute
    cursor.execute(self, sql, args)
psycopg2.errors.UndefinedTable: relation "arnika_nursecall_id_seq" does not exist

any help make me happy .

It may be linked to the CamelCase name. But normally we do not remove the case on the table name (nor sequence name). Also before the failing code, there is a test about the existence of the sequence.

1 Like

Can you elaborate on what was the problem and if we should fix something?

1 Like

yep i fix that , as you said its for CamelCase name. thanks to you

Indeed there is a bug that prevent Tryton to manage correctly sequences with different cases: PostgreSQL sequence functions fails with CamelCase names (#12194) · Issues · Tryton / Tryton · GitLab

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.