How to open a form view with existing records in SAVE or VIEW mode via a button in Odoo 13?

652 Views Asked by At

I have a form view like this: enter image description here

After fill in the required fields and click the 'Confirm' button. I want to show the form view in SAVE/VIEW mode. But it just shows the Form View in EDIT mode like this:

enter image description here

I'd tried to define the 'confirm' button like this:

    def confirm(self):

    for rec in self:
        rec.state='daduocxacnhan'
    
    return {
   'view_mode': 'form',
   'res_model': 'dieu.chinh',
   'context': {'form_view_initial_mode': 'save', 'force_detailed_view': 'true'},
   'target': 'current',}

But it still didn't work as expected. It still shows the form view in EDIT mode after clicking the 'confirm' button.

Please help! Thank you!

1

There are 1 best solutions below

0
Mountain Tran On

Nếu Bạn muốn hiển thị form view là 1 cái alert xác nhận có chắc muốn confirm cái thông tin này không thì sử dụng thuộc tính confirm có sẵn trong Odoo và thêm vào button đó

Còn nếu bạn muốn hiển thị form view mà mình custom thì sử dụng wizard nhé.

Link tham khảo wizard:https://minhng.info/odoo/hien-thuc-wizard-odoo.html