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

I'm trying to create a model named 'mantenimiento' based on project.task, but want to omit one or two columns from it.

I have this so far:

 _name = "project.mantenimientos" 
_description = "Mantenimientos"
_inherit = 'project.task'

How could I do it?

Thanks.

아바타
취소
베스트 답변

You need to define those fields as function fields in your model to don't get created in your table.

아바타
취소

Good trick. But in this case the field definition stays there in the model. And it might confuse tools that use the registry.

In this case it is prototype inheritance. A cleaner way would be if odoo allows specify the fields to exclude from the source model. Ex:

_inherit = {'project.task': {'exclude': ['fieldA', 'fieldB', ....]} }

베스트 답변

Hi Marie Pinto,

There are two possiblities to remove columns.

1) Easier way: Either inherit view and just invisible those columns which you don't want to show to user.

2) little tricky: override def init(self, cr): method of this model and execute query to drop columns by altering table as suggest by vivek.

  Risk factor in second step : If your are altering the table and removing any columns from table make sure those fields are not used in any views you have to remove it from there. if those fields are used in any base module view you have to replace it by inheriting views.

Hope this would clear more idea.

Regards,

Anil.




아바타
취소
베스트 답변

There is not any way for delete columns using _inherit. You need to remove column from database(postgres) using alter table.

You need to execute query for drop column like : alter table project_mantenimientos drop column specific_column.

아바타
취소
관련 게시물 답글 화면 활동
2
6월 25
796
2
6월 25
3070
0
4월 21
3420
1
3월 15
5308
1
2월 25
1201