تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
13957 أدوات العرض

How can I rename a field in the model code, e.g. `FooModel`, so that the changes propagate correctly to the database schema?

I would like to rename e.g. `spam` to `beans` in the `FooModel._columns`. But how can I ensure that the same column rename occurs in the database when I update the OpenERP server code?

I can just rename the field in the Python code for the model, of course. But how will Odoo know which field was renamed to what? What if I rename several fields at once? What if I rename one field, delete another, and create another? How can I signal to Odoo which new fields are renames?


الصورة الرمزية
إهمال
أفضل إجابة

Hi,

For example :

old :
    spam = fields.Char(string='SPAM')

new :

     beans = fields.Char(oldname='spam',string="SPAM")

"oldname" parameter refer to the previous name of this field, so that ORM can rename it automatically at migration.

الصورة الرمزية
إهمال
أفضل إجابة

I rename fields all the time. All that is needed is restarting Odoo, followed by an upgrade of the module that implements the field. Odoo will take care of the schema. 

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
ديسمبر 24
1328
1
مارس 24
2381
1
يونيو 23
12406
0
يناير 23
3105
2
سبتمبر 20
4041