Ayuda

4

How to show active and non-active records in one2many tree view?

Avatar
Marco Dieckhoff

Hi!

I want to show active and non-active records (here: of a one2many relationship) in the tree view of a subview together.

I tried

domain="['|',('active','=',True),('active','=',False)]"

to show both, but this had no effect - only active=True is shown. Even

domain=[('active','=',False)]

to show only non-active records does not work: it shows only active records, still.

Any hints or ideas? Is the many2one view broken in some way in 6.1?

<record id="model_form" model="ir.ui.view">
        <field name="name">model.form</field>
        <field name="model">model</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
                <form string="model">
                       <field name="name" colspan="4" />
                       ...
                       <separator colspan="4" string="Remotes" />
                            <field name="remote_ids" nolabel="1" colspan="4"
                            domain="['|',('active','=',True),('active','=',False)]">
                                    <tree string="Remote">
                                            <field name="name" />
                        ...
                                    </tree>
                                    <form string="Remote">
                                            <field name="name" colspan="4" />
                        ...
Avatar
Descartar
5 Respuestas
3
Avatar
Ivan Elizaryev
Best Answer

Try to specify active_test in context to ignore active field


 <field name="remote_ids" context="{'active_test':False}">...
Avatar
Descartar
1
Avatar
Eduardo de Miguel
Best Answer

Option 1:

Put context on your field definition:

remote_ids = fields.One2many(comodel_name='model.remote', inverse_name='remote_inverse', string='Remote IDs', context={'active_test': False})

Note: This context is only applied when searching values.


Option 2:

You can add the context with {'active_test': False} on the action that opens directly the tree/form view, but if you enter on the register vía relational link (click on many2one or something that not implies Menús or Actions), you will not have the context because you are not using the action (and don't see the registers).


Avatar
Descartar
0
Avatar
Andrias Yohanson
Best Answer

I wrote some code here the example.. it works for me

'jo_ids' : fields.one2many('jo.jo', 'employee_id', domain=['|',('active','=',False),('active','=',True)], string='No Jo'),
Avatar
Descartar
0
Avatar
Sathiyan
Best Answer
  • Adding a filter in the search view for model.form should do.
  • You must have a "active" field in the form view of model.form view to use this,
  • <filter icon="terp-personal+" domain="[('active','=',True)]" name="active" string="Active"/>

Hope it Helps..

5 Comentarios
Avatar
Descartar
Avatar
Marco Dieckhoff
-

Sorry, I don't have a search view when the object is embedded as one2many field :)

Avatar
Sathiyan
-

Then you must inherit one from the model.from

Avatar
Marco Dieckhoff
-

It's not about showing active lines from model.form, it's about the a subform view of the model related via remote_ids (in model.form), and the implicitly included subform defined by tree and form in field name="remote_ids".

(And yes, of course field name="active" is in the remote_ids block form, as invisible="1". I also tried to add it to tree.)

Avatar
saad
-

Your one2many field object is 'res.users' ?

Avatar
Marco Dieckhoff
-

No, it's not res.users, it's an own module in development. But it shouldn't matter at all, which object is related. (As long as it has an "active" field.)

0
Avatar
saad
Best Answer

I think you should override the search function of the one2many field object.

Avatar
Descartar