Question

Can any one explain me why OpenErp Create some default in posgresql database table while creating a new object in OpneErp module ??

In a email_template module --> email.template object --> create some default field like..

id, create_uid, create_date, write_date

explain each field with description

While from Openerp trunk-Server in base module like..

 res_users and res_partner

doesn't created this kind of field in PostgreSQL database table

my question is why create default field and and why not default field in some base module ??

Était-ce utile?

La solution

You double check following field are already exist in base module table res_users and res_partner

id, create_uid, create_date, write_date, write_uid

Reason behind this whenever you create new table you must inherit osv.osv base class.

Example: I'm create project table and inherit from osv.osv so this table automatically create extra five column id, create_uid, create_date, write_date, write_uid plus you define project_name column. Total 6 six column created.

project.py

from openerp.osv import osv, fields

class My_project(osv.osv):
    _name = 'my.project'
    _description = 'My project'
    _columns = {
         'project_name':fields.char('Project Name',size=30),
    }

Advantage

  1. To know which user are create this table with timestamp (date time).

  2. Auto Increment of ID field. so this column primary key,

  3. Which user (write_uid) are update table row with also store with timestamp update into write_date column.

    So above reason help us to track time and userid.


If you set _log_access = False Attributes four fields will not be created in the SQL table: create_uid, create_date, write_uid, write_date.

project.py

from openerp.osv import osv, fields

class My_project(osv.osv):
    _name = 'my.project'
    _description = 'My project'
    _log_access = False
    _columns = {
         'project_name':fields.char('Project Name',size=30),
    }

Now you check only 2 column are create for this table.

Hope this help you!

Autres conseils

You must please verify your database package, the following fields are already there in res_users and res_partners.

and the fields:

  • id: the sequences of index numbers for each record of particular table.

  • create_uid: the user id who created a particular record.

  • create_date: creation date of record.

  • write_uid: the user id who last update a particular record

  • write_date: date of record updated

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top