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))
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up| Related Posts | Replies | Views | Activity | |
|---|---|---|---|---|
|
1
Jun 21
|
4484 | |||
|
Auto Increment Custom Field
Solved
|
5
Aug 20
|
14294 | ||
|
1
Jun 15
|
7334 | |||
|
1
Dec 21
|
4723 | |||
|
1
Dec 19
|
3125 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.