Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
4027 Vistas

hello guys,

I need help, I'm trying to disable edit button in form view based on a field value state 

here's the status I want to disable edit button based on it :


 Status = fields.Selection([

        ('pending', 'Pending'),

        ('resolved', 'Resolved'),

        ('in progress', 'In Progress')

    ])

and here's my form view - > 

    <record id="complaint_form" model="ir.ui.view">

<field name="name">complaint.form</field>

<field name="model">complaint</field>

<field name="arch" type="xml">

<form >

                    <sheet>

                         <group>

                        <group>

                            <field name="x_css" invisible="1"/>

                            <field name = "employee" widget="many2one_tags"/>

                            <div style="height:20px">

                               </div>

                             <field name = "department" widget="many2one_tags"/>

                        </group>

                        <group>

                            <field name = "complaint_type" widget="many2one_tags"/>

                             <div style="height:20px">

                               </div>

                             <field name = "issue"/>

                        </group>

                              <group>

                                   <field name = "date"/>

                                   <div style="height:20px">

                               </div>

                                  <field name = "resolved_date"/>

                        </group>

                              <group>

                                  <field name = "has_financial_effect"/>

                                   <div style="height:20px">

                               </div>

                                  <field name = "has_effect_on_work_efficiency"/>

                        </group>

                              <group>

                                  <field name = "Status"/>

                                   <div style="height:20px">

                               </div>

                                   <field name = "action_company"/>

                        </group>


                         </group>

                    </sheet>

</form>

</field>

</record>

I need the Edit button disabled when status become resolved -> can any body help ? 
Avatar
Descartar
Mejor respuesta

Hi you could override write methode ex :

@api.model
def write(self, records, value):

if self.status == 'resolved':

raise ValidationError(_("You Cannot change as it is in resolved State"))

return super().write(records, value)


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
3
sept 24
3905
2
sept 23
9706
0
oct 21
2509
4
dic 19
6645
3
abr 24
10726