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

Hello everyone,


I was using the presentation from the Odoo Experience 2018 as basis for creating a new view type from scratch (link below), but it seems it is not compatible anymore with the current version 14.


https://www.youtube.com/watch?v=SIoljYJhTqk


I get the following error when installing the example module provided ( download from https://github.com/Polymorphe57/hello_world_view_code ):


"ValueError: ir.actions.act_window.view.view_mode: required selection fields must define an ondelete policy that implements the proper cleanup of the corresponding records upon module uninstallation. Please use one or more of the following policies: 'set default' (if the field has a default defined), 'cascade', or a single-argument callable where the argument is the recordset containing the specified option."


It seems like the code to add the new view in the available view modes is not compatible anymore, due to it being a selection field with required argument set to True, but without any ondelete argument set. When adding the new view with following code it will not work:

class ActWindowView(models.Model):
_inherit = 'ir.actions.act_window.view'

view_mode = fields.Selection(selection_add=[('hello_world', "Hello World")])

PS: I also tried adding the 'ondelete' argument together with the 'selection_add', but it also fails. I tried ondelete='set null' and ondelete='cascade'. Neither option worked.


Can anyone point me to the right direction to solve this OR show the correct way to implement a new view from scratch compatible with odoo 14?


Thanks in advance!


PS: Even in the Odoo official documentation they explain it like this, but it seems like it does not work with version 14 ( https://www.odoo.com/documentation/14.0/reference/javascript_cheatsheet.html#creating-a-new-view-from-scratch )

아바타
취소

Hi,

    I guess you are facing trouble while adding a selection field. Hope this video helps you,

    https://www.youtube.com/watch?v=4tlfzy-ZtMQ&vl=en

Thanks

베스트 답변

Please try:

view_mode = fields.Selection(selection_add=[
    ('hello_world', 'Hello World')
], ondelete={'hello_world': 'cascade'})

아바타
취소

That worked for me, Thanks

베스트 답변

I installed the Hello World App example code and I fixed this same cascade problem. But I got other error, when I selected the Hello World App from the main menu. Do I need to set the "ControlPanel" to modelExtension in the Hello World App javascript code (hello_world_view.js)?

TypeError: Cannot read property 'modelExtension' of undefined

    at Class.init (http://localhost:8069/web/static/src/js/views/abstract_view.js:201:72)

    at Class.prototype.<computed> [as init] (http://localhost:8069/web/static/src/js/core/class.js:90:38)

    at Class.init (http://localhost:8069/hello_world_view/static/src/js/hello_world_view.js:118:21)

    at Class.prototype.<computed> [as init] (http://localhost:8069/web/static/src/js/core/class.js:90:38)

    at new Class (http://localhost:8069/web/static/src/js/core/class.js:107:33)

    at Class._createViewController (http://localhost:8069/web/static/src/js/chrome/action_manager_act_window.js:191:24)

    at http://localhost:8069/web/static/src/js/chrome/action_manager_act_window.js:306:43


abstract_view.js


 const searchModelParams = Object.assign({}, params, { action });

        if (this.withControlPanel || this.withSearchPanel) {

            const { arch, fields, favoriteFilters } = params.controlPanelFieldsView || {};

            const archInfo = ActionModel.extractArchInfo({ search: arch }, this.viewType);

            const controlPanelInfo = archInfo[this.config.ControlPanel.modelExtension]; // HERE the 'modelExtension' is undefined

            const searchPanelInfo = archInfo[this.config.SearchPanel.modelExtension];

            this.withSearchPanel = this.withSearchPanel && Boolean(searchPanelInfo);

            Object.assign(searchModelParams, {

                fields,

                favoriteFilters,

                controlPanelInfo,

                searchPanelInfo,

            });

        }


Odoo's documentation is very "poor." Therefore it is wery difficult to learn Odoo development.

아바타
취소

Can't agree more ,even if you post your question you still won't find help

관련 게시물 답글 화면 활동
2
4월 21
1935
0
9월 18
2157
2
4월 15
5910
1
3월 15
9675
0
2월 20
3761