Skip to Content
Menu
This question has been flagged
2 Replies
3856 Views

Hey,

I try to acces to the buttons (type="object") of the header of a module because on click, it's set the wrong state to my statusbar..

I'm using studio, is it possible to access them ? How to create new ones (object type, not action type) for futur creations ?


PS: I only saw method for action buttons..

Avatar
Discard
Author

Thanks, but with the Sales module, I don't see where the create invoice button is liked. When I found his action (Settings > Technical > Actions) There's nothing but the type. No code that tell me how it's create a new invoice into the Accounting module.

Cause I'm looking for adding autofill data. Is it possible ?

Best Answer

Hi,

To make changes to the buttons or to add new buttons, you have to modify the XML code of the view.

For that, you need to enable debug mode. Then select the 'Edit View: Form' option from the debug options. You can see the main view. Navigate to the 'Inherited Views' tab and click on Add a line. A new form will be opened, where you can add the new button/ make changes to the new button by inheriting the existing view.

Provide a 'View Name' and select the current form view(The view from which the button is added(Either the parent view or any of its inherited view)) as 'Inherited View'. Then add the code in the text box under the 'Architecture' tab. For example:

<?xml version="1.0"?>


<data>


    <xpath expr="//button[@name='existing_button_1']" position="replace">


        <button name="replace_button_function" type="object" class="btn-primary" string="Updated Button"/>


    </xpath>


    <xpath expr="//button[@name='existing_button_2']" position="after">


        <button name="new_button_function" type="object" class="btn-primary" string="New Button"/>


    </xpath>


</data>


You have to add the changes in XML code in either a new inherited view or in the inherited view created by Odoo for Studio customizations(Preferred): The External ID starts with studio_customization.odoo_studio_. Don't modify the other existing views.

Regards

Avatar
Discard
Best Answer

Hi,

Using studio if you need to add a button that executes python functions, you can do it as follows.


Write a server action for that model with action to do as execute python code and write the necessary python codes there. Now in the view add button with type action and specify the id of the created action in the name of the button.


This is how type object in the code side is handled in the odoo studio.


For more, see this tutorial: https://www.youtube.com/watch?v=HC6Zw8A_uXo


Thanks

Avatar
Discard
Related Posts Replies Views Activity
2
Mar 15
7570
2
Jul 17
4273
1
May 25
66
2
Mar 25
696
0
Feb 25
456