hi,
how to create a primary key auto increment field?
thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
In default Openerp all the table "id" column created with Primary key auto increment using ORM.
orm.py code
def _create_table(self, cr):
cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id))' % (self._table,))
cr.execute(("COMMENT ON TABLE \"%s\" IS %%s" % self._table), (self._description,))
_schema.debug("Table '%s': created", self._table)
if self._log_access:
upd0 += ',create_uid,create_date,write_uid,write_date'
upd1 += ",%s,(now() at time zone 'UTC'),%s,(now() at time zone 'UTC')"
upd2.extend((user, user))
cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2))
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
Registrarse| Publicaciones relacionadas | Respuestas | Vistas | Actividad | |
|---|---|---|---|---|
|
1
jun 21
|
4486 | |||
|
Auto Increment Custom Field
Resuelto
|
5
ago 20
|
14295 | ||
|
1
jun 15
|
7334 | |||
|
1
dic 21
|
4723 | |||
|
1
dic 19
|
3126 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.