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

Hi,


I have two models:

/

class MyModel(models.TransientModel):
​_name = 'my.model'

​name = fields.Char(string='Name')
​line_ids = fields.One2many(string='Lines',
comodel_name='my.model.line',
inverse_name='my_model_id')

class MyModelLine(models.TransientModel):
_name = 'my.model.line'

name = fields.Char(string='Name')
my_model_id = fields.many2one(string='My Model',
comodel_name='my.model')

In the form of 'my.model', th lines of 'my.model.line' are fielled automatically.

The user can delete lines and can't create lines. This is working fine.

However I would like to prevent the user to open or edit a line (model 'my.model.line').


Boris




Avatar
Descartar
Mejor respuesta

Hi,

you can prevent opening lines in one2many field by using no_open 

<field name="bank_ids">
        <tree editable="bottom" no_open="True">
                <field name="sequence" widget="handle"/>
                <field name="bank_id"/>

       </tree>

</field>


to prevent edit without delete you can add readonly="1" to fields inside tree

Avatar
Descartar