Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
19672 มุมมอง

Hello, I have a problem.

When I open a record, the form is still in edit mode.. I would like it to be in basic view mode for all the records. 

I do not find why the form is systematically in edit mode

Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Normally the form view in edit mode will displayed if you give 'target': 'inline', in action params.

Please check your action and if not the case try to give the view_id.


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi, if you are using JS or you are returning an action to open the form you can add `flags` for this, unfortunately there is no `flags` field in the python model of `ir.action.act_window`.

JS:

 var action = {
                type: 'ir.actions.act_window',
                name: 'Action Name',
                target: 'new', //use 'current' for not opening in a dialog
                res_model: 'target.model',
                res_id: target_id,
                view_id: 'view_xml_id',//optional
                view_type: 'form',
                views: [[false,'form']],
                context: {//your context
                         },
                flags:{
                mode:'readonly'
} // default is 'edit'
            };
        this.do_action(action);
 


in python code (assuming that your button has `type='object'`):

@api.multi
def your_button_name(self):
return {
                'type': 'ir.actions.act_window',
                'name': 'Action Name',
                'target': 'new', #use 'current' for not opening in a dialog
                'res_model': 'target.model',
                'res_id': target_id,
                'view_id': 'view_xml_id',#optional
                'view_type': 'form',
                'views': [[false,'form']],
                'context': {#your context
                         },
                'flags':{mode:'readonly'} # default is 'edit'
            };

 

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thank for the reply,

Please excuse me I think I have not well explained my problem, I already"<field name="view_mode">kanban,form,tree</field>"

On the Kanban view, when I click on a record, the form opens but directly in edit mode, I would like it to open in view mode,

I have the same problem on a calendar view.


Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi, Joaquim lozano

     You have to change the "Action window" of your current model and there will be one field like,

"<field name="view_mode">tree,form</field>"

    you have to change the view mode's priority. at there tree view must be first and second form view. Tree view is for display the data and form view is for edit the data.

I hope this will help you.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.พ. 23
1968
2
ก.ย. 15
5596
1
มี.ค. 15
3748
3
พ.ค. 24
3291
1
พ.ย. 22
3374