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('', 'Hospital Bed',)
	health_professional = fields.Many2One('gnuhealth.healthprofessional','Health Professional', readonly=True)
	def __setup__(cls):
	   t = cls.__table__()
	   cls._sql_constraints = [
	       ('name_uniq', Unique(t,, '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/ 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>
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/", line 53, in run
    pool.init(update=options.update, lang=list(lang),
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/", line 164, in init
    restart = not load_modules(
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/modules/", line 438, in load_modules
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/modules/", line 406, in _load_modules
    load_module_graph(graph, pool, update, lang)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/modules/", line 238, in load_module_graph
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/model/", line 228, in __register__
    table = cls.__table_handler__(module_name)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/model/", 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/", line 56, in __init__
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/backend/postgresql/", 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.