1

I have added

<div class="oe_button_box" name="button_box">
    <field name="active" invisible="1"/>
    <button type="object" class="oe_stat_button" icon="fa-archive" name="toggle_active" string="Archive" attrs="{'invisible': [('active', '=', False)]}"/>
    <button type="object" class="oe_stat_button" icon="fa-archive" name="toggle_active" string="Restore" attrs="{'invisible': [('active', '=', True)]}"/>
</div>
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>

this to the sheet of the form of my view but unfortunately, the buttons do not get displayed.

This is what I want:

image with archive action

But this is what it looks like:

image without archive action

what is missing?

unnamed-dev
  • 165
  • 8

1 Answers1

1

That is not the button box but the action menu. IIRC you can't add anything there by extending a view, but by creating actions.

And if you want to add the archive functionality in Odoo 14+ you just have to add the field active invisible in your form view. That should be enough and is an exception to my statement before ;-)

If you need the ribbon, you have to add that, too, like in your example.

Edit: seems you should not put the field active into a div or probably the button_box div.

CZoellner
  • 13,553
  • 3
  • 25
  • 38
  • can you further explain what you mean with active invisible? I have added `active = fields.Boolean('Active', default=True)` To my model, what do I have to change? @CZoellner – unnamed-dev Jan 03 '22 at 11:31
  • I meant adding it to the view as normal field but with `invisible="1"`. But i see now, that you've already done that in your view. So the action "Archive" should be there already, hmm. – CZoellner Jan 03 '22 at 13:12
  • 1
    Maybe the div around it has some effect on it. Try to get it outside of that div. – CZoellner Jan 03 '22 at 13:13
  • 1
    Putting it outside of the div solved the problem. If you edit your answer that it contains it or post a new answer I will mark it as correct! Thank you for helping – unnamed-dev Jan 03 '22 at 13:40
  • 1
    added it. Thanks for the hint. – CZoellner Jan 03 '22 at 16:28