Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
10 Antwoorden
39629 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Beste antwoord

Try to specify active_test in context to ignore active field


 <field name="remote_ids" context="{'active_test':False}">...
Avatar
Annuleer
Beste antwoord
  • 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..

Avatar
Annuleer
Auteur

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

Then you must inherit one from the model.from

Auteur

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.)

Your one2many field object is 'res.users' ?

Auteur

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.)

Beste antwoord

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

Avatar
Annuleer
Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
4
dec. 23
17677
1
sep. 16
7398
0
mrt. 15
3643
1
mrt. 15
6757
0
sep. 24
296