Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
10 Odpovědi
39622 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

Try to specify active_test in context to ignore active field


 <field name="remote_ids" context="{'active_test':False}">...
Avatar
Zrušit
Nejlepší odpověď
  • 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
Zrušit
Autor

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

Autor

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' ?

Autor

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

Nejlepší odpověď

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

Avatar
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
4
pro 23
17677
1
zář 16
7396
0
bře 15
3643
1
bře 15
6757
0
zář 24
296