콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
14040 화면

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
12월 24
1431
1
3월 24
2464
1
6월 23
12474
0
1월 23
3161
2
9월 20
4154